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

// WebAuthorization represents TL type `webAuthorization#a6f8f452`.
// Represents a bot logged in using the Telegram login widget¹
//
// Links:
//  1. https://core.telegram.org/widgets/login
//
// See https://core.telegram.org/constructor/webAuthorization for reference.
type WebAuthorization struct {
	// Authorization hash
	Hash int64
	// Bot ID
	BotID int64
	// The domain name of the website on which the user has logged in.
	Domain string
	// Browser user-agent
	Browser string
	// Platform
	Platform string
	// When was the web session created
	DateCreated int
	// When was the web session last active
	DateActive int
	// IP address
	IP string
	// Region, determined from IP address
	Region string
}

// WebAuthorizationTypeID is TL type id of WebAuthorization.
const WebAuthorizationTypeID = 0xa6f8f452

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

func ( *WebAuthorization) () bool {
	if  == nil {
		return true
	}
	if !(.Hash == 0) {
		return false
	}
	if !(.BotID == 0) {
		return false
	}
	if !(.Domain == "") {
		return false
	}
	if !(.Browser == "") {
		return false
	}
	if !(.Platform == "") {
		return false
	}
	if !(.DateCreated == 0) {
		return false
	}
	if !(.DateActive == 0) {
		return false
	}
	if !(.IP == "") {
		return false
	}
	if !(.Region == "") {
		return false
	}

	return true
}

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

// FillFrom fills WebAuthorization from given interface.
func ( *WebAuthorization) ( interface {
	() ( int64)
	() ( int64)
	() ( string)
	() ( string)
	() ( string)
	() ( int)
	() ( int)
	() ( string)
	() ( string)
}) {
	.Hash = .()
	.BotID = .()
	.Domain = .()
	.Browser = .()
	.Platform = .()
	.DateCreated = .()
	.DateActive = .()
	.IP = .()
	.Region = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *WebAuthorization) () tdp.Type {
	 := tdp.Type{
		Name: "webAuthorization",
		ID:   WebAuthorizationTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
		{
			Name:       "BotID",
			SchemaName: "bot_id",
		},
		{
			Name:       "Domain",
			SchemaName: "domain",
		},
		{
			Name:       "Browser",
			SchemaName: "browser",
		},
		{
			Name:       "Platform",
			SchemaName: "platform",
		},
		{
			Name:       "DateCreated",
			SchemaName: "date_created",
		},
		{
			Name:       "DateActive",
			SchemaName: "date_active",
		},
		{
			Name:       "IP",
			SchemaName: "ip",
		},
		{
			Name:       "Region",
			SchemaName: "region",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *WebAuthorization) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode webAuthorization#a6f8f452 as nil")
	}
	.PutID(WebAuthorizationTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *WebAuthorization) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode webAuthorization#a6f8f452 as nil")
	}
	.PutLong(.Hash)
	.PutLong(.BotID)
	.PutString(.Domain)
	.PutString(.Browser)
	.PutString(.Platform)
	.PutInt(.DateCreated)
	.PutInt(.DateActive)
	.PutString(.IP)
	.PutString(.Region)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *WebAuthorization) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode webAuthorization#a6f8f452 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode webAuthorization#a6f8f452: field hash: %w", )
		}
		.Hash = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode webAuthorization#a6f8f452: field bot_id: %w", )
		}
		.BotID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode webAuthorization#a6f8f452: field domain: %w", )
		}
		.Domain = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode webAuthorization#a6f8f452: field browser: %w", )
		}
		.Browser = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode webAuthorization#a6f8f452: field platform: %w", )
		}
		.Platform = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode webAuthorization#a6f8f452: field date_created: %w", )
		}
		.DateCreated = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode webAuthorization#a6f8f452: field date_active: %w", )
		}
		.DateActive = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode webAuthorization#a6f8f452: field ip: %w", )
		}
		.IP = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode webAuthorization#a6f8f452: field region: %w", )
		}
		.Region = 
	}
	return nil
}

// GetHash returns value of Hash field.
func ( *WebAuthorization) () ( int64) {
	if  == nil {
		return
	}
	return .Hash
}

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

// GetDomain returns value of Domain field.
func ( *WebAuthorization) () ( string) {
	if  == nil {
		return
	}
	return .Domain
}

// GetBrowser returns value of Browser field.
func ( *WebAuthorization) () ( string) {
	if  == nil {
		return
	}
	return .Browser
}

// GetPlatform returns value of Platform field.
func ( *WebAuthorization) () ( string) {
	if  == nil {
		return
	}
	return .Platform
}

// GetDateCreated returns value of DateCreated field.
func ( *WebAuthorization) () ( int) {
	if  == nil {
		return
	}
	return .DateCreated
}

// GetDateActive returns value of DateActive field.
func ( *WebAuthorization) () ( int) {
	if  == nil {
		return
	}
	return .DateActive
}

// GetIP returns value of IP field.
func ( *WebAuthorization) () ( string) {
	if  == nil {
		return
	}
	return .IP
}

// GetRegion returns value of Region field.
func ( *WebAuthorization) () ( string) {
	if  == nil {
		return
	}
	return .Region
}