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

// StarGiftAuctionAcquiredGift represents TL type `starGiftAuctionAcquiredGift#42b00348`.
// Describes a gift that the current user won in an auction.
//
// See https://core.telegram.org/constructor/starGiftAuctionAcquiredGift for reference.
type StarGiftAuctionAcquiredGift struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, your name will be hidden if the destination peer decides to display the gift
	// on their profile (they will still see that you sent the gift).
	NameHidden bool
	// The peer that received the gift.
	Peer PeerClass
	// When was the gift obtained.
	Date int
	// The amount in Telegram Stars¹ that was bid in order to obtain the gift.
	//
	// Links:
	//  1) https://core.telegram.org/api/stars
	BidAmount int64
	// The round number where the gift was obtained.
	Round int
	// The position of the gift in the auction.
	Pos int
	// Optional message that attached with the gift, passed when making the bid.
	//
	// Use SetMessage and GetMessage helpers.
	Message TextWithEntities
	// If set, the collectible number of the won gift among all collectibles of the same type.
	//
	// Use SetGiftNum and GetGiftNum helpers.
	GiftNum int
}

// StarGiftAuctionAcquiredGiftTypeID is TL type id of StarGiftAuctionAcquiredGift.
const StarGiftAuctionAcquiredGiftTypeID = 0x42b00348

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

func ( *StarGiftAuctionAcquiredGift) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.NameHidden == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.BidAmount == 0) {
		return false
	}
	if !(.Round == 0) {
		return false
	}
	if !(.Pos == 0) {
		return false
	}
	if !(.Message.Zero()) {
		return false
	}
	if !(.GiftNum == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StarGiftAuctionAcquiredGift from given interface.
func ( *StarGiftAuctionAcquiredGift) ( interface {
	() ( bool)
	() ( PeerClass)
	() ( int)
	() ( int64)
	() ( int)
	() ( int)
	() ( TextWithEntities,  bool)
	() ( int,  bool)
}) {
	.NameHidden = .()
	.Peer = .()
	.Date = .()
	.BidAmount = .()
	.Round = .()
	.Pos = .()
	if ,  := .();  {
		.Message = 
	}

	if ,  := .();  {
		.GiftNum = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *StarGiftAuctionAcquiredGift) () tdp.Type {
	 := tdp.Type{
		Name: "starGiftAuctionAcquiredGift",
		ID:   StarGiftAuctionAcquiredGiftTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "NameHidden",
			SchemaName: "name_hidden",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "BidAmount",
			SchemaName: "bid_amount",
		},
		{
			Name:       "Round",
			SchemaName: "round",
		},
		{
			Name:       "Pos",
			SchemaName: "pos",
		},
		{
			Name:       "Message",
			SchemaName: "message",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "GiftNum",
			SchemaName: "gift_num",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *StarGiftAuctionAcquiredGift) () {
	if !(.NameHidden == false) {
		.Flags.Set(0)
	}
	if !(.Message.Zero()) {
		.Flags.Set(1)
	}
	if !(.GiftNum == 0) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *StarGiftAuctionAcquiredGift) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAuctionAcquiredGift#42b00348 as nil")
	}
	.PutID(StarGiftAuctionAcquiredGiftTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarGiftAuctionAcquiredGift) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAuctionAcquiredGift#42b00348 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode starGiftAuctionAcquiredGift#42b00348: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode starGiftAuctionAcquiredGift#42b00348: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode starGiftAuctionAcquiredGift#42b00348: field peer: %w", )
	}
	.PutInt(.Date)
	.PutLong(.BidAmount)
	.PutInt(.Round)
	.PutInt(.Pos)
	if .Flags.Has(1) {
		if  := .Message.Encode();  != nil {
			return fmt.Errorf("unable to encode starGiftAuctionAcquiredGift#42b00348: field message: %w", )
		}
	}
	if .Flags.Has(2) {
		.PutInt(.GiftNum)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StarGiftAuctionAcquiredGift) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAuctionAcquiredGift#42b00348 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode starGiftAuctionAcquiredGift#42b00348: field flags: %w", )
		}
	}
	.NameHidden = .Flags.Has(0)
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAuctionAcquiredGift#42b00348: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAuctionAcquiredGift#42b00348: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAuctionAcquiredGift#42b00348: field bid_amount: %w", )
		}
		.BidAmount = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAuctionAcquiredGift#42b00348: field round: %w", )
		}
		.Round = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAuctionAcquiredGift#42b00348: field pos: %w", )
		}
		.Pos = 
	}
	if .Flags.Has(1) {
		if  := .Message.Decode();  != nil {
			return fmt.Errorf("unable to decode starGiftAuctionAcquiredGift#42b00348: field message: %w", )
		}
	}
	if .Flags.Has(2) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAuctionAcquiredGift#42b00348: field gift_num: %w", )
		}
		.GiftNum = 
	}
	return nil
}

// SetNameHidden sets value of NameHidden conditional field.
func ( *StarGiftAuctionAcquiredGift) ( bool) {
	if  {
		.Flags.Set(0)
		.NameHidden = true
	} else {
		.Flags.Unset(0)
		.NameHidden = false
	}
}

// GetNameHidden returns value of NameHidden conditional field.
func ( *StarGiftAuctionAcquiredGift) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

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

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

// GetBidAmount returns value of BidAmount field.
func ( *StarGiftAuctionAcquiredGift) () ( int64) {
	if  == nil {
		return
	}
	return .BidAmount
}

// GetRound returns value of Round field.
func ( *StarGiftAuctionAcquiredGift) () ( int) {
	if  == nil {
		return
	}
	return .Round
}

// GetPos returns value of Pos field.
func ( *StarGiftAuctionAcquiredGift) () ( int) {
	if  == nil {
		return
	}
	return .Pos
}

// SetMessage sets value of Message conditional field.
func ( *StarGiftAuctionAcquiredGift) ( TextWithEntities) {
	.Flags.Set(1)
	.Message = 
}

// GetMessage returns value of Message conditional field and
// boolean which is true if field was set.
func ( *StarGiftAuctionAcquiredGift) () ( TextWithEntities,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Message, true
}

// SetGiftNum sets value of GiftNum conditional field.
func ( *StarGiftAuctionAcquiredGift) ( int) {
	.Flags.Set(2)
	.GiftNum = 
}

// GetGiftNum returns value of GiftNum conditional field and
// boolean which is true if field was set.
func ( *StarGiftAuctionAcquiredGift) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .GiftNum, true
}