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

// Boost represents TL type `boost#2a1c8c71`.
// Info about one or more boosts¹ applied by a specific user.
//
// Links:
//  1. https://core.telegram.org/api/boost
//
// See https://core.telegram.org/constructor/boost for reference.
type Boost struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether this boost was applied because the channel directly gifted a subscription to
	// the user¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/giveaways
	Gift bool
	// Whether this boost was applied because the user was chosen in a giveaway started by
	// the channel¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/giveaways
	Giveaway bool
	// If set, the user hasn't yet invoked payments.applyGiftCode¹ to claim a subscription
	// gifted directly or in a giveaway by the channel².
	//
	// Links:
	//  1) https://core.telegram.org/method/payments.applyGiftCode
	//  2) https://core.telegram.org/api/giveaways
	Unclaimed bool
	// Unique ID for this set of boosts.
	ID string
	// ID of the user that applied the boost.
	//
	// Use SetUserID and GetUserID helpers.
	UserID int64
	// The message ID of the giveaway¹
	//
	// Links:
	//  1) https://core.telegram.org/api/giveaways
	//
	// Use SetGiveawayMsgID and GetGiveawayMsgID helpers.
	GiveawayMsgID int
	// When was the boost applied
	Date int
	// When does the boost expire
	Expires int
	// The created Telegram Premium gift code, only set if either gift or giveaway are set
	// AND it is either a gift code for the currently logged in user or if it was already
	// claimed.
	//
	// Use SetUsedGiftSlug and GetUsedGiftSlug helpers.
	UsedGiftSlug string
	// If set, this boost counts as multiplier boosts, otherwise it counts as a single boost.
	//
	// Use SetMultiplier and GetMultiplier helpers.
	Multiplier int
}

// BoostTypeID is TL type id of Boost.
const BoostTypeID = 0x2a1c8c71

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

func ( *Boost) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Gift == false) {
		return false
	}
	if !(.Giveaway == false) {
		return false
	}
	if !(.Unclaimed == false) {
		return false
	}
	if !(.ID == "") {
		return false
	}
	if !(.UserID == 0) {
		return false
	}
	if !(.GiveawayMsgID == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.Expires == 0) {
		return false
	}
	if !(.UsedGiftSlug == "") {
		return false
	}
	if !(.Multiplier == 0) {
		return false
	}

	return true
}

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

// FillFrom fills Boost from given interface.
func ( *Boost) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( string)
	() ( int64,  bool)
	() ( int,  bool)
	() ( int)
	() ( int)
	() ( string,  bool)
	() ( int,  bool)
}) {
	.Gift = .()
	.Giveaway = .()
	.Unclaimed = .()
	.ID = .()
	if ,  := .();  {
		.UserID = 
	}

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

	.Date = .()
	.Expires = .()
	if ,  := .();  {
		.UsedGiftSlug = 
	}

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

}

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

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

