// 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{} ) // GetUserChatBoostsRequest represents TL type `getUserChatBoosts#b90ee799`. type GetUserChatBoostsRequest struct { // Identifier of the chat ChatID int64 // Identifier of the user UserID int64 } // GetUserChatBoostsRequestTypeID is TL type id of GetUserChatBoostsRequest. const GetUserChatBoostsRequestTypeID = 0xb90ee799 // Ensuring interfaces in compile-time for GetUserChatBoostsRequest. var ( _ bin.Encoder = &GetUserChatBoostsRequest{} _ bin.Decoder = &GetUserChatBoostsRequest{} _ bin.BareEncoder = &GetUserChatBoostsRequest{} _ bin.BareDecoder = &GetUserChatBoostsRequest{} ) func (g *GetUserChatBoostsRequest) Zero() bool { if g == nil { return true } if !(g.ChatID == 0) { return false } if !(g.UserID == 0) { return false } return true } // String implements fmt.Stringer. func (g *GetUserChatBoostsRequest) String() string { if g == nil { return "GetUserChatBoostsRequest(nil)" } type Alias GetUserChatBoostsRequest return fmt.Sprintf("GetUserChatBoostsRequest%+v", Alias(*g)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*GetUserChatBoostsRequest) TypeID() uint32 { return GetUserChatBoostsRequestTypeID } // TypeName returns name of type in TL schema. func (*GetUserChatBoostsRequest) TypeName() string { return "getUserChatBoosts" } // TypeInfo returns info about TL type. func (g *GetUserChatBoostsRequest) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "getUserChatBoosts", ID: GetUserChatBoostsRequestTypeID, } if g == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ChatID", SchemaName: "chat_id", }, { Name: "UserID", SchemaName: "user_id", }, } return typ } // Encode implements bin.Encoder. func (g *GetUserChatBoostsRequest) Encode(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't encode getUserChatBoosts#b90ee799 as nil") } b.PutID(GetUserChatBoostsRequestTypeID) return g.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (g *GetUserChatBoostsRequest) EncodeBare(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't encode getUserChatBoosts#b90ee799 as nil") } b.PutInt53(g.ChatID) b.PutInt53(g.UserID) return nil } // Decode implements bin.Decoder. func (g *GetUserChatBoostsRequest) Decode(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't decode getUserChatBoosts#b90ee799 to nil") } if err := b.ConsumeID(GetUserChatBoostsRequestTypeID); err != nil { return fmt.Errorf("unable to decode getUserChatBoosts#b90ee799: %w", err) } return g.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (g *GetUserChatBoostsRequest) DecodeBare(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't decode getUserChatBoosts#b90ee799 to nil") } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode getUserChatBoosts#b90ee799: field chat_id: %w", err) } g.ChatID = value } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode getUserChatBoosts#b90ee799: field user_id: %w", err) } g.UserID = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (g *GetUserChatBoostsRequest) EncodeTDLibJSON(b tdjson.Encoder) error { if g == nil { return fmt.Errorf("can't encode getUserChatBoosts#b90ee799 as nil") } b.ObjStart() b.PutID("getUserChatBoosts") b.Comma() b.FieldStart("chat_id") b.PutInt53(g.ChatID) b.Comma() b.FieldStart("user_id") b.PutInt53(g.UserID) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (g *GetUserChatBoostsRequest) DecodeTDLibJSON(b tdjson.Decoder) error { if g == nil { return fmt.Errorf("can't decode getUserChatBoosts#b90ee799 to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("getUserChatBoosts"); err != nil { return fmt.Errorf("unable to decode getUserChatBoosts#b90ee799: %w", err) } case "chat_id": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode getUserChatBoosts#b90ee799: field chat_id: %w", err) } g.ChatID = value case "user_id": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode getUserChatBoosts#b90ee799: field user_id: %w", err) } g.UserID = value default: return b.Skip() } return nil }) } // GetChatID returns value of ChatID field. func (g *GetUserChatBoostsRequest) GetChatID() (value int64) { if g == nil { return } return g.ChatID } // GetUserID returns value of UserID field. func (g *GetUserChatBoostsRequest) GetUserID() (value int64) { if g == nil { return } return g.UserID } // GetUserChatBoosts invokes method getUserChatBoosts#b90ee799 returning error if any. func (c *Client) GetUserChatBoosts(ctx context.Context, request *GetUserChatBoostsRequest) (*FoundChatBoosts, error) { var result FoundChatBoosts if err := c.rpc.Invoke(ctx, request, &result); err != nil { return nil, err } return &result, nil }