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

// PaymentsGetConnectedStarRefBotsRequest represents TL type `payments.getConnectedStarRefBots#5869a553`.
// Fetch all affiliations we have created for a certain peer
//
// See https://core.telegram.org/method/payments.getConnectedStarRefBots for reference.
type PaymentsGetConnectedStarRefBotsRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// The affiliated peer
	Peer InputPeerClass
	// If set, returns only results older than the specified unixtime
	//
	// Use SetOffsetDate and GetOffsetDate helpers.
	OffsetDate int
	// Offset for pagination¹, taken from the last returned connectedBotStarRef².url
	// (initially empty)
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	//  2) https://core.telegram.org/constructor/connectedBotStarRef
	//
	// Use SetOffsetLink and GetOffsetLink helpers.
	OffsetLink string
	// Maximum number of results to return, see pagination¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	Limit int
}

// PaymentsGetConnectedStarRefBotsRequestTypeID is TL type id of PaymentsGetConnectedStarRefBotsRequest.
const PaymentsGetConnectedStarRefBotsRequestTypeID = 0x5869a553

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

func ( *PaymentsGetConnectedStarRefBotsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.OffsetDate == 0) {
		return false
	}
	if !(.OffsetLink == "") {
		return false
	}
	if !(.Limit == 0) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsGetConnectedStarRefBotsRequest from given interface.
func ( *PaymentsGetConnectedStarRefBotsRequest) ( interface {
	() ( InputPeerClass)
	() ( int,  bool)
	() ( string,  bool)
	() ( int)
}) {
	.Peer = .()
	if ,  := .();  {
		.OffsetDate = 
	}

	if ,  := .();  {
		.OffsetLink = 
	}

	.Limit = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsGetConnectedStarRefBotsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.getConnectedStarRefBots",
		ID:   PaymentsGetConnectedStarRefBotsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "OffsetDate",
			SchemaName: "offset_date",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "OffsetLink",
			SchemaName: "offset_link",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Limit",
			SchemaName: "limit",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PaymentsGetConnectedStarRefBotsRequest) () {
	if !(.OffsetDate == 0) {
		.Flags.Set(2)
	}
	if !(.OffsetLink == "") {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *PaymentsGetConnectedStarRefBotsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getConnectedStarRefBots#5869a553 as nil")
	}
	.PutID(PaymentsGetConnectedStarRefBotsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsGetConnectedStarRefBotsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.getConnectedStarRefBots#5869a553 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.getConnectedStarRefBots#5869a553: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode payments.getConnectedStarRefBots#5869a553: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.getConnectedStarRefBots#5869a553: field peer: %w", )
	}
	if .Flags.Has(2) {
		.PutInt(.OffsetDate)
	}
	if .Flags.Has(2) {
		.PutString(.OffsetLink)
	}
	.PutInt(.Limit)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsGetConnectedStarRefBotsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.getConnectedStarRefBots#5869a553 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.getConnectedStarRefBots#5869a553: field flags: %w", )
		}
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getConnectedStarRefBots#5869a553: field peer: %w", )
		}
		.Peer = 
	}
	if .Flags.Has(2) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getConnectedStarRefBots#5869a553: field offset_date: %w", )
		}
		.OffsetDate = 
	}
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getConnectedStarRefBots#5869a553: field offset_link: %w", )
		}
		.OffsetLink = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode payments.getConnectedStarRefBots#5869a553: field limit: %w", )
		}
		.Limit = 
	}
	return nil
}

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

// SetOffsetDate sets value of OffsetDate conditional field.
func ( *PaymentsGetConnectedStarRefBotsRequest) ( int) {
	.Flags.Set(2)
	.OffsetDate = 
}

// GetOffsetDate returns value of OffsetDate conditional field and
// boolean which is true if field was set.
func ( *PaymentsGetConnectedStarRefBotsRequest) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .OffsetDate, true
}

// SetOffsetLink sets value of OffsetLink conditional field.
func ( *PaymentsGetConnectedStarRefBotsRequest) ( string) {
	.Flags.Set(2)
	.OffsetLink = 
}

// GetOffsetLink returns value of OffsetLink conditional field and
// boolean which is true if field was set.
func ( *PaymentsGetConnectedStarRefBotsRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .OffsetLink, true
}

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

// PaymentsGetConnectedStarRefBots invokes method payments.getConnectedStarRefBots#5869a553 returning error if any.
// Fetch all affiliations we have created for a certain peer
//
// See https://core.telegram.org/method/payments.getConnectedStarRefBots for reference.
func ( *Client) ( context.Context,  *PaymentsGetConnectedStarRefBotsRequest) (*PaymentsConnectedStarRefBots, error) {
	var  PaymentsConnectedStarRefBots

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