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

// Birthday represents TL type `birthday#6c8e1e06`.
// Birthday¹ information for a user.
// Also used to invite users to gift Telegram Premium subscriptions »¹ to other users
// with birthdays within a +1/-1 day time range, related to the current day.
//
// Links:
//  1. https://core.telegram.org/api/profile#birthday
//  2. https://core.telegram.org/api/premium#gifting-telegram-premium
//
// See https://core.telegram.org/constructor/birthday for reference.
type Birthday struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Birth day
	Day int
	// Birth month
	Month int
	// (Optional) birth year.
	//
	// Use SetYear and GetYear helpers.
	Year int
}

// BirthdayTypeID is TL type id of Birthday.
const BirthdayTypeID = 0x6c8e1e06

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

func ( *Birthday) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Day == 0) {
		return false
	}
	if !(.Month == 0) {
		return false
	}
	if !(.Year == 0) {
		return false
	}

	return true
}

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

// FillFrom fills Birthday from given interface.
func ( *Birthday) ( interface {
	() ( int)
	() ( int)
	() ( int,  bool)
}) {
	.Day = .()
	.Month = .()
	if ,  := .();  {
		.Year = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *Birthday) () tdp.Type {
	 := tdp.Type{
		Name: "birthday",
		ID:   BirthdayTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Day",
			SchemaName: "day",
		},
		{
			Name:       "Month",
			SchemaName: "month",
		},
		{
			Name:       "Year",
			SchemaName: "year",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *Birthday) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode birthday#6c8e1e06 as nil")
	}
	.PutID(BirthdayTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *Birthday) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode birthday#6c8e1e06 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode birthday#6c8e1e06: field flags: %w", )
	}
	.PutInt(.Day)
	.PutInt(.Month)
	if .Flags.Has(0) {
		.PutInt(.Year)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *Birthday) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode birthday#6c8e1e06 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode birthday#6c8e1e06: field flags: %w", )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode birthday#6c8e1e06: field day: %w", )
		}
		.Day = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode birthday#6c8e1e06: field month: %w", )
		}
		.Month = 
	}
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode birthday#6c8e1e06: field year: %w", )
		}
		.Year = 
	}
	return nil
}

// GetDay returns value of Day field.
func ( *Birthday) () ( int) {
	if  == nil {
		return
	}
	return .Day
}

// GetMonth returns value of Month field.
func ( *Birthday) () ( int) {
	if  == nil {
		return
	}
	return .Month
}

// SetYear sets value of Year conditional field.
func ( *Birthday) ( int) {
	.Flags.Set(0)
	.Year = 
}

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