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

// Ensuring interfaces in compile-time for PrepaidGiveaway.
var (
	_ bin.Encoder     = &PrepaidGiveaway{}
	_ bin.Decoder     = &PrepaidGiveaway{}
	_ bin.BareEncoder = &PrepaidGiveaway{}
	_ bin.BareDecoder = &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
}