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

// InputInvoiceMessage represents TL type `inputInvoiceMessage#c5b56859`.
// An invoice contained in a messageMediaInvoice¹ message.
//
// Links:
//  1. https://core.telegram.org/constructor/messageMediaInvoice
//
// See https://core.telegram.org/constructor/inputInvoiceMessage for reference.
type InputInvoiceMessage struct {
	// Chat where the invoice was sent
	Peer InputPeerClass
	// Message ID
	MsgID int
}

// InputInvoiceMessageTypeID is TL type id of InputInvoiceMessage.
const InputInvoiceMessageTypeID = 0xc5b56859

// construct implements constructor of InputInvoiceClass.
func ( InputInvoiceMessage) () InputInvoiceClass { return & }

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

	_ InputInvoiceClass = &InputInvoiceMessage{}
)

func ( *InputInvoiceMessage) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.MsgID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills InputInvoiceMessage from given interface.
func ( *InputInvoiceMessage) ( interface {
	() ( InputPeerClass)
	() ( int)
}) {
	.Peer = .()
	.MsgID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputInvoiceMessage) () tdp.Type {
	 := tdp.Type{
		Name: "inputInvoiceMessage",
		ID:   InputInvoiceMessageTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "MsgID",
			SchemaName: "msg_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputInvoiceMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputInvoiceMessage#c5b56859 as nil")
	}
	.PutID(InputInvoiceMessageTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputInvoiceMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputInvoiceMessage#c5b56859 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode inputInvoiceMessage#c5b56859: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode inputInvoiceMessage#c5b56859: field peer: %w", )
	}
	.PutInt(.MsgID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputInvoiceMessage) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputInvoiceMessage#c5b56859 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode inputInvoiceMessage#c5b56859: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode inputInvoiceMessage#c5b56859: field msg_id: %w", )
		}
		.MsgID = 
	}
	return nil
}

// GetPeer returns value of Peer field.
func ( *InputInvoiceMessage) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// GetMsgID returns value of MsgID field.
func ( *InputInvoiceMessage) () ( int) {
	if  == nil {
		return
	}
	return .MsgID
}

// InputInvoiceSlug represents TL type `inputInvoiceSlug#c326caef`.
// An invoice slug taken from an invoice deep link¹ or from the premium_invoice_slug app
// config parameter »²
//
// Links:
//  1. https://core.telegram.org/api/links#invoice-links
//  2. https://core.telegram.org/api/config#premium-invoice-slug
//
// See https://core.telegram.org/constructor/inputInvoiceSlug for reference.
type InputInvoiceSlug struct {
	// The invoice slug
	Slug string
}

// InputInvoiceSlugTypeID is TL type id of InputInvoiceSlug.
const InputInvoiceSlugTypeID = 0xc326caef

// construct implements constructor of InputInvoiceClass.
func ( InputInvoiceSlug) () InputInvoiceClass { return & }

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

	_ InputInvoiceClass = &InputInvoiceSlug{}
)

func ( *InputInvoiceSlug) () bool {
	if  == nil {
		return true
	}
	if !(.Slug == "") {
		return false
	}

	return true
}

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

// FillFrom fills InputInvoiceSlug from given interface.
func ( *InputInvoiceSlug) ( interface {
	() ( string)
}) {
	.Slug = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputInvoiceSlug) () tdp.Type {
	 := tdp.Type{
		Name: "inputInvoiceSlug",
		ID:   InputInvoiceSlugTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Slug",
			SchemaName: "slug",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputInvoiceSlug) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputInvoiceSlug#c326caef as nil")
	}
	.PutID(InputInvoiceSlugTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputInvoiceSlug) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputInvoiceSlug#c326caef as nil")
	}
	.PutString(.Slug)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputInvoiceSlug) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputInvoiceSlug#c326caef to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputInvoiceSlug#c326caef: field slug: %w", )
		}
		.Slug = 
	}
	return nil
}

// GetSlug returns value of Slug field.
func ( *InputInvoiceSlug) () ( string) {
	if  == nil {
		return
	}
	return .Slug
}

// InputInvoicePremiumGiftCode represents TL type `inputInvoicePremiumGiftCode#98986c0d`.
// Used if the user wishes to start a channel giveaway¹ or send some giftcodes² to
// members of a channel, in exchange for boosts³.
//
// Links:
//  1. https://core.telegram.org/api/giveaways
//  2. https://core.telegram.org/api/giveaways
//  3. https://core.telegram.org/api/boost
//
// See https://core.telegram.org/constructor/inputInvoicePremiumGiftCode for reference.
type InputInvoicePremiumGiftCode struct {
	// Should be populated with inputStorePaymentPremiumGiveaway¹ for giveaways² and
	// inputStorePaymentPremiumGiftCode³ for gifts⁴.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/inputStorePaymentPremiumGiveaway
	//  2) https://core.telegram.org/api/giveaways
	//  3) https://core.telegram.org/constructor/inputStorePaymentPremiumGiftCode
	//  4) https://core.telegram.org/api/giveaways
	Purpose InputStorePaymentPurposeClass
	// Should be populated with one of the giveaway options returned by payments
	// getPremiumGiftCodeOptions¹, see the giveaways »² documentation for more info.
	//
	// Links:
	//  1) https://core.telegram.org/method/payments.getPremiumGiftCodeOptions
	//  2) https://core.telegram.org/api/giveaways
	Option PremiumGiftCodeOption
}

