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

// InputTonConnectOauthSession represents TL type `inputTonConnectOauthSession#629f66ce`.
//
// See https://core.telegram.org/constructor/inputTonConnectOauthSession for reference.
type InputTonConnectOauthSession struct {
	// SessionID field of InputTonConnectOauthSession.
	SessionID int64
	// ChallengeAnswer field of InputTonConnectOauthSession.
	ChallengeAnswer []byte
	// Body field of InputTonConnectOauthSession.
	Body []byte
	// Proof field of InputTonConnectOauthSession.
	Proof WalletOwnershipProof
}

// InputTonConnectOauthSessionTypeID is TL type id of InputTonConnectOauthSession.
const InputTonConnectOauthSessionTypeID = 0x629f66ce

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

func ( *InputTonConnectOauthSession) () bool {
	if  == nil {
		return true
	}
	if !(.SessionID == 0) {
		return false
	}
	if !(.ChallengeAnswer == nil) {
		return false
	}
	if !(.Body == nil) {
		return false
	}
	if !(.Proof.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills InputTonConnectOauthSession from given interface.
func ( *InputTonConnectOauthSession) ( interface {
	() ( int64)
	() ( []byte)
	() ( []byte)
	() ( WalletOwnershipProof)
}) {
	.SessionID = .()
	.ChallengeAnswer = .()
	.Body = .()
	.Proof = .()
}

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

// TypeName returns name of type in TL schema.
func (*InputTonConnectOauthSession) () string {
	return "inputTonConnectOauthSession"
}

// TypeInfo returns info about TL type.
func ( *InputTonConnectOauthSession) () tdp.Type {
	 := tdp.Type{
		Name: "inputTonConnectOauthSession",
		ID:   InputTonConnectOauthSessionTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "SessionID",
			SchemaName: "session_id",
		},
		{
			Name:       "ChallengeAnswer",
			SchemaName: "challenge_answer",
		},
		{
			Name:       "Body",
			SchemaName: "body",
		},
		{
			Name:       "Proof",
			SchemaName: "proof",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputTonConnectOauthSession) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputTonConnectOauthSession#629f66ce as nil")
	}
	.PutID(InputTonConnectOauthSessionTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputTonConnectOauthSession) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputTonConnectOauthSession#629f66ce as nil")
	}
	.PutLong(.SessionID)
	.PutBytes(.ChallengeAnswer)
	.PutBytes(.Body)
	if  := .Proof.Encode();  != nil {
		return fmt.Errorf("unable to encode inputTonConnectOauthSession#629f66ce: field proof: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *InputTonConnectOauthSession) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputTonConnectOauthSession#629f66ce to nil")
	}
	if  := .ConsumeID(InputTonConnectOauthSessionTypeID);  != nil {
		return fmt.Errorf("unable to decode inputTonConnectOauthSession#629f66ce: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *InputTonConnectOauthSession) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputTonConnectOauthSession#629f66ce to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode inputTonConnectOauthSession#629f66ce: field session_id: %w", )
		}
		.SessionID = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode inputTonConnectOauthSession#629f66ce: field challenge_answer: %w", )
		}
		.ChallengeAnswer = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode inputTonConnectOauthSession#629f66ce: field body: %w", )
		}
		.Body = 
	}
	{
		if  := .Proof.Decode();  != nil {
			return fmt.Errorf("unable to decode inputTonConnectOauthSession#629f66ce: field proof: %w", )
		}
	}
	return nil
}

// GetSessionID returns value of SessionID field.
func ( *InputTonConnectOauthSession) () ( int64) {
	if  == nil {
		return
	}
	return .SessionID
}

// GetChallengeAnswer returns value of ChallengeAnswer field.
func ( *InputTonConnectOauthSession) () ( []byte) {
	if  == nil {
		return
	}
	return .ChallengeAnswer
}

// GetBody returns value of Body field.
func ( *InputTonConnectOauthSession) () ( []byte) {
	if  == nil {
		return
	}
	return .Body
}

// GetProof returns value of Proof field.
func ( *InputTonConnectOauthSession) () ( WalletOwnershipProof) {
	if  == nil {
		return
	}
	return .Proof
}