// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// StarsSubscriptionPricing represents TL type `starsSubscriptionPricing#5416d58`.
// Pricing of a Telegram Star subscription »¹.
//
// Links:
//  1. https://core.telegram.org/api/invites#paid-invite-links
//
// See https://core.telegram.org/constructor/starsSubscriptionPricing for reference.
type StarsSubscriptionPricing struct {
	// The user should pay amount stars every period seconds to gain and maintain access to
	// the channel. Currently the only allowed subscription period is 30*24*60*60, i.e. the
	// user will be debited amount stars every month.
	Period int
	// Price of the subscription in Telegram Stars.
	Amount int64
}

// StarsSubscriptionPricingTypeID is TL type id of StarsSubscriptionPricing.
const StarsSubscriptionPricingTypeID = 0x5416d58

// Ensuring interfaces in compile-time for StarsSubscriptionPricing.
var (
	_ bin.Encoder     = &StarsSubscriptionPricing{}
	_ bin.Decoder     = &StarsSubscriptionPricing{}
	_ bin.BareEncoder = &StarsSubscriptionPricing{}
	_ bin.BareDecoder = &StarsSubscriptionPricing{}
)

func ( *StarsSubscriptionPricing) () bool {
	if  == nil {
		return true
	}
	if !(.Period == 0) {
		return false
	}
	if !(.Amount == 0) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *StarsSubscriptionPricing) () string {
	if  == nil {
		return "StarsSubscriptionPricing(nil)"
	}
	type  StarsSubscriptionPricing
	return fmt.Sprintf("StarsSubscriptionPricing%+v", (*))
}

// FillFrom fills StarsSubscriptionPricing from given interface.
func ( *StarsSubscriptionPricing) ( interface {
	() ( int)
	() ( int64)
}) {
	.Period = .()
	.Amount = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*StarsSubscriptionPricing) () uint32 {
	return StarsSubscriptionPricingTypeID
}

// TypeName returns name of type in TL schema.
func (*StarsSubscriptionPricing) () string {
	return "starsSubscriptionPricing"
}

// TypeInfo returns info about TL type.
func ( *StarsSubscriptionPricing) () tdp.Type {
	 := tdp.Type{
		Name: "starsSubscriptionPricing",
		ID:   StarsSubscriptionPricingTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Period",
			SchemaName: "period",
		},
		{
			Name:       "Amount",
			SchemaName: "amount",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StarsSubscriptionPricing) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starsSubscriptionPricing#5416d58 as nil")
	}
	.PutID(StarsSubscriptionPricingTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarsSubscriptionPricing) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starsSubscriptionPricing#5416d58 as nil")
	}
	.PutInt(.Period)
	.PutLong(.Amount)
	return nil
}

// Decode implements bin.Decoder.
func ( *StarsSubscriptionPricing) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starsSubscriptionPricing#5416d58 to nil")
	}
	if  := .ConsumeID(StarsSubscriptionPricingTypeID);  != nil {
		return fmt.Errorf("unable to decode starsSubscriptionPricing#5416d58: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *StarsSubscriptionPricing) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starsSubscriptionPricing#5416d58 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starsSubscriptionPricing#5416d58: field period: %w", )
		}
		.Period = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode starsSubscriptionPricing#5416d58: field amount: %w", )
		}
		.Amount = 
	}
	return nil
}

// GetPeriod returns value of Period field.
func ( *StarsSubscriptionPricing) () ( int) {
	if  == nil {
		return
	}
	return .Period
}

// GetAmount returns value of Amount field.
func ( *StarsSubscriptionPricing) () ( int64) {
	if  == nil {
		return
	}
	return .Amount
}