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

// PaymentsExportInvoiceRequest represents TL type `payments.exportInvoice#f91b065`.
// Generate an invoice deep linkĀ¹
//
// Links:
//  1. https://core.telegram.org/api/links#invoice-links
//
// See https://core.telegram.org/method/payments.exportInvoice for reference.
type PaymentsExportInvoiceRequest struct {
	// Invoice
	InvoiceMedia InputMediaClass
}

// PaymentsExportInvoiceRequestTypeID is TL type id of PaymentsExportInvoiceRequest.
const PaymentsExportInvoiceRequestTypeID = 0xf91b065

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

func ( *PaymentsExportInvoiceRequest) () bool {
	if  == nil {
		return true
	}
	if !(.InvoiceMedia == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsExportInvoiceRequest from given interface.
func ( *PaymentsExportInvoiceRequest) ( interface {
	() ( InputMediaClass)
}) {
	.InvoiceMedia = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsExportInvoiceRequest) () tdp.Type {
	 := tdp.Type{
		Name: "payments.exportInvoice",
		ID:   PaymentsExportInvoiceRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "InvoiceMedia",
			SchemaName: "invoice_media",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PaymentsExportInvoiceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.exportInvoice#f91b065 as nil")
	}
	.PutID(PaymentsExportInvoiceRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsExportInvoiceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.exportInvoice#f91b065 as nil")
	}
	if .InvoiceMedia == nil {
		return fmt.Errorf("unable to encode payments.exportInvoice#f91b065: field invoice_media is nil")
	}
	if  := .InvoiceMedia.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.exportInvoice#f91b065: field invoice_media: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsExportInvoiceRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.exportInvoice#f91b065 to nil")
	}
	{
		,  := DecodeInputMedia()
		if  != nil {
			return fmt.Errorf("unable to decode payments.exportInvoice#f91b065: field invoice_media: %w", )
		}
		.InvoiceMedia = 
	}
	return nil
}

// GetInvoiceMedia returns value of InvoiceMedia field.
func ( *PaymentsExportInvoiceRequest) () ( InputMediaClass) {
	if  == nil {
		return
	}
	return .InvoiceMedia
}

// PaymentsExportInvoice invokes method payments.exportInvoice#f91b065 returning error if any.
// Generate an invoice deep linkĀ¹
//
// Links:
//  1. https://core.telegram.org/api/links#invoice-links
//
// Possible errors:
//
//	400 CURRENCY_TOTAL_AMOUNT_INVALID: The total amount of all prices is invalid.
//	400 INVOICE_PAYLOAD_INVALID: The specified invoice payload is invalid.
//	400 MEDIA_INVALID: Media invalid.
//	400 PAYMENT_PROVIDER_INVALID: The specified payment provider is invalid.
//
// See https://core.telegram.org/method/payments.exportInvoice for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  InputMediaClass) (*PaymentsExportedInvoice, error) {
	var  PaymentsExportedInvoice

	 := &PaymentsExportInvoiceRequest{
		InvoiceMedia: ,
	}
	if  := .rpc.Invoke(, , &);  != nil {
		return nil, 
	}
	return &, nil
}