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

// BusinessWorkHours represents TL type `businessWorkHours#8c92b098`.
// Specifies a set of Telegram Business opening hours¹.
//
// Links:
//  1. https://core.telegram.org/api/business#opening-hours
//
// See https://core.telegram.org/constructor/businessWorkHours for reference.
type BusinessWorkHours struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Ignored if set while invoking account.updateBusinessWorkHours¹, only returned by the
	// server in userFull².business_work_hours, indicating whether the business is currently
	// open according to the current time and the values in weekly_open and timezone.
	//
	// Links:
	//  1) https://core.telegram.org/method/account.updateBusinessWorkHours
	//  2) https://core.telegram.org/constructor/userFull
	OpenNow bool
	// An ID of one of the timezones returned by help.getTimezonesList¹.    The timezone ID
	// is contained timezone².id, a human-readable, localized name of the timezone is
	// available in timezone³.name and the timezone⁴.utc_offset field contains the UTC
	// offset in seconds, which may be displayed in hh:mm format by the client together with
	// the human-readable name (i.e. $name UTC -01:00).
	//
	// Links:
	//  1) https://core.telegram.org/method/help.getTimezonesList
	//  2) https://core.telegram.org/constructor/timezone
	//  3) https://core.telegram.org/constructor/timezone
	//  4) https://core.telegram.org/constructor/timezone
	TimezoneID string
	// A list of time intervals (max 28) represented by businessWeeklyOpen »¹, indicating
	// the opening hours of their business.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/businessWeeklyOpen
	WeeklyOpen []BusinessWeeklyOpen
}

// BusinessWorkHoursTypeID is TL type id of BusinessWorkHours.
const BusinessWorkHoursTypeID = 0x8c92b098

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

func ( *BusinessWorkHours) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.OpenNow == false) {
		return false
	}
	if !(.TimezoneID == "") {
		return false
	}
	if !(.WeeklyOpen == nil) {
		return false
	}

	return true
}

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

// FillFrom fills BusinessWorkHours from given interface.
func ( *BusinessWorkHours) ( interface {
	() ( bool)
	() ( string)
	() ( []BusinessWeeklyOpen)
}) {
	.OpenNow = .()
	.TimezoneID = .()
	.WeeklyOpen = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *BusinessWorkHours) () tdp.Type {
	 := tdp.Type{
		Name: "businessWorkHours",
		ID:   BusinessWorkHoursTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "OpenNow",
			SchemaName: "open_now",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "TimezoneID",
			SchemaName: "timezone_id",
		},
		{
			Name:       "WeeklyOpen",
			SchemaName: "weekly_open",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *BusinessWorkHours) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode businessWorkHours#8c92b098 as nil")
	}
	.PutID(BusinessWorkHoursTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BusinessWorkHours) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode businessWorkHours#8c92b098 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode businessWorkHours#8c92b098: field flags: %w", )
	}
	.PutString(.TimezoneID)
	.PutVectorHeader(len(.WeeklyOpen))
	for ,  := range .WeeklyOpen {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode businessWorkHours#8c92b098: field weekly_open element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *BusinessWorkHours) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode businessWorkHours#8c92b098 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode businessWorkHours#8c92b098: field flags: %w", )
		}
	}
	.OpenNow = .Flags.Has(0)
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode businessWorkHours#8c92b098: field timezone_id: %w", )
		}
		.TimezoneID = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode businessWorkHours#8c92b098: field weekly_open: %w", )
		}

		if  > 0 {
			.WeeklyOpen = make([]BusinessWeeklyOpen, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  BusinessWeeklyOpen
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode businessWorkHours#8c92b098: field weekly_open: %w", )
			}
			.WeeklyOpen = append(.WeeklyOpen, )
		}
	}
	return nil
}

// SetOpenNow sets value of OpenNow conditional field.
func ( *BusinessWorkHours) ( bool) {
	if  {
		.Flags.Set(0)
		.OpenNow = true
	} else {
		.Flags.Unset(0)
		.OpenNow = false
	}
}

// GetOpenNow returns value of OpenNow conditional field.
func ( *BusinessWorkHours) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetTimezoneID returns value of TimezoneID field.
func ( *BusinessWorkHours) () ( string) {
	if  == nil {
		return
	}
	return .TimezoneID
}

// GetWeeklyOpen returns value of WeeklyOpen field.
func ( *BusinessWorkHours) () ( []BusinessWeeklyOpen) {
	if  == nil {
		return
	}
	return .WeeklyOpen
}