// InputInvoicePremiumGiftCodeTypeID is TL type id of InputInvoicePremiumGiftCode.
const InputInvoicePremiumGiftCodeTypeID = 0x98986c0d

// construct implements constructor of InputInvoiceClass.
func ( InputInvoicePremiumGiftCode) () InputInvoiceClass { return & }

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

	_ InputInvoiceClass = &InputInvoicePremiumGiftCode{}
)

func ( *InputInvoicePremiumGiftCode) () bool {
	if  == nil {
		return true
	}
	if !(.Purpose == nil) {
		return false
	}
	if !(.Option.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills InputInvoicePremiumGiftCode from given interface.
func ( *InputInvoicePremiumGiftCode) ( interface {
	() ( InputStorePaymentPurposeClass)
	() ( PremiumGiftCodeOption)
}) {
	.Purpose = .()
	.Option = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputInvoicePremiumGiftCode) () tdp.Type {
	 := tdp.Type{
		Name: "inputInvoicePremiumGiftCode",
		ID:   InputInvoicePremiumGiftCodeTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Purpose",
			SchemaName: "purpose",
		},
		{
			Name:       "Option",
			SchemaName: "option",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputInvoicePremiumGiftCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputInvoicePremiumGiftCode#98986c0d as nil")
	}
	.PutID(InputInvoicePremiumGiftCodeTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputInvoicePremiumGiftCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputInvoicePremiumGiftCode#98986c0d as nil")
	}
	if .Purpose == nil {
		return fmt.Errorf("unable to encode inputInvoicePremiumGiftCode#98986c0d: field purpose is nil")
	}
	if  := .Purpose.Encode();  != nil {
		return fmt.Errorf("unable to encode inputInvoicePremiumGiftCode#98986c0d: field purpose: %w", )
	}
	if  := .Option.Encode();  != nil {
		return fmt.Errorf("unable to encode inputInvoicePremiumGiftCode#98986c0d: field option: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *InputInvoicePremiumGiftCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputInvoicePremiumGiftCode#98986c0d to nil")
	}
	if  := .ConsumeID(InputInvoicePremiumGiftCodeTypeID);  != nil {
		return fmt.Errorf("unable to decode inputInvoicePremiumGiftCode#98986c0d: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *InputInvoicePremiumGiftCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputInvoicePremiumGiftCode#98986c0d to nil")
	}
	{
		,  := DecodeInputStorePaymentPurpose()
		if  != nil {
			return fmt.Errorf("unable to decode inputInvoicePremiumGiftCode#98986c0d: field purpose: %w", )
		}
		.Purpose = 
	}
	{
		if  := .Option.Decode();  != nil {
			return fmt.Errorf("unable to decode inputInvoicePremiumGiftCode#98986c0d: field option: %w", )
		}
	}
	return nil
}

// GetPurpose returns value of Purpose field.
func ( *InputInvoicePremiumGiftCode) () ( InputStorePaymentPurposeClass) {
	if  == nil {
		return
	}
	return .Purpose
}

// GetOption returns value of Option field.
func ( *InputInvoicePremiumGiftCode) () ( PremiumGiftCodeOption) {
	if  == nil {
		return
	}
	return .Option
}

// InputInvoiceClassName is schema name of InputInvoiceClass.
const InputInvoiceClassName = "InputInvoice"

// InputInvoiceClass represents InputInvoice generic type.
//
// See https://core.telegram.org/type/InputInvoice for reference.
//
// Example:
//
//	g, err := tg.DecodeInputInvoice(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.InputInvoiceMessage: // inputInvoiceMessage#c5b56859
//	case *tg.InputInvoiceSlug: // inputInvoiceSlug#c326caef
//	case *tg.InputInvoicePremiumGiftCode: // inputInvoicePremiumGiftCode#98986c0d
//	default: panic(v)
//	}
type InputInvoiceClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputInvoiceClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool
}

// DecodeInputInvoice implements binary de-serialization for InputInvoiceClass.
func ( *bin.Buffer) (InputInvoiceClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case InputInvoiceMessageTypeID:
		// Decoding inputInvoiceMessage#c5b56859.
		 := InputInvoiceMessage{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputInvoiceClass: %w", )
		}
		return &, nil
	case InputInvoiceSlugTypeID:
		// Decoding inputInvoiceSlug#c326caef.
		 := InputInvoiceSlug{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputInvoiceClass: %w", )
		}
		return &, nil
	case InputInvoicePremiumGiftCodeTypeID:
		// Decoding inputInvoicePremiumGiftCode#98986c0d.
		 := InputInvoicePremiumGiftCode{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputInvoiceClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode InputInvoiceClass: %w", bin.NewUnexpectedID())
	}
}

// InputInvoice boxes the InputInvoiceClass providing a helper.
type InputInvoiceBox struct {
	InputInvoice InputInvoiceClass
}

// Decode implements bin.Decoder for InputInvoiceBox.
func ( *InputInvoiceBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode InputInvoiceBox to nil")
	}
	,  := DecodeInputInvoice()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.InputInvoice = 
	return nil
}

// Encode implements bin.Encode for InputInvoiceBox.
func ( *InputInvoiceBox) ( *bin.Buffer) error {
	if  == nil || .InputInvoice == nil {
		return fmt.Errorf("unable to encode InputInvoiceClass as nil")
	}
	return .InputInvoice.Encode()
}