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

// PaymentsGetStarsTransactionsRequest represents TL type `payments.getStarsTransactions#69da4557`.
// Fetch Telegram Stars transactions¹.
// The inbound and outbound flags are mutually exclusive: if none of the two are set,
// both incoming and outgoing transactions are fetched.
//
// Links:
//  1. https://core.telegram.org/api/stars#balance-and-transaction-history
//
// See https://core.telegram.org/method/payments.getStarsTransactions for reference.
type PaymentsGetStarsTransactionsRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, fetches only incoming transactions.
	Inbound bool
	// If set, fetches only outgoing transactions.
	Outbound bool
	// Return transactions in ascending order by date (instead of descending order by date).
	Ascending bool
	// If set, returns the channel/ad revenue transactions in nanotons, instead.
	Ton bool
	// If set, fetches only transactions for the specified Telegram Star subscription »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/stars#star-subscriptions
	//
	// Use SetSubscriptionID and GetSubscriptionID helpers.
	SubscriptionID string
	// Fetch the transaction history of the peer (inputPeerSelf¹ or a bot we own).
	//
	// Links:
	//  1) https://core.telegram.org/constructor/inputPeerSelf
	Peer InputPeerClass
	// Offset for pagination, obtained from the returned next_offset, initially an empty
	// string »¹.
	//
	// 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
}

// PaymentsGetStarsTransactionsRequestTypeID is TL type id of PaymentsGetStarsTransactionsRequest.
const PaymentsGetStarsTransactionsRequestTypeID = 0x69da4557

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

func ( *PaymentsGetStarsTransactionsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Inbound == false) {
		return false
	}
	if !(.Outbound == false) {
		return false
	}
	if !(.Ascending == false) {
		return false
	}
	if !(.Ton == false) {
		return false
	}
	if !(.SubscriptionID == "") {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Offset == "") {
		return false
	}
	if !(.Limit == 0) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsGetStarsTransactionsRequest from given interface.
func ( *PaymentsGetStarsTransactionsRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( string,  bool)
	() ( InputPeerClass)
	() ( string)
	() ( int)
}) {
	.Inbound = .()
	.Outbound = .()
	.Ascending = .()
	.Ton = .()
	if ,  := .();  {
		.SubscriptionID = 
	}

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

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsGetStarsTransactionsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.getStarsTransactions",
		ID:   PaymentsGetStarsTransactionsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Inbound",
			SchemaName: "inbound",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Outbound",
			SchemaName: "outbound",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Ascending",
			SchemaName: "ascending",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Ton",
			SchemaName: "ton",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "SubscriptionID",
			SchemaName: "subscription_id",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Limit",
			SchemaName: "limit",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PaymentsGetStarsTransactionsRequest) () {
	if !(.Inbound == false) {
		.Flags.Set(0)
	}
	if !(.Outbound == false) {
		.Flags.Set(1)
	}
	if !(.Ascending == false) {
		.Flags.Set(2)
	}
	if !(.Ton == false) {
		.Flags.Set(4)
	}
	if !(.SubscriptionID == "") {
		.Flags.Set(3)
	}
}

// Encode implements bin.Encoder.
func ( *PaymentsGetStarsTransactionsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getStarsTransactions#69da4557 as nil")
	}
	.PutID(PaymentsGetStarsTransactionsRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsGetStarsTransactionsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.getStarsTransactions#69da4557 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.getStarsTransactions#69da4557: field flags: %w", )
		}
	}
	.Inbound = .Flags.Has(0)
	.Outbound = .Flags.Has(1)
	.Ascending = .Flags.Has(2)
	.Ton = .Flags.Has(4)
	if .Flags.Has(3) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getStarsTransactions#69da4557: field subscription_id: %w", )
		}
		.SubscriptionID = 
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getStarsTransactions#69da4557: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getStarsTransactions#69da4557: field offset: %w", )
		}
		.Offset = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getStarsTransactions#69da4557: field limit: %w", )
		}
		.Limit = 
	}
	return nil
}

// SetInbound sets value of Inbound conditional field.
func ( *PaymentsGetStarsTransactionsRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Inbound = true
	} else {
		.Flags.Unset(0)
		.Inbound = false
	}
}

// GetInbound returns value of Inbound conditional field.
func ( *PaymentsGetStarsTransactionsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetOutbound sets value of Outbound conditional field.
func ( *PaymentsGetStarsTransactionsRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.Outbound = true
	} else {
		.Flags.Unset(1)
		.Outbound = false
	}
}

// GetOutbound returns value of Outbound conditional field.
func ( *PaymentsGetStarsTransactionsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetAscending sets value of Ascending conditional field.
func ( *PaymentsGetStarsTransactionsRequest) ( bool) {
	if  {
		.Flags.Set(2)
		.Ascending = true
	} else {
		.Flags.Unset(2)
		.Ascending = false
	}
}

// GetAscending returns value of Ascending conditional field.
func ( *PaymentsGetStarsTransactionsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetTon sets value of Ton conditional field.
func ( *PaymentsGetStarsTransactionsRequest) ( bool) {
	if  {
		.Flags.Set(4)
		.Ton = true
	} else {
		.Flags.Unset(4)
		.Ton = false
	}
}

// GetTon returns value of Ton conditional field.
func ( *PaymentsGetStarsTransactionsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}

// SetSubscriptionID sets value of SubscriptionID conditional field.
func ( *PaymentsGetStarsTransactionsRequest) ( string) {
	.Flags.Set(3)
	.SubscriptionID = 
}

// GetSubscriptionID returns value of SubscriptionID conditional field and
// boolean which is true if field was set.
func ( *PaymentsGetStarsTransactionsRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .SubscriptionID, true
}

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

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

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

// PaymentsGetStarsTransactions invokes method payments.getStarsTransactions#69da4557 returning error if any.
// Fetch Telegram Stars transactions¹.
// The inbound and outbound flags are mutually exclusive: if none of the two are set,
// both incoming and outgoing transactions are fetched.
//
// Links:
//  1. https://core.telegram.org/api/stars#balance-and-transaction-history
//
// Possible errors:
//
//	400 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 SUBSCRIPTION_ID_INVALID: The specified subscription_id is invalid.
//
// See https://core.telegram.org/method/payments.getStarsTransactions for reference.
func ( *Client) ( context.Context,  *PaymentsGetStarsTransactionsRequest) (*PaymentsStarsStatus, error) {
	var  PaymentsStarsStatus

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