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

// PaymentsGetStarsGiftOptionsRequest represents TL type `payments.getStarsGiftOptions#d3c96bc8`.
// Obtain a list of Telegram Stars gift options »¹ as starsGiftOption² constructors.
//
// Links:
//  1. https://core.telegram.org/api/stars#buying-or-gifting-stars
//  2. https://core.telegram.org/constructor/starsGiftOption
//
// See https://core.telegram.org/method/payments.getStarsGiftOptions for reference.
type PaymentsGetStarsGiftOptionsRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Receiver of the gift (optional).
	//
	// Use SetUserID and GetUserID helpers.
	UserID InputUserClass
}

// PaymentsGetStarsGiftOptionsRequestTypeID is TL type id of PaymentsGetStarsGiftOptionsRequest.
const PaymentsGetStarsGiftOptionsRequestTypeID = 0xd3c96bc8

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

func ( *PaymentsGetStarsGiftOptionsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.UserID == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsGetStarsGiftOptionsRequest from given interface.
func ( *PaymentsGetStarsGiftOptionsRequest) ( interface {
	() ( InputUserClass,  bool)
}) {
	if ,  := .();  {
		.UserID = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsGetStarsGiftOptionsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.getStarsGiftOptions",
		ID:   PaymentsGetStarsGiftOptionsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "UserID",
			SchemaName: "user_id",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PaymentsGetStarsGiftOptionsRequest) () {
	if !(.UserID == nil) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *PaymentsGetStarsGiftOptionsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getStarsGiftOptions#d3c96bc8 as nil")
	}
	.PutID(PaymentsGetStarsGiftOptionsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsGetStarsGiftOptionsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getStarsGiftOptions#d3c96bc8 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.getStarsGiftOptions#d3c96bc8: field flags: %w", )
	}
	if .Flags.Has(0) {
		if .UserID == nil {
			return fmt.Errorf("unable to encode payments.getStarsGiftOptions#d3c96bc8: field user_id is nil")
		}
		if  := .UserID.Encode();  != nil {
			return fmt.Errorf("unable to encode payments.getStarsGiftOptions#d3c96bc8: field user_id: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsGetStarsGiftOptionsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.getStarsGiftOptions#d3c96bc8 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.getStarsGiftOptions#d3c96bc8: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getStarsGiftOptions#d3c96bc8: field user_id: %w", )
		}
		.UserID = 
	}
	return nil
}

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

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

// PaymentsGetStarsGiftOptions invokes method payments.getStarsGiftOptions#d3c96bc8 returning error if any.
// Obtain a list of Telegram Stars gift options »¹ as starsGiftOption² constructors.
//
// Links:
//  1. https://core.telegram.org/api/stars#buying-or-gifting-stars
//  2. https://core.telegram.org/constructor/starsGiftOption
//
// Possible errors:
//
//	400 INPUT_USER_DEACTIVATED: The specified user was deleted.
//	400 USER_GIFT_UNAVAILABLE: Gifts are not available in the current region (stars_gifts_enabled is equal to false).
//	400 USER_ID_INVALID: The provided user ID is invalid.
//
// See https://core.telegram.org/method/payments.getStarsGiftOptions for reference.
func ( *Client) ( context.Context,  *PaymentsGetStarsGiftOptionsRequest) ([]StarsGiftOption, error) {
	var  StarsGiftOptionVector

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