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

// PaymentsGetSuggestedStarRefBotsRequest represents TL type `payments.getSuggestedStarRefBots#d6b48f7`.
// Obtain a list of suggested mini apps¹ with available affiliate programs²
// order_by_revenue and order_by_date are mutually exclusive: if neither is set, results
// are sorted by profitability.
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps
//  2. https://core.telegram.org/api/bots/referrals
//
// See https://core.telegram.org/method/payments.getSuggestedStarRefBots for reference.
type PaymentsGetSuggestedStarRefBotsRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, orders results by the expected revenue
	OrderByRevenue bool
	// If set, orders results by the creation date of the affiliate program
	OrderByDate bool
	// The peer that will become the affiliate: star commissions will be transferred to this
	// peer's star balance.
	Peer InputPeerClass
	// Offset for pagination, taken from payments.suggestedStarRefBots¹.next_offset,
	// initially empty.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/payments.suggestedStarRefBots
	Offset string
	// Maximum number of results to return, see pagination¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	Limit int
}

// PaymentsGetSuggestedStarRefBotsRequestTypeID is TL type id of PaymentsGetSuggestedStarRefBotsRequest.
const PaymentsGetSuggestedStarRefBotsRequestTypeID = 0xd6b48f7

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

func ( *PaymentsGetSuggestedStarRefBotsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.OrderByRevenue == false) {
		return false
	}
	if !(.OrderByDate == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Offset == "") {
		return false
	}
	if !(.Limit == 0) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsGetSuggestedStarRefBotsRequest from given interface.
func ( *PaymentsGetSuggestedStarRefBotsRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( InputPeerClass)
	() ( string)
	() ( int)
}) {
	.OrderByRevenue = .()
	.OrderByDate = .()
	.Peer = .()
	.Offset = .()
	.Limit = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsGetSuggestedStarRefBotsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.getSuggestedStarRefBots",
		ID:   PaymentsGetSuggestedStarRefBotsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "OrderByRevenue",
			SchemaName: "order_by_revenue",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "OrderByDate",
			SchemaName: "order_by_date",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
		{
			Name:       "Limit",
			SchemaName: "limit",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PaymentsGetSuggestedStarRefBotsRequest) () {
	if !(.OrderByRevenue == false) {
		.Flags.Set(0)
	}
	if !(.OrderByDate == false) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *PaymentsGetSuggestedStarRefBotsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getSuggestedStarRefBots#d6b48f7 as nil")
	}
	.PutID(PaymentsGetSuggestedStarRefBotsRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsGetSuggestedStarRefBotsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.getSuggestedStarRefBots#d6b48f7 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.getSuggestedStarRefBots#d6b48f7: field flags: %w", )
		}
	}
	.OrderByRevenue = .Flags.Has(0)
	.OrderByDate = .Flags.Has(1)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getSuggestedStarRefBots#d6b48f7: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getSuggestedStarRefBots#d6b48f7: field offset: %w", )
		}
		.Offset = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getSuggestedStarRefBots#d6b48f7: field limit: %w", )
		}
		.Limit = 
	}
	return nil
}

// SetOrderByRevenue sets value of OrderByRevenue conditional field.
func ( *PaymentsGetSuggestedStarRefBotsRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.OrderByRevenue = true
	} else {
		.Flags.Unset(0)
		.OrderByRevenue = false
	}
}

// GetOrderByRevenue returns value of OrderByRevenue conditional field.
func ( *PaymentsGetSuggestedStarRefBotsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetOrderByDate sets value of OrderByDate conditional field.
func ( *PaymentsGetSuggestedStarRefBotsRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.OrderByDate = true
	} else {
		.Flags.Unset(1)
		.OrderByDate = false
	}
}

// GetOrderByDate returns value of OrderByDate conditional field.
func ( *PaymentsGetSuggestedStarRefBotsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

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

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

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

// PaymentsGetSuggestedStarRefBots invokes method payments.getSuggestedStarRefBots#d6b48f7 returning error if any.
// Obtain a list of suggested mini apps¹ with available affiliate programs²
// order_by_revenue and order_by_date are mutually exclusive: if neither is set, results
// are sorted by profitability.
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps
//  2. https://core.telegram.org/api/bots/referrals
//
// Possible errors:
//
//	403 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/payments.getSuggestedStarRefBots for reference.
func ( *Client) ( context.Context,  *PaymentsGetSuggestedStarRefBotsRequest) (*PaymentsSuggestedStarRefBots, error) {
	var  PaymentsSuggestedStarRefBots

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