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

// AccountGetAuthorizationFormRequest represents TL type `account.getAuthorizationForm#a929597a`.
// Returns a Telegram Passport authorization form for sharing data with a service
//
// See https://core.telegram.org/method/account.getAuthorizationForm for reference.
type AccountGetAuthorizationFormRequest struct {
	// User identifier of the service's bot
	BotID int64
	// Telegram Passport element types requested by the service
	Scope string
	// Service's public key
	PublicKey string
}

// AccountGetAuthorizationFormRequestTypeID is TL type id of AccountGetAuthorizationFormRequest.
const AccountGetAuthorizationFormRequestTypeID = 0xa929597a

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

func ( *AccountGetAuthorizationFormRequest) () bool {
	if  == nil {
		return true
	}
	if !(.BotID == 0) {
		return false
	}
	if !(.Scope == "") {
		return false
	}
	if !(.PublicKey == "") {
		return false
	}

	return true
}

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

// FillFrom fills AccountGetAuthorizationFormRequest from given interface.
func ( *AccountGetAuthorizationFormRequest) ( interface {
	() ( int64)
	() ( string)
	() ( string)
}) {
	.BotID = .()
	.Scope = .()
	.PublicKey = .()
}

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

// TypeName returns name of type in TL schema.
func (*AccountGetAuthorizationFormRequest) () string {
	return "account.getAuthorizationForm"
}

// TypeInfo returns info about TL type.
func ( *AccountGetAuthorizationFormRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.getAuthorizationForm",
		ID:   AccountGetAuthorizationFormRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "BotID",
			SchemaName: "bot_id",
		},
		{
			Name:       "Scope",
			SchemaName: "scope",
		},
		{
			Name:       "PublicKey",
			SchemaName: "public_key",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountGetAuthorizationFormRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.getAuthorizationForm#a929597a as nil")
	}
	.PutID(AccountGetAuthorizationFormRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountGetAuthorizationFormRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.getAuthorizationForm#a929597a as nil")
	}
	.PutLong(.BotID)
	.PutString(.Scope)
	.PutString(.PublicKey)
	return nil
}

// Decode implements bin.Decoder.
func ( *AccountGetAuthorizationFormRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.getAuthorizationForm#a929597a to nil")
	}
	if  := .ConsumeID(AccountGetAuthorizationFormRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode account.getAuthorizationForm#a929597a: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AccountGetAuthorizationFormRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.getAuthorizationForm#a929597a to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode account.getAuthorizationForm#a929597a: field bot_id: %w", )
		}
		.BotID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.getAuthorizationForm#a929597a: field scope: %w", )
		}
		.Scope = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.getAuthorizationForm#a929597a: field public_key: %w", )
		}
		.PublicKey = 
	}
	return nil
}

// GetBotID returns value of BotID field.
func ( *AccountGetAuthorizationFormRequest) () ( int64) {
	if  == nil {
		return
	}
	return .BotID
}

// GetScope returns value of Scope field.
func ( *AccountGetAuthorizationFormRequest) () ( string) {
	if  == nil {
		return
	}
	return .Scope
}

// GetPublicKey returns value of PublicKey field.
func ( *AccountGetAuthorizationFormRequest) () ( string) {
	if  == nil {
		return
	}
	return .PublicKey
}

// AccountGetAuthorizationForm invokes method account.getAuthorizationForm#a929597a returning error if any.
// Returns a Telegram Passport authorization form for sharing data with a service
//
// Possible errors:
//
//	400 PUBLIC_KEY_REQUIRED: A public key is required.
//
// See https://core.telegram.org/method/account.getAuthorizationForm for reference.
func ( *Client) ( context.Context,  *AccountGetAuthorizationFormRequest) (*AccountAuthorizationForm, error) {
	var  AccountAuthorizationForm

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