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

// PaymentsGetSavedStarGiftsRequest represents TL type `payments.getSavedStarGifts#a319e569`.
// Fetch the full list of gifts¹ owned by a peer.
// Note that unlike what the name suggests, the method can be used to fetch both "saved"
// and "unsaved" gifts (aka gifts both pinned and not pinned) to the profile, depending
// on the passed flags.
//
// Links:
//  1. https://core.telegram.org/api/gifts
//
// See https://core.telegram.org/method/payments.getSavedStarGifts for reference.
type PaymentsGetSavedStarGiftsRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Exclude gifts not pinned on the profile.
	ExcludeUnsaved bool
	// Exclude gifts pinned on the profile.
	ExcludeSaved bool
	// Exclude gifts that do not have the starGift¹.limited flag set.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/starGift
	ExcludeUnlimited bool
	// Exclude collectible gifts »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#collectible-gifts
	ExcludeUnique bool
	// If set, sorts the gifts by price instead of reception date.
	SortByValue bool
	// Exclude gifts that can be upgraded to collectible gifts »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#collectible-gifts
	ExcludeUpgradable bool
	// Exclude gifts that cannot be upgraded to collectible gifts »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#collectible-gifts
	ExcludeUnupgradable bool
	// PeerColorAvailable field of PaymentsGetSavedStarGiftsRequest.
	PeerColorAvailable bool
	// ExcludeHosted field of PaymentsGetSavedStarGiftsRequest.
	ExcludeHosted bool
	// Fetch only gifts owned by the specified peer, such as: a user, with
	// peer=inputPeerUser¹; a channel, with peer=inputPeerChannel²; a connected business
	// user³ (when executing the method as a bot, over the business connection), with
	// peer=inputPeerUser⁴.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/inputPeerUser
	//  2) https://core.telegram.org/constructor/inputPeerChannel
	//  3) https://core.telegram.org/api/bots/connected-business-bots
	//  4) https://core.telegram.org/constructor/inputPeerUser
	Peer InputPeerClass
	// Only returns gifts within the specified collection »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#gift-collections
	//
	// Use SetCollectionID and GetCollectionID helpers.
	CollectionID int
	// Offset for pagination¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	Offset string
	// Maximum number of results to return, see pagination¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	Limit int
}

// PaymentsGetSavedStarGiftsRequestTypeID is TL type id of PaymentsGetSavedStarGiftsRequest.
const PaymentsGetSavedStarGiftsRequestTypeID = 0xa319e569

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

func ( *PaymentsGetSavedStarGiftsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ExcludeUnsaved == false) {
		return false
	}
	if !(.ExcludeSaved == false) {
		return false
	}
	if !(.ExcludeUnlimited == false) {
		return false
	}
	if !(.ExcludeUnique == false) {
		return false
	}
	if !(.SortByValue == false) {
		return false
	}
	if !(.ExcludeUpgradable == false) {
		return false
	}
	if !(.ExcludeUnupgradable == false) {
		return false
	}
	if !(.PeerColorAvailable == false) {
		return false
	}
	if !(.ExcludeHosted == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.CollectionID == 0) {
		return false
	}
	if !(.Offset == "") {
		return false
	}
	if !(.Limit == 0) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsGetSavedStarGiftsRequest from given interface.
func ( *PaymentsGetSavedStarGiftsRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( InputPeerClass)
	() ( int,  bool)
	() ( string)
	() ( int)
}) {
	.ExcludeUnsaved = .()
	.ExcludeSaved = .()
	.ExcludeUnlimited = .()
	.ExcludeUnique = .()
	.SortByValue = .()
	.ExcludeUpgradable = .()
	.ExcludeUnupgradable = .()
	.PeerColorAvailable = .()
	.ExcludeHosted = .()
	.Peer = .()
	if ,  := .();  {
		.CollectionID = 
	}

	.Offset = .()
	.Limit = .()
}

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

// TypeName returns name of type in TL schema.
func (*PaymentsGetSavedStarGiftsRequest) () string {
	return "payments.getSavedStarGifts"
}

