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

// PaymentsGetStarGiftAuctionStateRequest represents TL type `payments.getStarGiftAuctionState#5c9ff4d6`.
// Returns info about a collectible gift auction »¹; also subscribes the user to
// auction updates, see here »² for more info on the full flow.
//
// Links:
//  1. https://core.telegram.org/api/auctions
//  2. https://core.telegram.org/api/auctions
//
// See https://core.telegram.org/method/payments.getStarGiftAuctionState for reference.
type PaymentsGetStarGiftAuctionStateRequest struct {
	// Either the ID of the gift linked to the auction, or an auction deep link slug »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/links#auction-links
	Auction InputStarGiftAuctionClass
	// Initially 0, then set to the returned starGiftAuctionState¹.version, to avoid
	// refetching results if they haven't changed.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/starGiftAuctionState
	Version int
}

// PaymentsGetStarGiftAuctionStateRequestTypeID is TL type id of PaymentsGetStarGiftAuctionStateRequest.
const PaymentsGetStarGiftAuctionStateRequestTypeID = 0x5c9ff4d6

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

func ( *PaymentsGetStarGiftAuctionStateRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Auction == nil) {
		return false
	}
	if !(.Version == 0) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsGetStarGiftAuctionStateRequest from given interface.
func ( *PaymentsGetStarGiftAuctionStateRequest) ( interface {
	() ( InputStarGiftAuctionClass)
	() ( int)
}) {
	.Auction = .()
	.Version = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsGetStarGiftAuctionStateRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.getStarGiftAuctionState",
		ID:   PaymentsGetStarGiftAuctionStateRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Auction",
			SchemaName: "auction",
		},
		{
			Name:       "Version",
			SchemaName: "version",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PaymentsGetStarGiftAuctionStateRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getStarGiftAuctionState#5c9ff4d6 as nil")
	}
	.PutID(PaymentsGetStarGiftAuctionStateRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsGetStarGiftAuctionStateRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getStarGiftAuctionState#5c9ff4d6 as nil")
	}
	if .Auction == nil {
		return fmt.Errorf("unable to encode payments.getStarGiftAuctionState#5c9ff4d6: field auction is nil")
	}
	if  := .Auction.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.getStarGiftAuctionState#5c9ff4d6: field auction: %w", )
	}
	.PutInt(.Version)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsGetStarGiftAuctionStateRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.getStarGiftAuctionState#5c9ff4d6 to nil")
	}
	{
		,  := DecodeInputStarGiftAuction()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getStarGiftAuctionState#5c9ff4d6: field auction: %w", )
		}
		.Auction = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getStarGiftAuctionState#5c9ff4d6: field version: %w", )
		}
		.Version = 
	}
	return nil
}

// GetAuction returns value of Auction field.
func ( *PaymentsGetStarGiftAuctionStateRequest) () ( InputStarGiftAuctionClass) {
	if  == nil {
		return
	}
	return .Auction
}

// GetVersion returns value of Version field.
func ( *PaymentsGetStarGiftAuctionStateRequest) () ( int) {
	if  == nil {
		return
	}
	return .Version
}

// PaymentsGetStarGiftAuctionState invokes method payments.getStarGiftAuctionState#5c9ff4d6 returning error if any.
// Returns info about a collectible gift auction »¹; also subscribes the user to
// auction updates, see here »² for more info on the full flow.
//
// Links:
//  1. https://core.telegram.org/api/auctions
//  2. https://core.telegram.org/api/auctions
//
// Possible errors:
//
//	400 STARGIFT_INVALID: The passed gift is invalid.
//
// See https://core.telegram.org/method/payments.getStarGiftAuctionState for reference.
func ( *Client) ( context.Context,  *PaymentsGetStarGiftAuctionStateRequest) (*PaymentsStarGiftAuctionState, error) {
	var  PaymentsStarGiftAuctionState

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