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

// PaymentsToggleChatStarGiftNotificationsRequest represents TL type `payments.toggleChatStarGiftNotifications#60eaefa1`.
// Enables or disables the reception of notifications every time a gift »¹ is received
// by the specified channel, can only be invoked by admins with post_messages admin
// rights².
//
// Links:
//  1. https://core.telegram.org/api/gifts
//  2. https://core.telegram.org/constructor/chatAdminRights
//
// See https://core.telegram.org/method/payments.toggleChatStarGiftNotifications for reference.
type PaymentsToggleChatStarGiftNotificationsRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to enable or disable reception of notifications in the form of
	// messageActionStarGiftUnique¹ and messageActionStarGift² service messages from the
	// channel.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/messageActionStarGiftUnique
	//  2) https://core.telegram.org/constructor/messageActionStarGift
	Enabled bool
	// The channel for which to receive or not receive notifications.
	Peer InputPeerClass
}

// PaymentsToggleChatStarGiftNotificationsRequestTypeID is TL type id of PaymentsToggleChatStarGiftNotificationsRequest.
const PaymentsToggleChatStarGiftNotificationsRequestTypeID = 0x60eaefa1

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

func ( *PaymentsToggleChatStarGiftNotificationsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Enabled == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsToggleChatStarGiftNotificationsRequest from given interface.
func ( *PaymentsToggleChatStarGiftNotificationsRequest) ( interface {
	() ( bool)
	() ( InputPeerClass)
}) {
	.Enabled = .()
	.Peer = .()
}

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

// TypeName returns name of type in TL schema.
func (*PaymentsToggleChatStarGiftNotificationsRequest) () string {
	return "payments.toggleChatStarGiftNotifications"
}

// TypeInfo returns info about TL type.
func ( *PaymentsToggleChatStarGiftNotificationsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.toggleChatStarGiftNotifications",
		ID:   PaymentsToggleChatStarGiftNotificationsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Enabled",
			SchemaName: "enabled",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *PaymentsToggleChatStarGiftNotificationsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.toggleChatStarGiftNotifications#60eaefa1 as nil")
	}
	.PutID(PaymentsToggleChatStarGiftNotificationsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsToggleChatStarGiftNotificationsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.toggleChatStarGiftNotifications#60eaefa1 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.toggleChatStarGiftNotifications#60eaefa1: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode payments.toggleChatStarGiftNotifications#60eaefa1: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.toggleChatStarGiftNotifications#60eaefa1: field peer: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PaymentsToggleChatStarGiftNotificationsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.toggleChatStarGiftNotifications#60eaefa1 to nil")
	}
	if  := .ConsumeID(PaymentsToggleChatStarGiftNotificationsRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode payments.toggleChatStarGiftNotifications#60eaefa1: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsToggleChatStarGiftNotificationsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.toggleChatStarGiftNotifications#60eaefa1 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.toggleChatStarGiftNotifications#60eaefa1: field flags: %w", )
		}
	}
	.Enabled = .Flags.Has(0)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode payments.toggleChatStarGiftNotifications#60eaefa1: field peer: %w", )
		}
		.Peer = 
	}
	return nil
}

// SetEnabled sets value of Enabled conditional field.
func ( *PaymentsToggleChatStarGiftNotificationsRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Enabled = true
	} else {
		.Flags.Unset(0)
		.Enabled = false
	}
}

// GetEnabled returns value of Enabled conditional field.
func ( *PaymentsToggleChatStarGiftNotificationsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetPeer returns value of Peer field.
func ( *PaymentsToggleChatStarGiftNotificationsRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// PaymentsToggleChatStarGiftNotifications invokes method payments.toggleChatStarGiftNotifications#60eaefa1 returning error if any.
// Enables or disables the reception of notifications every time a gift »¹ is received
// by the specified channel, can only be invoked by admins with post_messages admin
// rights².
//
// Links:
//  1. https://core.telegram.org/api/gifts
//  2. https://core.telegram.org/constructor/chatAdminRights
//
// Possible errors:
//
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/payments.toggleChatStarGiftNotifications for reference.
func ( *Client) ( context.Context,  *PaymentsToggleChatStarGiftNotificationsRequest) (bool, error) {
	var  BoolBox

	if  := .rpc.Invoke(, , &);  != nil {
		return false, 
	}
	,  := .Bool.(*BoolTrue)
	return , nil
}