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

// UpdatesGetDifferenceRequest represents TL type `updates.getDifference#19c2f763`.
// Get new updates¹.
//
// Links:
//  1. https://core.telegram.org/api/updates
//
// See https://core.telegram.org/method/updates.getDifference for reference.
type UpdatesGetDifferenceRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// PTS, see updates¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/updates
	Pts int
	// PTS limit
	//
	// Use SetPtsLimit and GetPtsLimit helpers.
	PtsLimit int
	// For fast updating: if provided and pts + pts_total_limit < remote pts, updates
	// differenceTooLong¹ will be returned.Simply tells the server to not return the
	// difference if it is bigger than pts_total_limitIf the remote pts is too big (>
	// ~4000000), this field will default to 1000000
	//
	// Links:
	//  1) https://core.telegram.org/constructor/updates.differenceTooLong
	//
	// Use SetPtsTotalLimit and GetPtsTotalLimit helpers.
	PtsTotalLimit int
	// date, see updates¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/updates
	Date int
	// QTS, see updates¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/updates
	Qts int
	// QTS limit
	//
	// Use SetQtsLimit and GetQtsLimit helpers.
	QtsLimit int
}

// UpdatesGetDifferenceRequestTypeID is TL type id of UpdatesGetDifferenceRequest.
const UpdatesGetDifferenceRequestTypeID = 0x19c2f763

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

func ( *UpdatesGetDifferenceRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Pts == 0) {
		return false
	}
	if !(.PtsLimit == 0) {
		return false
	}
	if !(.PtsTotalLimit == 0) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.Qts == 0) {
		return false
	}
	if !(.QtsLimit == 0) {
		return false
	}

	return true
}

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

// FillFrom fills UpdatesGetDifferenceRequest from given interface.
func ( *UpdatesGetDifferenceRequest) ( interface {
	() ( int)
	() ( int,  bool)
	() ( int,  bool)
	() ( int)
	() ( int)
	() ( int,  bool)
}) {
	.Pts = .()
	if ,  := .();  {
		.PtsLimit = 
	}

	if ,  := .();  {
		.PtsTotalLimit = 
	}

	.Date = .()
	.Qts = .()
	if ,  := .();  {
		.QtsLimit = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *UpdatesGetDifferenceRequest) () tdp.Type {
	 := tdp.Type{
		Name: "updates.getDifference",
		ID:   UpdatesGetDifferenceRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Pts",
			SchemaName: "pts",
		},
		{
			Name:       "PtsLimit",
			SchemaName: "pts_limit",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "PtsTotalLimit",
			SchemaName: "pts_total_limit",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "Qts",
			SchemaName: "qts",
		},
		{
			Name:       "QtsLimit",
			SchemaName: "qts_limit",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *UpdatesGetDifferenceRequest) () {
	if !(.PtsLimit == 0) {
		.Flags.Set(1)
	}
	if !(.PtsTotalLimit == 0) {
		.Flags.Set(0)
	}
	if !(.QtsLimit == 0) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *UpdatesGetDifferenceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode updates.getDifference#19c2f763 as nil")
	}
	.PutID(UpdatesGetDifferenceRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *UpdatesGetDifferenceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode updates.getDifference#19c2f763 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode updates.getDifference#19c2f763: field flags: %w", )
	}
	.PutInt(.Pts)
	if .Flags.Has(1) {
		.PutInt(.PtsLimit)
	}
	if .Flags.Has(0) {
		.PutInt(.PtsTotalLimit)
	}
	.PutInt(.Date)
	.PutInt(.Qts)
	if .Flags.Has(2) {
		.PutInt(.QtsLimit)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *UpdatesGetDifferenceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode updates.getDifference#19c2f763 to nil")
	}
	if  := .ConsumeID(UpdatesGetDifferenceRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode updates.getDifference#19c2f763: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *UpdatesGetDifferenceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode updates.getDifference#19c2f763 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode updates.getDifference#19c2f763: field flags: %w", )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode updates.getDifference#19c2f763: field pts: %w", )
		}
		.Pts = 
	}
	if .Flags.Has(1) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode updates.getDifference#19c2f763: field pts_limit: %w", )
		}
		.PtsLimit = 
	}
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode updates.getDifference#19c2f763: field pts_total_limit: %w", )
		}
		.PtsTotalLimit = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode updates.getDifference#19c2f763: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode updates.getDifference#19c2f763: field qts: %w", )
		}
		.Qts = 
	}
	if .Flags.Has(2) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode updates.getDifference#19c2f763: field qts_limit: %w", )
		}
		.QtsLimit = 
	}
	return nil
}

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

// SetPtsLimit sets value of PtsLimit conditional field.
func ( *UpdatesGetDifferenceRequest) ( int) {
	.Flags.Set(1)
	.PtsLimit = 
}

// GetPtsLimit returns value of PtsLimit conditional field and
// boolean which is true if field was set.
func ( *UpdatesGetDifferenceRequest) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .PtsLimit, true
}

// SetPtsTotalLimit sets value of PtsTotalLimit conditional field.
func ( *UpdatesGetDifferenceRequest) ( int) {
	.Flags.Set(0)
	.PtsTotalLimit = 
}

// GetPtsTotalLimit returns value of PtsTotalLimit conditional field and
// boolean which is true if field was set.
func ( *UpdatesGetDifferenceRequest) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .PtsTotalLimit, true
}

// GetDate returns value of Date field.
func ( *UpdatesGetDifferenceRequest) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// GetQts returns value of Qts field.
func ( *UpdatesGetDifferenceRequest) () ( int) {
	if  == nil {
		return
	}
	return .Qts
}

// SetQtsLimit sets value of QtsLimit conditional field.
func ( *UpdatesGetDifferenceRequest) ( int) {
	.Flags.Set(2)
	.QtsLimit = 
}

// GetQtsLimit returns value of QtsLimit conditional field and
// boolean which is true if field was set.
func ( *UpdatesGetDifferenceRequest) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .QtsLimit, true
}

// UpdatesGetDifference invokes method updates.getDifference#19c2f763 returning error if any.
// Get new updates¹.
//
// Links:
//  1. https://core.telegram.org/api/updates
//
// Possible errors:
//
//	400 CDN_METHOD_INVALID: You can't call this method in a CDN DC.
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	400 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	403 CHAT_WRITE_FORBIDDEN: You can't write in this chat.
//	400 DATE_EMPTY: Date empty.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//	400 PERSISTENT_TIMESTAMP_EMPTY: Persistent timestamp empty.
//	400 PERSISTENT_TIMESTAMP_INVALID: Persistent timestamp invalid.
//	500 RANDOM_ID_DUPLICATE: You provided a random ID that was already used.
//	400 USERNAME_INVALID: The provided username is not valid.
//	400 USER_NOT_PARTICIPANT: You're not a member of this supergroup/channel.
//
// See https://core.telegram.org/method/updates.getDifference for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *UpdatesGetDifferenceRequest) (UpdatesDifferenceClass, error) {
	var  UpdatesDifferenceBox

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