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

// PaymentsCanPurchaseStoreRequest represents TL type `payments.canPurchaseStore#4fdc5ea7`.
// Checks whether a purchase is possible. Must be called before in-store purchase,
// official apps only.
//
// See https://core.telegram.org/method/payments.canPurchaseStore for reference.
type PaymentsCanPurchaseStoreRequest struct {
	// Payment purpose.
	Purpose InputStorePaymentPurposeClass
}

// PaymentsCanPurchaseStoreRequestTypeID is TL type id of PaymentsCanPurchaseStoreRequest.
const PaymentsCanPurchaseStoreRequestTypeID = 0x4fdc5ea7

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *PaymentsCanPurchaseStoreRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.canPurchaseStore#4fdc5ea7 as nil")
	}
	.PutID(PaymentsCanPurchaseStoreRequestTypeID)
	return .EncodeBare()
}

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

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

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

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

// PaymentsCanPurchaseStore invokes method payments.canPurchaseStore#4fdc5ea7 returning error if any.
// Checks whether a purchase is possible. Must be called before in-store purchase,
// official apps only.
//
// Possible errors:
//
//	400 INPUT_PURPOSE_INVALID: The specified payment purpose is invalid.
//	406 PREMIUM_CURRENTLY_UNAVAILABLE: You cannot currently purchase a Premium subscription.
//
// See https://core.telegram.org/method/payments.canPurchaseStore for reference.
func ( *Client) ( context.Context,  InputStorePaymentPurposeClass) (bool, error) {
	var  BoolBox

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