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

// PaymentsGetStarGiftCollectionsRequest represents TL type `payments.getStarGiftCollections#981b91dd`.
// Fetches all star gift collections »¹ of a peer.
//
// Links:
//  1. https://core.telegram.org/api/gifts#gift-collections
//
// See https://core.telegram.org/method/payments.getStarGiftCollections for reference.
type PaymentsGetStarGiftCollectionsRequest struct {
	// The peer.
	Peer InputPeerClass
	// Hash (generated as specified here »¹) using the starGiftCollection².hash field (not
	// the collection_id field) of all collections returned by a previous method call, to
	// avoid refetching the result if it hasn't changed.
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets#hash-generation
	//  2) https://core.telegram.org/constructor/starGiftCollection
	Hash int64
}

// PaymentsGetStarGiftCollectionsRequestTypeID is TL type id of PaymentsGetStarGiftCollectionsRequest.
const PaymentsGetStarGiftCollectionsRequestTypeID = 0x981b91dd

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

func ( *PaymentsGetStarGiftCollectionsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Hash == 0) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsGetStarGiftCollectionsRequest from given interface.
func ( *PaymentsGetStarGiftCollectionsRequest) ( interface {
	() ( InputPeerClass)
	() ( int64)
}) {
	.Peer = .()
	.Hash = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsGetStarGiftCollectionsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.getStarGiftCollections",
		ID:   PaymentsGetStarGiftCollectionsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PaymentsGetStarGiftCollectionsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getStarGiftCollections#981b91dd as nil")
	}
	.PutID(PaymentsGetStarGiftCollectionsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsGetStarGiftCollectionsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getStarGiftCollections#981b91dd as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode payments.getStarGiftCollections#981b91dd: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.getStarGiftCollections#981b91dd: field peer: %w", )
	}
	.PutLong(.Hash)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsGetStarGiftCollectionsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.getStarGiftCollections#981b91dd to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getStarGiftCollections#981b91dd: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getStarGiftCollections#981b91dd: field hash: %w", )
		}
		.Hash = 
	}
	return nil
}

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

// GetHash returns value of Hash field.
func ( *PaymentsGetStarGiftCollectionsRequest) () ( int64) {
	if  == nil {
		return
	}
	return .Hash
}

// PaymentsGetStarGiftCollections invokes method payments.getStarGiftCollections#981b91dd returning error if any.
// Fetches all star gift collections »¹ of a peer.
//
// Links:
//  1. https://core.telegram.org/api/gifts#gift-collections
//
// Possible errors:
//
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/payments.getStarGiftCollections for reference.
func ( *Client) ( context.Context,  *PaymentsGetStarGiftCollectionsRequest) (PaymentsStarGiftCollectionsClass, error) {
	var  PaymentsStarGiftCollectionsBox

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