// TypeInfo returns info about TL type.
func ( *PaymentsGetSavedStarGiftsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.getSavedStarGifts",
		ID:   PaymentsGetSavedStarGiftsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ExcludeUnsaved",
			SchemaName: "exclude_unsaved",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "ExcludeSaved",
			SchemaName: "exclude_saved",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "ExcludeUnlimited",
			SchemaName: "exclude_unlimited",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "ExcludeUnique",
			SchemaName: "exclude_unique",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "SortByValue",
			SchemaName: "sort_by_value",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "ExcludeUpgradable",
			SchemaName: "exclude_upgradable",
			Null:       !.Flags.Has(7),
		},
		{
			Name:       "ExcludeUnupgradable",
			SchemaName: "exclude_unupgradable",
			Null:       !.Flags.Has(8),
		},
		{
			Name:       "PeerColorAvailable",
			SchemaName: "peer_color_available",
			Null:       !.Flags.Has(9),
		},
		{
			Name:       "ExcludeHosted",
			SchemaName: "exclude_hosted",
			Null:       !.Flags.Has(10),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "CollectionID",
			SchemaName: "collection_id",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Limit",
			SchemaName: "limit",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PaymentsGetSavedStarGiftsRequest) () {
	if !(.ExcludeUnsaved == false) {
		.Flags.Set(0)
	}
	if !(.ExcludeSaved == false) {
		.Flags.Set(1)
	}
	if !(.ExcludeUnlimited == false) {
		.Flags.Set(2)
	}
	if !(.ExcludeUnique == false) {
		.Flags.Set(4)
	}
	if !(.SortByValue == false) {
		.Flags.Set(5)
	}
	if !(.ExcludeUpgradable == false) {
		.Flags.Set(7)
	}
	if !(.ExcludeUnupgradable == false) {
		.Flags.Set(8)
	}
	if !(.PeerColorAvailable == false) {
		.Flags.Set(9)
	}
	if !(.ExcludeHosted == false) {
		.Flags.Set(10)
	}
	if !(.CollectionID == 0) {
		.Flags.Set(6)
	}
}

// Encode implements bin.Encoder.
func ( *PaymentsGetSavedStarGiftsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getSavedStarGifts#a319e569 as nil")
	}
	.PutID(PaymentsGetSavedStarGiftsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsGetSavedStarGiftsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getSavedStarGifts#a319e569 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.getSavedStarGifts#a319e569: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode payments.getSavedStarGifts#a319e569: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.getSavedStarGifts#a319e569: field peer: %w", )
	}
	if .Flags.Has(6) {
		.PutInt(.CollectionID)
	}
	.PutString(.Offset)
	.PutInt(.Limit)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsGetSavedStarGiftsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.getSavedStarGifts#a319e569 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.getSavedStarGifts#a319e569: field flags: %w", )
		}
	}
	.ExcludeUnsaved = .Flags.Has(0)
	.ExcludeSaved = .Flags.Has(1)
	.ExcludeUnlimited = .Flags.Has(2)
	.ExcludeUnique = .Flags.Has(4)
	.SortByValue = .Flags.Has(5)
	.ExcludeUpgradable = .Flags.Has(7)
	.ExcludeUnupgradable = .Flags.Has(8)
	.PeerColorAvailable = .Flags.Has(9)
	.ExcludeHosted = .Flags.Has(10)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getSavedStarGifts#a319e569: field peer: %w", )
		}
		.Peer = 
	}
	if .Flags.Has(6) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getSavedStarGifts#a319e569: field collection_id: %w", )
		}
		.CollectionID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getSavedStarGifts#a319e569: field offset: %w", )
		}
		.Offset = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getSavedStarGifts#a319e569: field limit: %w", )
		}
		.Limit = 
	}
	return nil
}

// SetExcludeUnsaved sets value of ExcludeUnsaved conditional field.
func ( *PaymentsGetSavedStarGiftsRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.ExcludeUnsaved = true
	} else {
		.Flags.Unset(0)
		.ExcludeUnsaved = false
	}
}

// GetExcludeUnsaved returns value of ExcludeUnsaved conditional field.
func ( *PaymentsGetSavedStarGiftsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetExcludeSaved sets value of ExcludeSaved conditional field.
func ( *PaymentsGetSavedStarGiftsRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.ExcludeSaved = true
	} else {
		.Flags.Unset(1)
		.ExcludeSaved = false
	}
}

