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

// PrepaidGiveaway represents TL type `prepaidGiveaway#b2539d54`.
// Contains info about a prepaid giveaway »¹.
//
// Links:
//  1. https://core.telegram.org/api/giveaways
//
// See https://core.telegram.org/constructor/prepaidGiveaway for reference.
type PrepaidGiveaway struct {
	// Prepaid giveaway ID.
	ID int64
	// Duration in months of each gifted Telegram Premium¹ subscription.
	//
	// Links:
	//  1) https://core.telegram.org/api/premium
	Months int
	// Number of given away Telegram Premium¹ subscriptions.
	//
	// Links:
	//  1) https://core.telegram.org/api/premium
	Quantity int
	// Payment date.
	Date int
}

// PrepaidGiveawayTypeID is TL type id of PrepaidGiveaway.
const PrepaidGiveawayTypeID = 0xb2539d54

// construct implements constructor of PrepaidGiveawayClass.
func ( PrepaidGiveaway) () PrepaidGiveawayClass { return & }

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

	_ PrepaidGiveawayClass = &PrepaidGiveaway{}
)

func ( *PrepaidGiveaway) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}
	if !(.Months == 0) {
		return false
	}
	if !(.Quantity == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}

	return true
}

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

// FillFrom fills PrepaidGiveaway from given interface.
func ( *PrepaidGiveaway) ( interface {
	() ( int64)
	() ( int)
	() ( int)
	() ( int)
}) {
	.ID = .()
	.Months = .()
	.Quantity = .()
	.Date = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PrepaidGiveaway) () tdp.Type {
	 := tdp.Type{
		Name: "prepaidGiveaway",
		ID:   PrepaidGiveawayTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Months",
			SchemaName: "months",
		},
		{
			Name:       "Quantity",
			SchemaName: "quantity",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PrepaidGiveaway) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode prepaidGiveaway#b2539d54 as nil")
	}
	.PutID(PrepaidGiveawayTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PrepaidGiveaway) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode prepaidGiveaway#b2539d54 as nil")
	}
	.PutLong(.ID)
	.PutInt(.Months)
	.PutInt(.Quantity)
	.PutInt(.Date)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PrepaidGiveaway) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode prepaidGiveaway#b2539d54 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode prepaidGiveaway#b2539d54: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode prepaidGiveaway#b2539d54: field months: %w", )
		}
		.Months = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode prepaidGiveaway#b2539d54: field quantity: %w", )
		}
		.Quantity = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode prepaidGiveaway#b2539d54: field date: %w", )
		}
		.Date = 
	}
	return nil
}

// GetID returns value of ID field.
func ( *PrepaidGiveaway) () ( int64) {
	if  == nil {
		return
	}
	return .ID
}

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

// GetQuantity returns value of Quantity field.
func ( *PrepaidGiveaway) () ( int) {
	if  == nil {
		return
	}
	return .Quantity
}

// GetDate returns value of Date field.
func ( *PrepaidGiveaway) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// PrepaidStarsGiveaway represents TL type `prepaidStarsGiveaway#9a9d77e0`.
// Contains info about a prepaid Telegram Star giveaway »¹.
//
// Links:
//  1. https://core.telegram.org/api/giveaways#star-giveaways
//
// See https://core.telegram.org/constructor/prepaidStarsGiveaway for reference.
type PrepaidStarsGiveaway struct {
	// Prepaid giveaway ID.
	ID int64
	// Number of given away Telegram Stars »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/stars
	Stars int64
	// Number of giveaway winners
	Quantity int
	// Number of boosts the channel will gain by launching the giveaway.
	Boosts int
	// When was the giveaway paid for
	Date int
}

// PrepaidStarsGiveawayTypeID is TL type id of PrepaidStarsGiveaway.
const PrepaidStarsGiveawayTypeID = 0x9a9d77e0

// construct implements constructor of PrepaidGiveawayClass.
func ( PrepaidStarsGiveaway) () PrepaidGiveawayClass { return & }

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

	_ PrepaidGiveawayClass = &PrepaidStarsGiveaway{}
)

func ( *PrepaidStarsGiveaway) () bool {
	if  == nil {
		return true
	}
	if !(.ID == 0) {
		return false
	}
	if !(.Stars == 0) {
		return false
	}
	if !(.Quantity == 0) {
		return false
	}
	if !(.Boosts == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}

	return true
}

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