// TypeInfo returns info about TL type.
func ( *Boost) () tdp.Type {
	 := tdp.Type{
		Name: "boost",
		ID:   BoostTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Gift",
			SchemaName: "gift",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Giveaway",
			SchemaName: "giveaway",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Unclaimed",
			SchemaName: "unclaimed",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "UserID",
			SchemaName: "user_id",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "GiveawayMsgID",
			SchemaName: "giveaway_msg_id",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "Expires",
			SchemaName: "expires",
		},
		{
			Name:       "UsedGiftSlug",
			SchemaName: "used_gift_slug",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "Multiplier",
			SchemaName: "multiplier",
			Null:       !.Flags.Has(5),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *Boost) () {
	if !(.Gift == false) {
		.Flags.Set(1)
	}
	if !(.Giveaway == false) {
		.Flags.Set(2)
	}
	if !(.Unclaimed == false) {
		.Flags.Set(3)
	}
	if !(.UserID == 0) {
		.Flags.Set(0)
	}
	if !(.GiveawayMsgID == 0) {
		.Flags.Set(2)
	}
	if !(.UsedGiftSlug == "") {
		.Flags.Set(4)
	}
	if !(.Multiplier == 0) {
		.Flags.Set(5)
	}
}

// Encode implements bin.Encoder.
func ( *Boost) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode boost#2a1c8c71 as nil")
	}
	.PutID(BoostTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *Boost) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode boost#2a1c8c71 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode boost#2a1c8c71: field flags: %w", )
	}
	.PutString(.ID)
	if .Flags.Has(0) {
		.PutLong(.UserID)
	}
	if .Flags.Has(2) {
		.PutInt(.GiveawayMsgID)
	}
	.PutInt(.Date)
	.PutInt(.Expires)
	if .Flags.Has(4) {
		.PutString(.UsedGiftSlug)
	}
	if .Flags.Has(5) {
		.PutInt(.Multiplier)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *Boost) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode boost#2a1c8c71 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode boost#2a1c8c71: field flags: %w", )
		}
	}
	.Gift = .Flags.Has(1)
	.Giveaway = .Flags.Has(2)
	.Unclaimed = .Flags.Has(3)
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode boost#2a1c8c71: field id: %w", )
		}
		.ID = 
	}
	if .Flags.Has(0) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode boost#2a1c8c71: field user_id: %w", )
		}
		.UserID = 
	}
	if .Flags.Has(2) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode boost#2a1c8c71: field giveaway_msg_id: %w", )
		}
		.GiveawayMsgID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode boost#2a1c8c71: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode boost#2a1c8c71: field expires: %w", )
		}
		.Expires = 
	}
	if .Flags.Has(4) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode boost#2a1c8c71: field used_gift_slug: %w", )
		}
		.UsedGiftSlug = 
	}
	if .Flags.Has(5) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode boost#2a1c8c71: field multiplier: %w", )
		}
		.Multiplier = 
	}
	return nil
}

// SetGift sets value of Gift conditional field.
func ( *Boost) ( bool) {
	if  {
		.Flags.Set(1)
		.Gift = true
	} else {
		.Flags.Unset(1)
		.Gift = false
	}
}

// GetGift returns value of Gift conditional field.
func ( *Boost) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetGiveaway sets value of Giveaway conditional field.
func ( *Boost) ( bool) {
	if  {
		.Flags.Set(2)
		.Giveaway = true
	} else {
		.Flags.Unset(2)
		.Giveaway = false
	}
}

// GetGiveaway returns value of Giveaway conditional field.
func ( *Boost) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetUnclaimed sets value of Unclaimed conditional field.
func ( *Boost) ( bool) {
	if  {
		.Flags.Set(3)
		.Unclaimed = true
	} else {
		.Flags.Unset(3)
		.Unclaimed = false
	}
}

// GetUnclaimed returns value of Unclaimed conditional field.
func ( *Boost) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

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

// SetUserID sets value of UserID conditional field.
func ( *Boost) ( int64) {
	.Flags.Set(0)
	.UserID = 
}

// GetUserID returns value of UserID conditional field and
// boolean which is true if field was set.
func ( *Boost) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .UserID, true
}

// SetGiveawayMsgID sets value of GiveawayMsgID conditional field.
func ( *Boost) ( int) {
	.Flags.Set(2)
	.GiveawayMsgID = 
}

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

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

// GetExpires returns value of Expires field.
func ( *Boost) () ( int) {
	if  == nil {
		return
	}
	return .Expires
}

// SetUsedGiftSlug sets value of UsedGiftSlug conditional field.
func ( *Boost) ( string) {
	.Flags.Set(4)
	.UsedGiftSlug = 
}

// GetUsedGiftSlug returns value of UsedGiftSlug conditional field and
// boolean which is true if field was set.
func ( *Boost) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .UsedGiftSlug, true
}

// SetMultiplier sets value of Multiplier conditional field.
func ( *Boost) ( int) {
	.Flags.Set(5)
	.Multiplier = 
}

// GetMultiplier returns value of Multiplier conditional field and
// boolean which is true if field was set.
func ( *Boost) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(5) {
		return , false
	}
	return .Multiplier, true
}