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

// InputCollectibleUsername represents TL type `inputCollectibleUsername#e39460a9`.
// Represents a username fragment collectible¹
//
// Links:
//  1. https://core.telegram.org/api/fragment
//
// See https://core.telegram.org/constructor/inputCollectibleUsername for reference.
type InputCollectibleUsername struct {
	// Username
	Username string
}

// InputCollectibleUsernameTypeID is TL type id of InputCollectibleUsername.
const InputCollectibleUsernameTypeID = 0xe39460a9

// construct implements constructor of InputCollectibleClass.
func ( InputCollectibleUsername) () InputCollectibleClass { return & }

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

	_ InputCollectibleClass = &InputCollectibleUsername{}
)

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

	return true
}

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

// FillFrom fills InputCollectibleUsername from given interface.
func ( *InputCollectibleUsername) ( interface {
	() ( string)
}) {
	.Username = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputCollectibleUsername) () tdp.Type {
	 := tdp.Type{
		Name: "inputCollectibleUsername",
		ID:   InputCollectibleUsernameTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Username",
			SchemaName: "username",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputCollectibleUsername) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputCollectibleUsername#e39460a9 as nil")
	}
	.PutID(InputCollectibleUsernameTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputCollectibleUsername) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputCollectibleUsername#e39460a9 as nil")
	}
	.PutString(.Username)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputCollectibleUsername) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputCollectibleUsername#e39460a9 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputCollectibleUsername#e39460a9: field username: %w", )
		}
		.Username = 
	}
	return nil
}

// GetUsername returns value of Username field.
func ( *InputCollectibleUsername) () ( string) {
	if  == nil {
		return
	}
	return .Username
}

// InputCollectiblePhone represents TL type `inputCollectiblePhone#a2e214a4`.
// Represents a phone number fragment collectible¹
//
// Links:
//  1. https://core.telegram.org/api/fragment
//
// See https://core.telegram.org/constructor/inputCollectiblePhone for reference.
type InputCollectiblePhone struct {
	// Phone number
	Phone string
}

// InputCollectiblePhoneTypeID is TL type id of InputCollectiblePhone.
const InputCollectiblePhoneTypeID = 0xa2e214a4

// construct implements constructor of InputCollectibleClass.
func ( InputCollectiblePhone) () InputCollectibleClass { return & }

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

	_ InputCollectibleClass = &InputCollectiblePhone{}
)

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

	return true
}

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

// FillFrom fills InputCollectiblePhone from given interface.
func ( *InputCollectiblePhone) ( interface {
	() ( string)
}) {
	.Phone = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputCollectiblePhone) () tdp.Type {
	 := tdp.Type{
		Name: "inputCollectiblePhone",
		ID:   InputCollectiblePhoneTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Phone",
			SchemaName: "phone",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputCollectiblePhone) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputCollectiblePhone#a2e214a4 as nil")
	}
	.PutID(InputCollectiblePhoneTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputCollectiblePhone) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputCollectiblePhone#a2e214a4 as nil")
	}
	.PutString(.Phone)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputCollectiblePhone) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputCollectiblePhone#a2e214a4 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputCollectiblePhone#a2e214a4: field phone: %w", )
		}
		.Phone = 
	}
	return nil
}

// GetPhone returns value of Phone field.
func ( *InputCollectiblePhone) () ( string) {
	if  == nil {
		return
	}
	return .Phone
}

// InputCollectibleClassName is schema name of InputCollectibleClass.
const InputCollectibleClassName = "InputCollectible"

// InputCollectibleClass represents InputCollectible generic type.
//
// See https://core.telegram.org/type/InputCollectible for reference.
//
// Constructors:
//   - [InputCollectibleUsername]
//   - [InputCollectiblePhone]
//
// Example:
//
//	g, err := tg.DecodeInputCollectible(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.InputCollectibleUsername: // inputCollectibleUsername#e39460a9
//	case *tg.InputCollectiblePhone: // inputCollectiblePhone#a2e214a4
//	default: panic(v)
//	}
type InputCollectibleClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputCollectibleClass

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

// DecodeInputCollectible implements binary de-serialization for InputCollectibleClass.
func ( *bin.Buffer) (InputCollectibleClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case InputCollectibleUsernameTypeID:
		// Decoding inputCollectibleUsername#e39460a9.
		 := InputCollectibleUsername{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputCollectibleClass: %w", )
		}
		return &, nil
	case InputCollectiblePhoneTypeID:
		// Decoding inputCollectiblePhone#a2e214a4.
		 := InputCollectiblePhone{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputCollectibleClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode InputCollectibleClass: %w", bin.NewUnexpectedID())
	}
}

// InputCollectible boxes the InputCollectibleClass providing a helper.
type InputCollectibleBox struct {
	InputCollectible InputCollectibleClass
}

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

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