// Code generated by gotdgen, DO NOT EDIT. package tg 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{} ) // PaymentsGetStarsStatusRequest represents TL type `payments.getStarsStatus#104fcfa7`. // Get the current Telegram Stars balance¹ of the current account (with // peer=inputPeerSelf²), or the stars balance of the bot specified in peer. // // Links: // 1. https://core.telegram.org/api/stars // 2. https://core.telegram.org/constructor/inputPeerSelf // // See https://core.telegram.org/method/payments.getStarsStatus for reference. type PaymentsGetStarsStatusRequest struct { // Peer of which to get the balance. Peer InputPeerClass } // PaymentsGetStarsStatusRequestTypeID is TL type id of PaymentsGetStarsStatusRequest. const PaymentsGetStarsStatusRequestTypeID = 0x104fcfa7 // Ensuring interfaces in compile-time for PaymentsGetStarsStatusRequest. var ( _ bin.Encoder = &PaymentsGetStarsStatusRequest{} _ bin.Decoder = &PaymentsGetStarsStatusRequest{} _ bin.BareEncoder = &PaymentsGetStarsStatusRequest{} _ bin.BareDecoder = &PaymentsGetStarsStatusRequest{} ) func (g *PaymentsGetStarsStatusRequest) Zero() bool { if g == nil { return true } if !(g.Peer == nil) { return false } return true } // String implements fmt.Stringer. func (g *PaymentsGetStarsStatusRequest) String() string { if g == nil { return "PaymentsGetStarsStatusRequest(nil)" } type Alias PaymentsGetStarsStatusRequest return fmt.Sprintf("PaymentsGetStarsStatusRequest%+v", Alias(*g)) } // FillFrom fills PaymentsGetStarsStatusRequest from given interface. func (g *PaymentsGetStarsStatusRequest) FillFrom(from interface { GetPeer() (value InputPeerClass) }) { g.Peer = from.GetPeer() } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*PaymentsGetStarsStatusRequest) TypeID() uint32 { return PaymentsGetStarsStatusRequestTypeID } // TypeName returns name of type in TL schema. func (*PaymentsGetStarsStatusRequest) TypeName() string { return "payments.getStarsStatus" } // TypeInfo returns info about TL type. func (g *PaymentsGetStarsStatusRequest) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "payments.getStarsStatus", ID: PaymentsGetStarsStatusRequestTypeID, } if g == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "Peer", SchemaName: "peer", }, } return typ } // Encode implements bin.Encoder. func (g *PaymentsGetStarsStatusRequest) Encode(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't encode payments.getStarsStatus#104fcfa7 as nil") } b.PutID(PaymentsGetStarsStatusRequestTypeID) return g.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (g *PaymentsGetStarsStatusRequest) EncodeBare(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't encode payments.getStarsStatus#104fcfa7 as nil") } if g.Peer == nil { return fmt.Errorf("unable to encode payments.getStarsStatus#104fcfa7: field peer is nil") } if err := g.Peer.Encode(b); err != nil { return fmt.Errorf("unable to encode payments.getStarsStatus#104fcfa7: field peer: %w", err) } return nil } // Decode implements bin.Decoder. func (g *PaymentsGetStarsStatusRequest) Decode(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't decode payments.getStarsStatus#104fcfa7 to nil") } if err := b.ConsumeID(PaymentsGetStarsStatusRequestTypeID); err != nil { return fmt.Errorf("unable to decode payments.getStarsStatus#104fcfa7: %w", err) } return g.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (g *PaymentsGetStarsStatusRequest) DecodeBare(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't decode payments.getStarsStatus#104fcfa7 to nil") } { value, err := DecodeInputPeer(b) if err != nil { return fmt.Errorf("unable to decode payments.getStarsStatus#104fcfa7: field peer: %w", err) } g.Peer = value } return nil } // GetPeer returns value of Peer field. func (g *PaymentsGetStarsStatusRequest) GetPeer() (value InputPeerClass) { if g == nil { return } return g.Peer } // PaymentsGetStarsStatus invokes method payments.getStarsStatus#104fcfa7 returning error if any. // Get the current Telegram Stars balance¹ of the current account (with // peer=inputPeerSelf²), or the stars balance of the bot specified in peer. // // Links: // 1. https://core.telegram.org/api/stars // 2. https://core.telegram.org/constructor/inputPeerSelf // // Possible errors: // // 400 PEER_ID_INVALID: The provided peer id is invalid. // // See https://core.telegram.org/method/payments.getStarsStatus for reference. func (c *Client) PaymentsGetStarsStatus(ctx context.Context, peer InputPeerClass) (*PaymentsStarsStatus, error) { var result PaymentsStarsStatus request := &PaymentsGetStarsStatusRequest{ Peer: peer, } if err := c.rpc.Invoke(ctx, request, &result); err != nil { return nil, err } return &result, nil }