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

// BusinessWeeklyOpen represents TL type `businessWeeklyOpen#120b1ab9`.
// A time interval, indicating the opening hours of a business.
// Note that opening hours specified by the user must be appropriately validated and
// transformed before uploading them to the server, as specified here »¹.
//
// Links:
//  1. https://core.telegram.org/api/business#opening-hours
//
// See https://core.telegram.org/constructor/businessWeeklyOpen for reference.
type BusinessWeeklyOpen struct {
	// Start minute in minutes of the week, 0 to 7*24*60 inclusively.
	StartMinute int
	// End minute in minutes of the week, 1 to 8*24*60 inclusively (8 and not 7 because this
	// allows to specify intervals that, for example, start on Sunday 21:00 and end on Monday
	// 04:00 (6*24*60+21*60 to 7*24*60+4*60) without passing an invalid end_minute <
	// start_minute). See here »¹ for more info.
	//
	// Links:
	//  1) https://core.telegram.org/api/business#opening-hours
	EndMinute int
}

// BusinessWeeklyOpenTypeID is TL type id of BusinessWeeklyOpen.
const BusinessWeeklyOpenTypeID = 0x120b1ab9

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

func ( *BusinessWeeklyOpen) () bool {
	if  == nil {
		return true
	}
	if !(.StartMinute == 0) {
		return false
	}
	if !(.EndMinute == 0) {
		return false
	}

	return true
}

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

// FillFrom fills BusinessWeeklyOpen from given interface.
func ( *BusinessWeeklyOpen) ( interface {
	() ( int)
	() ( int)
}) {
	.StartMinute = .()
	.EndMinute = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *BusinessWeeklyOpen) () tdp.Type {
	 := tdp.Type{
		Name: "businessWeeklyOpen",
		ID:   BusinessWeeklyOpenTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "StartMinute",
			SchemaName: "start_minute",
		},
		{
			Name:       "EndMinute",
			SchemaName: "end_minute",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *BusinessWeeklyOpen) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode businessWeeklyOpen#120b1ab9 as nil")
	}
	.PutID(BusinessWeeklyOpenTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BusinessWeeklyOpen) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode businessWeeklyOpen#120b1ab9 as nil")
	}
	.PutInt(.StartMinute)
	.PutInt(.EndMinute)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *BusinessWeeklyOpen) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode businessWeeklyOpen#120b1ab9 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode businessWeeklyOpen#120b1ab9: field start_minute: %w", )
		}
		.StartMinute = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode businessWeeklyOpen#120b1ab9: field end_minute: %w", )
		}
		.EndMinute = 
	}
	return nil
}

// GetStartMinute returns value of StartMinute field.
func ( *BusinessWeeklyOpen) () ( int) {
	if  == nil {
		return
	}
	return .StartMinute
}

// GetEndMinute returns value of EndMinute field.
func ( *BusinessWeeklyOpen) () ( int) {
	if  == nil {
		return
	}
	return .EndMinute
}