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

// ContactsGetLocatedRequest represents TL type `contacts.getLocated#d348bc44`.
// Get users and geochats near you, see here »¹ for more info.
//
// Links:
//  1. https://core.telegram.org/api/nearby
//
// See https://core.telegram.org/method/contacts.getLocated for reference.
type ContactsGetLocatedRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// While the geolocation of the current user is public, clients should update it in the
	// background every half-an-hour or so, while setting this flag. Do this only if the new
	// location is more than 1 KM away from the previous one, or if the previous location is
	// unknown.
	Background bool
	// Geolocation
	GeoPoint InputGeoPointClass
	// If set, the geolocation of the current user will be public for the specified number of
	// seconds; pass 0x7fffffff to disable expiry, 0 to make the current geolocation private;
	// if the flag isn't set, no changes will be applied.
	//
	// Use SetSelfExpires and GetSelfExpires helpers.
	SelfExpires int
}

// ContactsGetLocatedRequestTypeID is TL type id of ContactsGetLocatedRequest.
const ContactsGetLocatedRequestTypeID = 0xd348bc44

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

func ( *ContactsGetLocatedRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Background == false) {
		return false
	}
	if !(.GeoPoint == nil) {
		return false
	}
	if !(.SelfExpires == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ContactsGetLocatedRequest from given interface.
func ( *ContactsGetLocatedRequest) ( interface {
	() ( bool)
	() ( InputGeoPointClass)
	() ( int,  bool)
}) {
	.Background = .()
	.GeoPoint = .()
	if ,  := .();  {
		.SelfExpires = 
	}

}

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

// TypeName returns name of type in TL schema.
func (*ContactsGetLocatedRequest) () string {
	return "contacts.getLocated"
}

// TypeInfo returns info about TL type.
func ( *ContactsGetLocatedRequest) () tdp.Type {
	 := tdp.Type{
		Name: "contacts.getLocated",
		ID:   ContactsGetLocatedRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Background",
			SchemaName: "background",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "GeoPoint",
			SchemaName: "geo_point",
		},
		{
			Name:       "SelfExpires",
			SchemaName: "self_expires",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ContactsGetLocatedRequest) () {
	if !(.Background == false) {
		.Flags.Set(1)
	}
	if !(.SelfExpires == 0) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *ContactsGetLocatedRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.getLocated#d348bc44 as nil")
	}
	.PutID(ContactsGetLocatedRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ContactsGetLocatedRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode contacts.getLocated#d348bc44 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode contacts.getLocated#d348bc44: field flags: %w", )
	}
	if .GeoPoint == nil {
		return fmt.Errorf("unable to encode contacts.getLocated#d348bc44: field geo_point is nil")
	}
	if  := .GeoPoint.Encode();  != nil {
		return fmt.Errorf("unable to encode contacts.getLocated#d348bc44: field geo_point: %w", )
	}
	if .Flags.Has(0) {
		.PutInt(.SelfExpires)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ContactsGetLocatedRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode contacts.getLocated#d348bc44 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode contacts.getLocated#d348bc44: field flags: %w", )
		}
	}
	.Background = .Flags.Has(1)
	{
		,  := DecodeInputGeoPoint()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.getLocated#d348bc44: field geo_point: %w", )
		}
		.GeoPoint = 
	}
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode contacts.getLocated#d348bc44: field self_expires: %w", )
		}
		.SelfExpires = 
	}
	return nil
}

// SetBackground sets value of Background conditional field.
func ( *ContactsGetLocatedRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.Background = true
	} else {
		.Flags.Unset(1)
		.Background = false
	}
}

// GetBackground returns value of Background conditional field.
func ( *ContactsGetLocatedRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// GetGeoPoint returns value of GeoPoint field.
func ( *ContactsGetLocatedRequest) () ( InputGeoPointClass) {
	if  == nil {
		return
	}
	return .GeoPoint
}

// SetSelfExpires sets value of SelfExpires conditional field.
func ( *ContactsGetLocatedRequest) ( int) {
	.Flags.Set(0)
	.SelfExpires = 
}

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

// GetGeoPointAsNotEmpty returns mapped value of GeoPoint field.
func ( *ContactsGetLocatedRequest) () (*InputGeoPoint, bool) {
	return .GeoPoint.AsNotEmpty()
}

// ContactsGetLocated invokes method contacts.getLocated#d348bc44 returning error if any.
// Get users and geochats near you, see here »¹ for more info.
//
// Links:
//  1. https://core.telegram.org/api/nearby
//
// Possible errors:
//
//	400 GEO_POINT_INVALID: Invalid geoposition provided.
//	406 USERPIC_PRIVACY_REQUIRED: You need to disable privacy settings for your profile picture in order to make your geolocation public.
//	406 USERPIC_UPLOAD_REQUIRED: You must have a profile picture to publish your geolocation.
//
// See https://core.telegram.org/method/contacts.getLocated for reference.
func ( *Client) ( context.Context,  *ContactsGetLocatedRequest) (UpdatesClass, error) {
	var  UpdatesBox

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