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

// BusinessLocation represents TL type `businessLocation#ac5c1af7`.
// Represents the location of a Telegram Business »¹.
//
// Links:
//  1. https://core.telegram.org/api/business#location
//
// See https://core.telegram.org/constructor/businessLocation for reference.
type BusinessLocation struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Geographical coordinates (optional).
	//
	// Use SetGeoPoint and GetGeoPoint helpers.
	GeoPoint GeoPointClass
	// Textual description of the address (mandatory).
	Address string
}

// BusinessLocationTypeID is TL type id of BusinessLocation.
const BusinessLocationTypeID = 0xac5c1af7

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

func ( *BusinessLocation) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.GeoPoint == nil) {
		return false
	}
	if !(.Address == "") {
		return false
	}

	return true
}

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

// FillFrom fills BusinessLocation from given interface.
func ( *BusinessLocation) ( interface {
	() ( GeoPointClass,  bool)
	() ( string)
}) {
	if ,  := .();  {
		.GeoPoint = 
	}

	.Address = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *BusinessLocation) () tdp.Type {
	 := tdp.Type{
		Name: "businessLocation",
		ID:   BusinessLocationTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "GeoPoint",
			SchemaName: "geo_point",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Address",
			SchemaName: "address",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *BusinessLocation) () {
	if !(.GeoPoint == nil) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *BusinessLocation) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode businessLocation#ac5c1af7 as nil")
	}
	.PutID(BusinessLocationTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *BusinessLocation) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode businessLocation#ac5c1af7 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode businessLocation#ac5c1af7: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := DecodeGeoPoint()
		if  != nil {
			return fmt.Errorf("unable to decode businessLocation#ac5c1af7: field geo_point: %w", )
		}
		.GeoPoint = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode businessLocation#ac5c1af7: field address: %w", )
		}
		.Address = 
	}
	return nil
}

// SetGeoPoint sets value of GeoPoint conditional field.
func ( *BusinessLocation) ( GeoPointClass) {
	.Flags.Set(0)
	.GeoPoint = 
}

// GetGeoPoint returns value of GeoPoint conditional field and
// boolean which is true if field was set.
func ( *BusinessLocation) () ( GeoPointClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .GeoPoint, true
}

// GetAddress returns value of Address field.
func ( *BusinessLocation) () ( string) {
	if  == nil {
		return
	}
	return .Address
}

// GetGeoPointAsNotEmpty returns mapped value of GeoPoint conditional field and
// boolean which is true if field was set.
func ( *BusinessLocation) () (*GeoPoint, bool) {
	if ,  := .GetGeoPoint();  {
		return .AsNotEmpty()
	}
	return nil, false
}