// 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{}
)

// PremiumGiftOption represents TL type `premiumGiftOption#74c34319`.
// Telegram Premium gift option
//
// See https://core.telegram.org/constructor/premiumGiftOption for reference.
type PremiumGiftOption struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Duration of gifted Telegram Premium subscription
	Months int
	// Three-letter ISO 4217 currency¹ code
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments#supported-currencies
	Currency string
	// Price of the product in the smallest units of the currency (integer, not float/double)
	// For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in
	// currencies.json¹, it shows the number of digits past the decimal point for each
	// currency (2 for the majority of currencies).
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments/currencies.json
	Amount int64
	// An invoice deep link »¹ to an invoice for in-app payment, using the official Premium
	// bot; may be empty if direct payment isn't available.
	//
	// Links:
	//  1) https://core.telegram.org/api/links#invoice-links
	BotURL string
	// An identifier for the App Store/Play Store product associated with the Premium gift.
	//
	// Use SetStoreProduct and GetStoreProduct helpers.
	StoreProduct string
}

// PremiumGiftOptionTypeID is TL type id of PremiumGiftOption.
const PremiumGiftOptionTypeID = 0x74c34319

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

func ( *PremiumGiftOption) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Months == 0) {
		return false
	}
	if !(.Currency == "") {
		return false
	}
	if !(.Amount == 0) {
		return false
	}
	if !(.BotURL == "") {
		return false
	}
	if !(.StoreProduct == "") {
		return false
	}

	return true
}

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

// FillFrom fills PremiumGiftOption from given interface.
func ( *PremiumGiftOption) ( interface {
	() ( int)
	() ( string)
	() ( int64)
	() ( string)
	() ( string,  bool)
}) {
	.Months = .()
	.Currency = .()
	.Amount = .()
	.BotURL = .()
	if ,  := .();  {
		.StoreProduct = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *PremiumGiftOption) () tdp.Type {
	 := tdp.Type{
		Name: "premiumGiftOption",
		ID:   PremiumGiftOptionTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Months",
			SchemaName: "months",
		},
		{
			Name:       "Currency",
			SchemaName: "currency",
		},
		{
			Name:       "Amount",
			SchemaName: "amount",
		},
		{
			Name:       "BotURL",
			SchemaName: "bot_url",
		},
		{
			Name:       "StoreProduct",
			SchemaName: "store_product",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PremiumGiftOption) () {
	if !(.StoreProduct == "") {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *PremiumGiftOption) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode premiumGiftOption#74c34319 as nil")
	}
	.PutID(PremiumGiftOptionTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PremiumGiftOption) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode premiumGiftOption#74c34319 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode premiumGiftOption#74c34319: field flags: %w", )
	}
	.PutInt(.Months)
	.PutString(.Currency)
	.PutLong(.Amount)
	.PutString(.BotURL)
	if .Flags.Has(0) {
		.PutString(.StoreProduct)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PremiumGiftOption) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode premiumGiftOption#74c34319 to nil")
	}
	if  := .ConsumeID(PremiumGiftOptionTypeID);  != nil {
		return fmt.Errorf("unable to decode premiumGiftOption#74c34319: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PremiumGiftOption) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode premiumGiftOption#74c34319 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode premiumGiftOption#74c34319: field flags: %w", )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode premiumGiftOption#74c34319: field months: %w", )
		}
		.Months = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode premiumGiftOption#74c34319: field currency: %w", )
		}
		.Currency = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode premiumGiftOption#74c34319: field amount: %w", )
		}
		.Amount = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode premiumGiftOption#74c34319: field bot_url: %w", )
		}
		.BotURL = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode premiumGiftOption#74c34319: field store_product: %w", )
		}
		.StoreProduct = 
	}
	return nil
}

// GetMonths returns value of Months field.
func ( *PremiumGiftOption) () ( int) {
	if  == nil {
		return
	}
	return .Months
}

// GetCurrency returns value of Currency field.
func ( *PremiumGiftOption) () ( string) {
	if  == nil {
		return
	}
	return .Currency
}

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

// GetBotURL returns value of BotURL field.
func ( *PremiumGiftOption) () ( string) {
	if  == nil {
		return
	}
	return .BotURL
}

// SetStoreProduct sets value of StoreProduct conditional field.
func ( *PremiumGiftOption) ( string) {
	.Flags.Set(0)
	.StoreProduct = 
}

// GetStoreProduct returns value of StoreProduct conditional field and
// boolean which is true if field was set.
func ( *PremiumGiftOption) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .StoreProduct, true
}