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

// DisallowedGiftsSettings represents TL type `disallowedGiftsSettings#71f276c4`.
// Disallow the reception of specific gift¹ types.
//
// Links:
//  1. https://core.telegram.org/api/gifts
//
// See https://core.telegram.org/constructor/disallowedGiftsSettings for reference.
type DisallowedGiftsSettings struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Disallow the reception of gifts with an unlimited supply (those with the starGift¹
	// limited flag not set).
	//
	// Links:
	//  1) https://core.telegram.org/constructor/starGift
	DisallowUnlimitedStargifts bool
	// Disallow the reception of limited-supply gifts (those with the starGift¹.limited flag
	// set).
	//
	// Links:
	//  1) https://core.telegram.org/constructor/starGift
	DisallowLimitedStargifts bool
	// Disallow the reception of collectible gifts »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#collectible-gifts
	DisallowUniqueStargifts bool
	// Disallow the reception of gifted Telegram Premium subscriptions »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#collectible-gifts
	DisallowPremiumGifts bool
	// Disallow the reception of gifts sent by channels.
	DisallowStargiftsFromChannels bool
}

// DisallowedGiftsSettingsTypeID is TL type id of DisallowedGiftsSettings.
const DisallowedGiftsSettingsTypeID = 0x71f276c4

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

func ( *DisallowedGiftsSettings) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.DisallowUnlimitedStargifts == false) {
		return false
	}
	if !(.DisallowLimitedStargifts == false) {
		return false
	}
	if !(.DisallowUniqueStargifts == false) {
		return false
	}
	if !(.DisallowPremiumGifts == false) {
		return false
	}
	if !(.DisallowStargiftsFromChannels == false) {
		return false
	}

	return true
}

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

// FillFrom fills DisallowedGiftsSettings from given interface.
func ( *DisallowedGiftsSettings) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
}) {
	.DisallowUnlimitedStargifts = .()
	.DisallowLimitedStargifts = .()
	.DisallowUniqueStargifts = .()
	.DisallowPremiumGifts = .()
	.DisallowStargiftsFromChannels = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *DisallowedGiftsSettings) () tdp.Type {
	 := tdp.Type{
		Name: "disallowedGiftsSettings",
		ID:   DisallowedGiftsSettingsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "DisallowUnlimitedStargifts",
			SchemaName: "disallow_unlimited_stargifts",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "DisallowLimitedStargifts",
			SchemaName: "disallow_limited_stargifts",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "DisallowUniqueStargifts",
			SchemaName: "disallow_unique_stargifts",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "DisallowPremiumGifts",
			SchemaName: "disallow_premium_gifts",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "DisallowStargiftsFromChannels",
			SchemaName: "disallow_stargifts_from_channels",
			Null:       !.Flags.Has(4),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *DisallowedGiftsSettings) () {
	if !(.DisallowUnlimitedStargifts == false) {
		.Flags.Set(0)
	}
	if !(.DisallowLimitedStargifts == false) {
		.Flags.Set(1)
	}
	if !(.DisallowUniqueStargifts == false) {
		.Flags.Set(2)
	}
	if !(.DisallowPremiumGifts == false) {
		.Flags.Set(3)
	}
	if !(.DisallowStargiftsFromChannels == false) {
		.Flags.Set(4)
	}
}

// Encode implements bin.Encoder.
func ( *DisallowedGiftsSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode disallowedGiftsSettings#71f276c4 as nil")
	}
	.PutID(DisallowedGiftsSettingsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *DisallowedGiftsSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode disallowedGiftsSettings#71f276c4 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode disallowedGiftsSettings#71f276c4: field flags: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *DisallowedGiftsSettings) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode disallowedGiftsSettings#71f276c4 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode disallowedGiftsSettings#71f276c4: field flags: %w", )
		}
	}
	.DisallowUnlimitedStargifts = .Flags.Has(0)
	.DisallowLimitedStargifts = .Flags.Has(1)
	.DisallowUniqueStargifts = .Flags.Has(2)
	.DisallowPremiumGifts = .Flags.Has(3)
	.DisallowStargiftsFromChannels = .Flags.Has(4)
	return nil
}

// SetDisallowUnlimitedStargifts sets value of DisallowUnlimitedStargifts conditional field.
func ( *DisallowedGiftsSettings) ( bool) {
	if  {
		.Flags.Set(0)
		.DisallowUnlimitedStargifts = true
	} else {
		.Flags.Unset(0)
		.DisallowUnlimitedStargifts = false
	}
}

// GetDisallowUnlimitedStargifts returns value of DisallowUnlimitedStargifts conditional field.
func ( *DisallowedGiftsSettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetDisallowLimitedStargifts sets value of DisallowLimitedStargifts conditional field.
func ( *DisallowedGiftsSettings) ( bool) {
	if  {
		.Flags.Set(1)
		.DisallowLimitedStargifts = true
	} else {
		.Flags.Unset(1)
		.DisallowLimitedStargifts = false
	}
}

// GetDisallowLimitedStargifts returns value of DisallowLimitedStargifts conditional field.
func ( *DisallowedGiftsSettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetDisallowUniqueStargifts sets value of DisallowUniqueStargifts conditional field.
func ( *DisallowedGiftsSettings) ( bool) {
	if  {
		.Flags.Set(2)
		.DisallowUniqueStargifts = true
	} else {
		.Flags.Unset(2)
		.DisallowUniqueStargifts = false
	}
}

// GetDisallowUniqueStargifts returns value of DisallowUniqueStargifts conditional field.
func ( *DisallowedGiftsSettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetDisallowPremiumGifts sets value of DisallowPremiumGifts conditional field.
func ( *DisallowedGiftsSettings) ( bool) {
	if  {
		.Flags.Set(3)
		.DisallowPremiumGifts = true
	} else {
		.Flags.Unset(3)
		.DisallowPremiumGifts = false
	}
}

// GetDisallowPremiumGifts returns value of DisallowPremiumGifts conditional field.
func ( *DisallowedGiftsSettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// SetDisallowStargiftsFromChannels sets value of DisallowStargiftsFromChannels conditional field.
func ( *DisallowedGiftsSettings) ( bool) {
	if  {
		.Flags.Set(4)
		.DisallowStargiftsFromChannels = true
	} else {
		.Flags.Unset(4)
		.DisallowStargiftsFromChannels = false
	}
}

// GetDisallowStargiftsFromChannels returns value of DisallowStargiftsFromChannels conditional field.
func ( *DisallowedGiftsSettings) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}