// GetExcludeSaved returns value of ExcludeSaved conditional field.
func ( *PaymentsGetSavedStarGiftsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetExcludeUnlimited sets value of ExcludeUnlimited conditional field.
func ( *PaymentsGetSavedStarGiftsRequest) ( bool) {
	if  {
		.Flags.Set(2)
		.ExcludeUnlimited = true
	} else {
		.Flags.Unset(2)
		.ExcludeUnlimited = false
	}
}

// GetExcludeUnlimited returns value of ExcludeUnlimited conditional field.
func ( *PaymentsGetSavedStarGiftsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetExcludeUnique sets value of ExcludeUnique conditional field.
func ( *PaymentsGetSavedStarGiftsRequest) ( bool) {
	if  {
		.Flags.Set(4)
		.ExcludeUnique = true
	} else {
		.Flags.Unset(4)
		.ExcludeUnique = false
	}
}

// GetExcludeUnique returns value of ExcludeUnique conditional field.
func ( *PaymentsGetSavedStarGiftsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}

// SetSortByValue sets value of SortByValue conditional field.
func ( *PaymentsGetSavedStarGiftsRequest) ( bool) {
	if  {
		.Flags.Set(5)
		.SortByValue = true
	} else {
		.Flags.Unset(5)
		.SortByValue = false
	}
}

// GetSortByValue returns value of SortByValue conditional field.
func ( *PaymentsGetSavedStarGiftsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(5)
}

// SetExcludeUpgradable sets value of ExcludeUpgradable conditional field.
func ( *PaymentsGetSavedStarGiftsRequest) ( bool) {
	if  {
		.Flags.Set(7)
		.ExcludeUpgradable = true
	} else {
		.Flags.Unset(7)
		.ExcludeUpgradable = false
	}
}

// GetExcludeUpgradable returns value of ExcludeUpgradable conditional field.
func ( *PaymentsGetSavedStarGiftsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(7)
}

// SetExcludeUnupgradable sets value of ExcludeUnupgradable conditional field.
func ( *PaymentsGetSavedStarGiftsRequest) ( bool) {
	if  {
		.Flags.Set(8)
		.ExcludeUnupgradable = true
	} else {
		.Flags.Unset(8)
		.ExcludeUnupgradable = false
	}
}

// GetExcludeUnupgradable returns value of ExcludeUnupgradable conditional field.
func ( *PaymentsGetSavedStarGiftsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(8)
}

// SetPeerColorAvailable sets value of PeerColorAvailable conditional field.
func ( *PaymentsGetSavedStarGiftsRequest) ( bool) {
	if  {
		.Flags.Set(9)
		.PeerColorAvailable = true
	} else {
		.Flags.Unset(9)
		.PeerColorAvailable = false
	}
}

// GetPeerColorAvailable returns value of PeerColorAvailable conditional field.
func ( *PaymentsGetSavedStarGiftsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(9)
}

// SetExcludeHosted sets value of ExcludeHosted conditional field.
func ( *PaymentsGetSavedStarGiftsRequest) ( bool) {
	if  {
		.Flags.Set(10)
		.ExcludeHosted = true
	} else {
		.Flags.Unset(10)
		.ExcludeHosted = false
	}
}

// GetExcludeHosted returns value of ExcludeHosted conditional field.
func ( *PaymentsGetSavedStarGiftsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(10)
}

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

// SetCollectionID sets value of CollectionID conditional field.
func ( *PaymentsGetSavedStarGiftsRequest) ( int) {
	.Flags.Set(6)
	.CollectionID = 
}

// GetCollectionID returns value of CollectionID conditional field and
// boolean which is true if field was set.
func ( *PaymentsGetSavedStarGiftsRequest) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(6) {
		return , false
	}
	return .CollectionID, true
}

// GetOffset returns value of Offset field.
func ( *PaymentsGetSavedStarGiftsRequest) () ( string) {
	if  == nil {
		return
	}
	return .Offset
}

// GetLimit returns value of Limit field.
func ( *PaymentsGetSavedStarGiftsRequest) () ( int) {
	if  == nil {
		return
	}
	return .Limit
}

// PaymentsGetSavedStarGifts invokes method payments.getSavedStarGifts#a319e569 returning error if any.
// Fetch the full list of gifts¹ owned by a peer.
// Note that unlike what the name suggests, the method can be used to fetch both "saved"
// and "unsaved" gifts (aka gifts both pinned and not pinned) to the profile, depending
// on the passed flags.
//
// Links:
//  1. https://core.telegram.org/api/gifts
//
// Possible errors:
//
//	400 BUSINESS_CONNECTION_INVALID: The connection_id passed to the wrapping invokeWithBusinessConnection call is invalid.
//	400 COLLECTION_ID_INVALID:
//	400 MSG_ID_INVALID: Invalid message ID provided.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/payments.getSavedStarGifts for reference.
func ( *Client) ( context.Context,  *PaymentsGetSavedStarGiftsRequest) (*PaymentsSavedStarGifts, error) {
	var  PaymentsSavedStarGifts

	if  := .rpc.Invoke(, , &);  != nil {
		return nil, 
	}
	return &, nil
}