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

// PaymentsChangeStarsSubscriptionRequest represents TL type `payments.changeStarsSubscription#c7770878`.
// Activate or deactivate a Telegram Star subscription »¹.
//
// Links:
//  1. https://core.telegram.org/api/invites#paid-invite-links
//
// See https://core.telegram.org/method/payments.changeStarsSubscription for reference.
type PaymentsChangeStarsSubscriptionRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Always pass inputPeerSelf¹.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/inputPeerSelf
	Peer InputPeerClass
	// ID of the subscription.
	SubscriptionID string
	// Whether to cancel or reactivate the subscription.
	//
	// Use SetCanceled and GetCanceled helpers.
	Canceled bool
}

// PaymentsChangeStarsSubscriptionRequestTypeID is TL type id of PaymentsChangeStarsSubscriptionRequest.
const PaymentsChangeStarsSubscriptionRequestTypeID = 0xc7770878

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

func ( *PaymentsChangeStarsSubscriptionRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.SubscriptionID == "") {
		return false
	}
	if !(.Canceled == false) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsChangeStarsSubscriptionRequest from given interface.
func ( *PaymentsChangeStarsSubscriptionRequest) ( interface {
	() ( InputPeerClass)
	() ( string)
	() ( bool,  bool)
}) {
	.Peer = .()
	.SubscriptionID = .()
	if ,  := .();  {
		.Canceled = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsChangeStarsSubscriptionRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.changeStarsSubscription",
		ID:   PaymentsChangeStarsSubscriptionRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "SubscriptionID",
			SchemaName: "subscription_id",
		},
		{
			Name:       "Canceled",
			SchemaName: "canceled",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *PaymentsChangeStarsSubscriptionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.changeStarsSubscription#c7770878 as nil")
	}
	.PutID(PaymentsChangeStarsSubscriptionRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsChangeStarsSubscriptionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.changeStarsSubscription#c7770878 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.changeStarsSubscription#c7770878: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode payments.changeStarsSubscription#c7770878: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.changeStarsSubscription#c7770878: field peer: %w", )
	}
	.PutString(.SubscriptionID)
	if .Flags.Has(0) {
		.PutBool(.Canceled)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsChangeStarsSubscriptionRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.changeStarsSubscription#c7770878 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.changeStarsSubscription#c7770878: field flags: %w", )
		}
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode payments.changeStarsSubscription#c7770878: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.changeStarsSubscription#c7770878: field subscription_id: %w", )
		}
		.SubscriptionID = 
	}
	if .Flags.Has(0) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode payments.changeStarsSubscription#c7770878: field canceled: %w", )
		}
		.Canceled = 
	}
	return nil
}

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

// GetSubscriptionID returns value of SubscriptionID field.
func ( *PaymentsChangeStarsSubscriptionRequest) () ( string) {
	if  == nil {
		return
	}
	return .SubscriptionID
}

// SetCanceled sets value of Canceled conditional field.
func ( *PaymentsChangeStarsSubscriptionRequest) ( bool) {
	.Flags.Set(0)
	.Canceled = 
}

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

// PaymentsChangeStarsSubscription invokes method payments.changeStarsSubscription#c7770878 returning error if any.
// Activate or deactivate a Telegram Star subscription »¹.
//
// Links:
//  1. https://core.telegram.org/api/invites#paid-invite-links
//
// Possible errors:
//
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/payments.changeStarsSubscription for reference.
func ( *Client) ( context.Context,  *PaymentsChangeStarsSubscriptionRequest) (bool, error) {
	var  BoolBox

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