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

// AccountUnregisterDeviceRequest represents TL type `account.unregisterDevice#6a0d3206`.
// Deletes a device by its token, stops sending PUSH-notifications to it.
//
// See https://core.telegram.org/method/account.unregisterDevice for reference.
type AccountUnregisterDeviceRequest struct {
	// Device token type, see PUSH updates¹ for the possible values.
	//
	// Links:
	//  1) https://core.telegram.org/api/push-updates#subscribing-to-notifications
	TokenType int
	// Device token, see PUSH updates¹ for the possible values.
	//
	// Links:
	//  1) https://core.telegram.org/api/push-updates#subscribing-to-notifications
	Token string
	// List of user identifiers of other users currently using the client
	OtherUIDs []int64
}

// AccountUnregisterDeviceRequestTypeID is TL type id of AccountUnregisterDeviceRequest.
const AccountUnregisterDeviceRequestTypeID = 0x6a0d3206

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

func ( *AccountUnregisterDeviceRequest) () bool {
	if  == nil {
		return true
	}
	if !(.TokenType == 0) {
		return false
	}
	if !(.Token == "") {
		return false
	}
	if !(.OtherUIDs == nil) {
		return false
	}

	return true
}

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

// FillFrom fills AccountUnregisterDeviceRequest from given interface.
func ( *AccountUnregisterDeviceRequest) ( interface {
	() ( int)
	() ( string)
	() ( []int64)
}) {
	.TokenType = .()
	.Token = .()
	.OtherUIDs = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountUnregisterDeviceRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.unregisterDevice",
		ID:   AccountUnregisterDeviceRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "TokenType",
			SchemaName: "token_type",
		},
		{
			Name:       "Token",
			SchemaName: "token",
		},
		{
			Name:       "OtherUIDs",
			SchemaName: "other_uids",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountUnregisterDeviceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.unregisterDevice#6a0d3206 as nil")
	}
	.PutID(AccountUnregisterDeviceRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountUnregisterDeviceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.unregisterDevice#6a0d3206 as nil")
	}
	.PutInt(.TokenType)
	.PutString(.Token)
	.PutVectorHeader(len(.OtherUIDs))
	for ,  := range .OtherUIDs {
		.PutLong()
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountUnregisterDeviceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.unregisterDevice#6a0d3206 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode account.unregisterDevice#6a0d3206: field token_type: %w", )
		}
		.TokenType = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.unregisterDevice#6a0d3206: field token: %w", )
		}
		.Token = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode account.unregisterDevice#6a0d3206: field other_uids: %w", )
		}

		if  > 0 {
			.OtherUIDs = make([]int64, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Long()
			if  != nil {
				return fmt.Errorf("unable to decode account.unregisterDevice#6a0d3206: field other_uids: %w", )
			}
			.OtherUIDs = append(.OtherUIDs, )
		}
	}
	return nil
}

// GetTokenType returns value of TokenType field.
func ( *AccountUnregisterDeviceRequest) () ( int) {
	if  == nil {
		return
	}
	return .TokenType
}

// GetToken returns value of Token field.
func ( *AccountUnregisterDeviceRequest) () ( string) {
	if  == nil {
		return
	}
	return .Token
}

// GetOtherUIDs returns value of OtherUIDs field.
func ( *AccountUnregisterDeviceRequest) () ( []int64) {
	if  == nil {
		return
	}
	return .OtherUIDs
}

// AccountUnregisterDevice invokes method account.unregisterDevice#6a0d3206 returning error if any.
// Deletes a device by its token, stops sending PUSH-notifications to it.
//
// Possible errors:
//
//	400 TOKEN_INVALID: The provided token is invalid.
//
// See https://core.telegram.org/method/account.unregisterDevice for reference.
func ( *Client) ( context.Context,  *AccountUnregisterDeviceRequest) (bool, error) {
	var  BoolBox

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