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

// UpdatesGetChannelDifferenceRequest represents TL type `updates.getChannelDifference#3173d78`.
// Returns the difference between the current state of updates of a certain channel and
// transmitted.
//
// See https://core.telegram.org/method/updates.getChannelDifference for reference.
type UpdatesGetChannelDifferenceRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Set to true to skip some possibly unneeded updates and reduce server-side load
	Force bool
	// The channel
	Channel InputChannelClass
	// Messsage filter
	Filter ChannelMessagesFilterClass
	// Persistent timestamp (see updates¹)
	//
	// Links:
	//  1) https://core.telegram.org/api/updates
	Pts int
	// How many updates to fetch, max 100000Ordinary (non-bot) users are supposed to pass
	// 10-100
	Limit int
}

// UpdatesGetChannelDifferenceRequestTypeID is TL type id of UpdatesGetChannelDifferenceRequest.
const UpdatesGetChannelDifferenceRequestTypeID = 0x3173d78

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

func ( *UpdatesGetChannelDifferenceRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Force == false) {
		return false
	}
	if !(.Channel == nil) {
		return false
	}
	if !(.Filter == nil) {
		return false
	}
	if !(.Pts == 0) {
		return false
	}
	if !(.Limit == 0) {
		return false
	}

	return true
}

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

// FillFrom fills UpdatesGetChannelDifferenceRequest from given interface.
func ( *UpdatesGetChannelDifferenceRequest) ( interface {
	() ( bool)
	() ( InputChannelClass)
	() ( ChannelMessagesFilterClass)
	() ( int)
	() ( int)
}) {
	.Force = .()
	.Channel = .()
	.Filter = .()
	.Pts = .()
	.Limit = .()
}

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

// TypeName returns name of type in TL schema.
func (*UpdatesGetChannelDifferenceRequest) () string {
	return "updates.getChannelDifference"
}

// TypeInfo returns info about TL type.
func ( *UpdatesGetChannelDifferenceRequest) () tdp.Type {
	 := tdp.Type{
		Name: "updates.getChannelDifference",
		ID:   UpdatesGetChannelDifferenceRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Force",
			SchemaName: "force",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			Name:       "Filter",
			SchemaName: "filter",
		},
		{
			Name:       "Pts",
			SchemaName: "pts",
		},
		{
			Name:       "Limit",
			SchemaName: "limit",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *UpdatesGetChannelDifferenceRequest) () {
	if !(.Force == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *UpdatesGetChannelDifferenceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode updates.getChannelDifference#3173d78 as nil")
	}
	.PutID(UpdatesGetChannelDifferenceRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *UpdatesGetChannelDifferenceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode updates.getChannelDifference#3173d78 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode updates.getChannelDifference#3173d78: field flags: %w", )
	}
	if .Channel == nil {
		return fmt.Errorf("unable to encode updates.getChannelDifference#3173d78: field channel is nil")
	}
	if  := .Channel.Encode();  != nil {
		return fmt.Errorf("unable to encode updates.getChannelDifference#3173d78: field channel: %w", )
	}
	if .Filter == nil {
		return fmt.Errorf("unable to encode updates.getChannelDifference#3173d78: field filter is nil")
	}
	if  := .Filter.Encode();  != nil {
		return fmt.Errorf("unable to encode updates.getChannelDifference#3173d78: field filter: %w", )
	}
	.PutInt(.Pts)
	.PutInt(.Limit)
	return nil
}

// Decode implements bin.Decoder.
func ( *UpdatesGetChannelDifferenceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode updates.getChannelDifference#3173d78 to nil")
	}
	if  := .ConsumeID(UpdatesGetChannelDifferenceRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode updates.getChannelDifference#3173d78: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *UpdatesGetChannelDifferenceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode updates.getChannelDifference#3173d78 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode updates.getChannelDifference#3173d78: field flags: %w", )
		}
	}
	.Force = .Flags.Has(0)
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode updates.getChannelDifference#3173d78: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := DecodeChannelMessagesFilter()
		if  != nil {
			return fmt.Errorf("unable to decode updates.getChannelDifference#3173d78: field filter: %w", )
		}
		.Filter = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode updates.getChannelDifference#3173d78: field pts: %w", )
		}
		.Pts = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode updates.getChannelDifference#3173d78: field limit: %w", )
		}
		.Limit = 
	}
	return nil
}

// SetForce sets value of Force conditional field.
func ( *UpdatesGetChannelDifferenceRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Force = true
	} else {
		.Flags.Unset(0)
		.Force = false
	}
}

// GetForce returns value of Force conditional field.
func ( *UpdatesGetChannelDifferenceRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetChannel returns value of Channel field.
func ( *UpdatesGetChannelDifferenceRequest) () ( InputChannelClass) {
	if  == nil {
		return
	}
	return .Channel
}

// GetFilter returns value of Filter field.
func ( *UpdatesGetChannelDifferenceRequest) () ( ChannelMessagesFilterClass) {
	if  == nil {
		return
	}
	return .Filter
}

// GetPts returns value of Pts field.
func ( *UpdatesGetChannelDifferenceRequest) () ( int) {
	if  == nil {
		return
	}
	return .Pts
}

// GetLimit returns value of Limit field.
func ( *UpdatesGetChannelDifferenceRequest) () ( int) {
	if  == nil {
		return
	}
	return .Limit
}

// GetChannelAsNotEmpty returns mapped value of Channel field.
func ( *UpdatesGetChannelDifferenceRequest) () (NotEmptyInputChannel, bool) {
	return .Channel.AsNotEmpty()
}

// GetFilterAsNotEmpty returns mapped value of Filter field.
func ( *UpdatesGetChannelDifferenceRequest) () (*ChannelMessagesFilter, bool) {
	return .Filter.AsNotEmpty()
}

// UpdatesGetChannelDifference invokes method updates.getChannelDifference#3173d78 returning error if any.
// Returns the difference between the current state of updates of a certain channel and
// transmitted.
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	406 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	403 CHANNEL_PUBLIC_GROUP_NA: channel/supergroup not available.
//	403 CHAT_WRITE_FORBIDDEN: You can't write in this chat.
//	400 FROM_MESSAGE_BOT_DISABLED: Bots can't use fromMessage min constructors.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//	400 PERSISTENT_TIMESTAMP_EMPTY: Persistent timestamp empty.
//	400 PERSISTENT_TIMESTAMP_INVALID: Persistent timestamp invalid.
//	500 PERSISTENT_TIMESTAMP_OUTDATED: Channel internal replication issues, try again later (treat this like an RPC_CALL_FAIL).
//	400 PINNED_DIALOGS_TOO_MUCH: Too many pinned dialogs.
//	400 RANGES_INVALID: Invalid range provided.
//	400 USER_BANNED_IN_CHANNEL: You're banned from sending messages in supergroups/channels.
//
// See https://core.telegram.org/method/updates.getChannelDifference for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *UpdatesGetChannelDifferenceRequest) (UpdatesChannelDifferenceClass, error) {
	var  UpdatesChannelDifferenceBox

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