// FillFrom fills PrepaidStarsGiveaway from given interface.
func ( *PrepaidStarsGiveaway) ( interface {
	() ( int64)
	() ( int64)
	() ( int)
	() ( int)
	() ( int)
}) {
	.ID = .()
	.Stars = .()
	.Quantity = .()
	.Boosts = .()
	.Date = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PrepaidStarsGiveaway) () tdp.Type {
	 := tdp.Type{
		Name: "prepaidStarsGiveaway",
		ID:   PrepaidStarsGiveawayTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Stars",
			SchemaName: "stars",
		},
		{
			Name:       "Quantity",
			SchemaName: "quantity",
		},
		{
			Name:       "Boosts",
			SchemaName: "boosts",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PrepaidStarsGiveaway) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode prepaidStarsGiveaway#9a9d77e0 as nil")
	}
	.PutID(PrepaidStarsGiveawayTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PrepaidStarsGiveaway) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode prepaidStarsGiveaway#9a9d77e0 as nil")
	}
	.PutLong(.ID)
	.PutLong(.Stars)
	.PutInt(.Quantity)
	.PutInt(.Boosts)
	.PutInt(.Date)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PrepaidStarsGiveaway) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode prepaidStarsGiveaway#9a9d77e0 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode prepaidStarsGiveaway#9a9d77e0: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode prepaidStarsGiveaway#9a9d77e0: field stars: %w", )
		}
		.Stars = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode prepaidStarsGiveaway#9a9d77e0: field quantity: %w", )
		}
		.Quantity = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode prepaidStarsGiveaway#9a9d77e0: field boosts: %w", )
		}
		.Boosts = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode prepaidStarsGiveaway#9a9d77e0: field date: %w", )
		}
		.Date = 
	}
	return nil
}

// GetID returns value of ID field.
func ( *PrepaidStarsGiveaway) () ( int64) {
	if  == nil {
		return
	}
	return .ID
}

// GetStars returns value of Stars field.
func ( *PrepaidStarsGiveaway) () ( int64) {
	if  == nil {
		return
	}
	return .Stars
}

// GetQuantity returns value of Quantity field.
func ( *PrepaidStarsGiveaway) () ( int) {
	if  == nil {
		return
	}
	return .Quantity
}

// GetBoosts returns value of Boosts field.
func ( *PrepaidStarsGiveaway) () ( int) {
	if  == nil {
		return
	}
	return .Boosts
}

// GetDate returns value of Date field.
func ( *PrepaidStarsGiveaway) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// PrepaidGiveawayClassName is schema name of PrepaidGiveawayClass.
const PrepaidGiveawayClassName = "PrepaidGiveaway"

// PrepaidGiveawayClass represents PrepaidGiveaway generic type.
//
// See https://core.telegram.org/type/PrepaidGiveaway for reference.
//
// Constructors:
//   - [PrepaidGiveaway]
//   - [PrepaidStarsGiveaway]
//
// Example:
//
//	g, err := tg.DecodePrepaidGiveaway(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.PrepaidGiveaway: // prepaidGiveaway#b2539d54
//	case *tg.PrepaidStarsGiveaway: // prepaidStarsGiveaway#9a9d77e0
//	default: panic(v)
//	}
type PrepaidGiveawayClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() PrepaidGiveawayClass

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

	// Prepaid giveaway ID.
	GetID() (value int64)

	// Number of given away Telegram Premium¹ subscriptions.
	//
	// Links:
	//  1) https://core.telegram.org/api/premium
	GetQuantity() (value int)

	// Payment date.
	GetDate() (value int)
}

// DecodePrepaidGiveaway implements binary de-serialization for PrepaidGiveawayClass.
func ( *bin.Buffer) (PrepaidGiveawayClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case PrepaidGiveawayTypeID:
		// Decoding prepaidGiveaway#b2539d54.
		 := PrepaidGiveaway{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PrepaidGiveawayClass: %w", )
		}
		return &, nil
	case PrepaidStarsGiveawayTypeID:
		// Decoding prepaidStarsGiveaway#9a9d77e0.
		 := PrepaidStarsGiveaway{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PrepaidGiveawayClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode PrepaidGiveawayClass: %w", bin.NewUnexpectedID())
	}
}

// PrepaidGiveaway boxes the PrepaidGiveawayClass providing a helper.
type PrepaidGiveawayBox struct {
	PrepaidGiveaway PrepaidGiveawayClass
}

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

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