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

// PaymentsGetStarsSubscriptionsRequest represents TL type `payments.getStarsSubscriptions#32512c5`.
// Obtain a list of active, expired or cancelled Telegram Star subscriptions »¹.
//
// Links:
//  1. https://core.telegram.org/api/invites#paid-invite-links
//
// See https://core.telegram.org/method/payments.getStarsSubscriptions for reference.
type PaymentsGetStarsSubscriptionsRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to return only subscriptions expired due to an excessively low Telegram Star
	// balance.
	MissingBalance bool
	// Always pass inputPeerSelf¹.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/inputPeerSelf
	Peer InputPeerClass
	// Offset for pagination, taken from payments.starsStatus¹.subscriptions_next_offset.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/payments.starsStatus
	Offset string
}

// PaymentsGetStarsSubscriptionsRequestTypeID is TL type id of PaymentsGetStarsSubscriptionsRequest.
const PaymentsGetStarsSubscriptionsRequestTypeID = 0x32512c5

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

func ( *PaymentsGetStarsSubscriptionsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.MissingBalance == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Offset == "") {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsGetStarsSubscriptionsRequest from given interface.
func ( *PaymentsGetStarsSubscriptionsRequest) ( interface {
	() ( bool)
	() ( InputPeerClass)
	() ( string)
}) {
	.MissingBalance = .()
	.Peer = .()
	.Offset = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsGetStarsSubscriptionsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.getStarsSubscriptions",
		ID:   PaymentsGetStarsSubscriptionsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "MissingBalance",
			SchemaName: "missing_balance",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PaymentsGetStarsSubscriptionsRequest) () {
	if !(.MissingBalance == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *PaymentsGetStarsSubscriptionsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getStarsSubscriptions#32512c5 as nil")
	}
	.PutID(PaymentsGetStarsSubscriptionsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsGetStarsSubscriptionsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getStarsSubscriptions#32512c5 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.getStarsSubscriptions#32512c5: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode payments.getStarsSubscriptions#32512c5: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.getStarsSubscriptions#32512c5: field peer: %w", )
	}
	.PutString(.Offset)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsGetStarsSubscriptionsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.getStarsSubscriptions#32512c5 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.getStarsSubscriptions#32512c5: field flags: %w", )
		}
	}
	.MissingBalance = .Flags.Has(0)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getStarsSubscriptions#32512c5: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getStarsSubscriptions#32512c5: field offset: %w", )
		}
		.Offset = 
	}
	return nil
}

// SetMissingBalance sets value of MissingBalance conditional field.
func ( *PaymentsGetStarsSubscriptionsRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.MissingBalance = true
	} else {
		.Flags.Unset(0)
		.MissingBalance = false
	}
}

// GetMissingBalance returns value of MissingBalance conditional field.
func ( *PaymentsGetStarsSubscriptionsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

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

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

// PaymentsGetStarsSubscriptions invokes method payments.getStarsSubscriptions#32512c5 returning error if any.
// Obtain a list of active, expired or cancelled Telegram Star subscriptions »¹.
//
// Links:
//  1. https://core.telegram.org/api/invites#paid-invite-links
//
// Possible errors:
//
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/payments.getStarsSubscriptions for reference.
func ( *Client) ( context.Context,  *PaymentsGetStarsSubscriptionsRequest) (*PaymentsStarsStatus, error) {
	var  PaymentsStarsStatus

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