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

// PaymentsCanPurchasePremiumRequest represents TL type `payments.canPurchasePremium#9fc19eb6`.
// Checks whether Telegram Premium purchase is possible. Must be called before in-store
// Premium purchase, official apps only.
//
// See https://core.telegram.org/method/payments.canPurchasePremium for reference.
type PaymentsCanPurchasePremiumRequest struct {
	// Payment purpose
	Purpose InputStorePaymentPurposeClass
}

// PaymentsCanPurchasePremiumRequestTypeID is TL type id of PaymentsCanPurchasePremiumRequest.
const PaymentsCanPurchasePremiumRequestTypeID = 0x9fc19eb6

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

func ( *PaymentsCanPurchasePremiumRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Purpose == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsCanPurchasePremiumRequest from given interface.
func ( *PaymentsCanPurchasePremiumRequest) ( interface {
	() ( InputStorePaymentPurposeClass)
}) {
	.Purpose = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsCanPurchasePremiumRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.canPurchasePremium",
		ID:   PaymentsCanPurchasePremiumRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Purpose",
			SchemaName: "purpose",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PaymentsCanPurchasePremiumRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.canPurchasePremium#9fc19eb6 as nil")
	}
	.PutID(PaymentsCanPurchasePremiumRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsCanPurchasePremiumRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.canPurchasePremium#9fc19eb6 as nil")
	}
	if .Purpose == nil {
		return fmt.Errorf("unable to encode payments.canPurchasePremium#9fc19eb6: field purpose is nil")
	}
	if  := .Purpose.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.canPurchasePremium#9fc19eb6: field purpose: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsCanPurchasePremiumRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.canPurchasePremium#9fc19eb6 to nil")
	}
	{
		,  := DecodeInputStorePaymentPurpose()
		if  != nil {
			return fmt.Errorf("unable to decode payments.canPurchasePremium#9fc19eb6: field purpose: %w", )
		}
		.Purpose = 
	}
	return nil
}

// GetPurpose returns value of Purpose field.
func ( *PaymentsCanPurchasePremiumRequest) () ( InputStorePaymentPurposeClass) {
	if  == nil {
		return
	}
	return .Purpose
}

// PaymentsCanPurchasePremium invokes method payments.canPurchasePremium#9fc19eb6 returning error if any.
// Checks whether Telegram Premium purchase is possible. Must be called before in-store
// Premium purchase, official apps only.
//
// See https://core.telegram.org/method/payments.canPurchasePremium for reference.
func ( *Client) ( context.Context,  InputStorePaymentPurposeClass) (bool, error) {
	var  BoolBox

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