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

// OnrampSession represents TL type `onrampSession#d1e42e24`.
//
// See https://core.telegram.org/constructor/onrampSession for reference.
type OnrampSession struct {
	// Provider field of OnrampSession.
	Provider string
	// SessionID field of OnrampSession.
	SessionID string
	// URL field of OnrampSession.
	URL string
	// ExpiresDate field of OnrampSession.
	ExpiresDate int
}

// OnrampSessionTypeID is TL type id of OnrampSession.
const OnrampSessionTypeID = 0xd1e42e24

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

func ( *OnrampSession) () bool {
	if  == nil {
		return true
	}
	if !(.Provider == "") {
		return false
	}
	if !(.SessionID == "") {
		return false
	}
	if !(.URL == "") {
		return false
	}
	if !(.ExpiresDate == 0) {
		return false
	}

	return true
}

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

// FillFrom fills OnrampSession from given interface.
func ( *OnrampSession) ( interface {
	() ( string)
	() ( string)
	() ( string)
	() ( int)
}) {
	.Provider = .()
	.SessionID = .()
	.URL = .()
	.ExpiresDate = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *OnrampSession) () tdp.Type {
	 := tdp.Type{
		Name: "onrampSession",
		ID:   OnrampSessionTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Provider",
			SchemaName: "provider",
		},
		{
			Name:       "SessionID",
			SchemaName: "session_id",
		},
		{
			Name:       "URL",
			SchemaName: "url",
		},
		{
			Name:       "ExpiresDate",
			SchemaName: "expires_date",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *OnrampSession) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode onrampSession#d1e42e24 as nil")
	}
	.PutID(OnrampSessionTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *OnrampSession) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode onrampSession#d1e42e24 as nil")
	}
	.PutString(.Provider)
	.PutString(.SessionID)
	.PutString(.URL)
	.PutInt(.ExpiresDate)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *OnrampSession) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode onrampSession#d1e42e24 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode onrampSession#d1e42e24: field provider: %w", )
		}
		.Provider = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode onrampSession#d1e42e24: field session_id: %w", )
		}
		.SessionID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode onrampSession#d1e42e24: field url: %w", )
		}
		.URL = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode onrampSession#d1e42e24: field expires_date: %w", )
		}
		.ExpiresDate = 
	}
	return nil
}

// GetProvider returns value of Provider field.
func ( *OnrampSession) () ( string) {
	if  == nil {
		return
	}
	return .Provider
}

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

// GetURL returns value of URL field.
func ( *OnrampSession) () ( string) {
	if  == nil {
		return
	}
	return .URL
}

// GetExpiresDate returns value of ExpiresDate field.
func ( *OnrampSession) () ( int) {
	if  == nil {
		return
	}
	return .ExpiresDate
}