// Code generated by gotdgen, DO NOT EDIT. package tdapi import ( "context" "errors" "fmt" "sort" "strings" "go.uber.org/multierr" "go.mau.fi/mautrix-telegram/pkg/gotd/bin" "go.mau.fi/mautrix-telegram/pkg/gotd/tdjson" "go.mau.fi/mautrix-telegram/pkg/gotd/tdp" "go.mau.fi/mautrix-telegram/pkg/gotd/tgerr" ) // 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{} ) // CheckAuthenticationPremiumPurchaseRequest represents TL type `checkAuthenticationPremiumPurchase#5eb59abe`. type CheckAuthenticationPremiumPurchaseRequest struct { // ISO 4217 currency code of the payment currency Currency string // Paid amount, in the smallest units of the currency Amount int64 } // CheckAuthenticationPremiumPurchaseRequestTypeID is TL type id of CheckAuthenticationPremiumPurchaseRequest. const CheckAuthenticationPremiumPurchaseRequestTypeID = 0x5eb59abe // Ensuring interfaces in compile-time for CheckAuthenticationPremiumPurchaseRequest. var ( _ bin.Encoder = &CheckAuthenticationPremiumPurchaseRequest{} _ bin.Decoder = &CheckAuthenticationPremiumPurchaseRequest{} _ bin.BareEncoder = &CheckAuthenticationPremiumPurchaseRequest{} _ bin.BareDecoder = &CheckAuthenticationPremiumPurchaseRequest{} ) func (c *CheckAuthenticationPremiumPurchaseRequest) Zero() bool { if c == nil { return true } if !(c.Currency == "") { return false } if !(c.Amount == 0) { return false } return true } // String implements fmt.Stringer. func (c *CheckAuthenticationPremiumPurchaseRequest) String() string { if c == nil { return "CheckAuthenticationPremiumPurchaseRequest(nil)" } type Alias CheckAuthenticationPremiumPurchaseRequest return fmt.Sprintf("CheckAuthenticationPremiumPurchaseRequest%+v", Alias(*c)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*CheckAuthenticationPremiumPurchaseRequest) TypeID() uint32 { return CheckAuthenticationPremiumPurchaseRequestTypeID } // TypeName returns name of type in TL schema. func (*CheckAuthenticationPremiumPurchaseRequest) TypeName() string { return "checkAuthenticationPremiumPurchase" } // TypeInfo returns info about TL type. func (c *CheckAuthenticationPremiumPurchaseRequest) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "checkAuthenticationPremiumPurchase", ID: CheckAuthenticationPremiumPurchaseRequestTypeID, } if c == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "Currency", SchemaName: "currency", }, { Name: "Amount", SchemaName: "amount", }, } return typ } // Encode implements bin.Encoder. func (c *CheckAuthenticationPremiumPurchaseRequest) Encode(b *bin.Buffer) error { if c == nil { return fmt.Errorf("can't encode checkAuthenticationPremiumPurchase#5eb59abe as nil") } b.PutID(CheckAuthenticationPremiumPurchaseRequestTypeID) return c.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (c *CheckAuthenticationPremiumPurchaseRequest) EncodeBare(b *bin.Buffer) error { if c == nil { return fmt.Errorf("can't encode checkAuthenticationPremiumPurchase#5eb59abe as nil") } b.PutString(c.Currency) b.PutInt53(c.Amount) return nil } // Decode implements bin.Decoder. func (c *CheckAuthenticationPremiumPurchaseRequest) Decode(b *bin.Buffer) error { if c == nil { return fmt.Errorf("can't decode checkAuthenticationPremiumPurchase#5eb59abe to nil") } if err := b.ConsumeID(CheckAuthenticationPremiumPurchaseRequestTypeID); err != nil { return fmt.Errorf("unable to decode checkAuthenticationPremiumPurchase#5eb59abe: %w", err) } return c.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (c *CheckAuthenticationPremiumPurchaseRequest) DecodeBare(b *bin.Buffer) error { if c == nil { return fmt.Errorf("can't decode checkAuthenticationPremiumPurchase#5eb59abe to nil") } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode checkAuthenticationPremiumPurchase#5eb59abe: field currency: %w", err) } c.Currency = value } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode checkAuthenticationPremiumPurchase#5eb59abe: field amount: %w", err) } c.Amount = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (c *CheckAuthenticationPremiumPurchaseRequest) EncodeTDLibJSON(b tdjson.Encoder) error { if c == nil { return fmt.Errorf("can't encode checkAuthenticationPremiumPurchase#5eb59abe as nil") } b.ObjStart() b.PutID("checkAuthenticationPremiumPurchase") b.Comma() b.FieldStart("currency") b.PutString(c.Currency) b.Comma() b.FieldStart("amount") b.PutInt53(c.Amount) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (c *CheckAuthenticationPremiumPurchaseRequest) DecodeTDLibJSON(b tdjson.Decoder) error { if c == nil { return fmt.Errorf("can't decode checkAuthenticationPremiumPurchase#5eb59abe to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("checkAuthenticationPremiumPurchase"); err != nil { return fmt.Errorf("unable to decode checkAuthenticationPremiumPurchase#5eb59abe: %w", err) } case "currency": value, err := b.String() if err != nil { return fmt.Errorf("unable to decode checkAuthenticationPremiumPurchase#5eb59abe: field currency: %w", err) } c.Currency = value case "amount": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode checkAuthenticationPremiumPurchase#5eb59abe: field amount: %w", err) } c.Amount = value default: return b.Skip() } return nil }) } // GetCurrency returns value of Currency field. func (c *CheckAuthenticationPremiumPurchaseRequest) GetCurrency() (value string) { if c == nil { return } return c.Currency } // GetAmount returns value of Amount field. func (c *CheckAuthenticationPremiumPurchaseRequest) GetAmount() (value int64) { if c == nil { return } return c.Amount } // CheckAuthenticationPremiumPurchase invokes method checkAuthenticationPremiumPurchase#5eb59abe returning error if any. func (c *Client) CheckAuthenticationPremiumPurchase(ctx context.Context, request *CheckAuthenticationPremiumPurchaseRequest) error { var ok Ok if err := c.rpc.Invoke(ctx, request, &ok); err != nil { return err } return nil }