// 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{} ) // GetStatisticalGraphRequest represents TL type `getStatisticalGraph#419f8d9b`. type GetStatisticalGraphRequest struct { // Chat identifier ChatID int64 // The token for graph loading Token string // X-value for zoomed in graph or 0 otherwise X int64 } // GetStatisticalGraphRequestTypeID is TL type id of GetStatisticalGraphRequest. const GetStatisticalGraphRequestTypeID = 0x419f8d9b // Ensuring interfaces in compile-time for GetStatisticalGraphRequest. var ( _ bin.Encoder = &GetStatisticalGraphRequest{} _ bin.Decoder = &GetStatisticalGraphRequest{} _ bin.BareEncoder = &GetStatisticalGraphRequest{} _ bin.BareDecoder = &GetStatisticalGraphRequest{} ) func (g *GetStatisticalGraphRequest) Zero() bool { if g == nil { return true } if !(g.ChatID == 0) { return false } if !(g.Token == "") { return false } if !(g.X == 0) { return false } return true } // String implements fmt.Stringer. func (g *GetStatisticalGraphRequest) String() string { if g == nil { return "GetStatisticalGraphRequest(nil)" } type Alias GetStatisticalGraphRequest return fmt.Sprintf("GetStatisticalGraphRequest%+v", Alias(*g)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*GetStatisticalGraphRequest) TypeID() uint32 { return GetStatisticalGraphRequestTypeID } // TypeName returns name of type in TL schema. func (*GetStatisticalGraphRequest) TypeName() string { return "getStatisticalGraph" } // TypeInfo returns info about TL type. func (g *GetStatisticalGraphRequest) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "getStatisticalGraph", ID: GetStatisticalGraphRequestTypeID, } if g == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ChatID", SchemaName: "chat_id", }, { Name: "Token", SchemaName: "token", }, { Name: "X", SchemaName: "x", }, } return typ } // Encode implements bin.Encoder. func (g *GetStatisticalGraphRequest) Encode(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't encode getStatisticalGraph#419f8d9b as nil") } b.PutID(GetStatisticalGraphRequestTypeID) return g.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (g *GetStatisticalGraphRequest) EncodeBare(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't encode getStatisticalGraph#419f8d9b as nil") } b.PutInt53(g.ChatID) b.PutString(g.Token) b.PutInt53(g.X) return nil } // Decode implements bin.Decoder. func (g *GetStatisticalGraphRequest) Decode(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't decode getStatisticalGraph#419f8d9b to nil") } if err := b.ConsumeID(GetStatisticalGraphRequestTypeID); err != nil { return fmt.Errorf("unable to decode getStatisticalGraph#419f8d9b: %w", err) } return g.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (g *GetStatisticalGraphRequest) DecodeBare(b *bin.Buffer) error { if g == nil { return fmt.Errorf("can't decode getStatisticalGraph#419f8d9b to nil") } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode getStatisticalGraph#419f8d9b: field chat_id: %w", err) } g.ChatID = value } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode getStatisticalGraph#419f8d9b: field token: %w", err) } g.Token = value } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode getStatisticalGraph#419f8d9b: field x: %w", err) } g.X = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (g *GetStatisticalGraphRequest) EncodeTDLibJSON(b tdjson.Encoder) error { if g == nil { return fmt.Errorf("can't encode getStatisticalGraph#419f8d9b as nil") } b.ObjStart() b.PutID("getStatisticalGraph") b.Comma() b.FieldStart("chat_id") b.PutInt53(g.ChatID) b.Comma() b.FieldStart("token") b.PutString(g.Token) b.Comma() b.FieldStart("x") b.PutInt53(g.X) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (g *GetStatisticalGraphRequest) DecodeTDLibJSON(b tdjson.Decoder) error { if g == nil { return fmt.Errorf("can't decode getStatisticalGraph#419f8d9b to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("getStatisticalGraph"); err != nil { return fmt.Errorf("unable to decode getStatisticalGraph#419f8d9b: %w", err) } case "chat_id": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode getStatisticalGraph#419f8d9b: field chat_id: %w", err) } g.ChatID = value case "token": value, err := b.String() if err != nil { return fmt.Errorf("unable to decode getStatisticalGraph#419f8d9b: field token: %w", err) } g.Token = value case "x": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode getStatisticalGraph#419f8d9b: field x: %w", err) } g.X = value default: return b.Skip() } return nil }) } // GetChatID returns value of ChatID field. func (g *GetStatisticalGraphRequest) GetChatID() (value int64) { if g == nil { return } return g.ChatID } // GetToken returns value of Token field. func (g *GetStatisticalGraphRequest) GetToken() (value string) { if g == nil { return } return g.Token } // GetX returns value of X field. func (g *GetStatisticalGraphRequest) GetX() (value int64) { if g == nil { return } return g.X } // GetStatisticalGraph invokes method getStatisticalGraph#419f8d9b returning error if any. func (c *Client) GetStatisticalGraph(ctx context.Context, request *GetStatisticalGraphRequest) (StatisticalGraphClass, error) { var result StatisticalGraphBox if err := c.rpc.Invoke(ctx, request, &result); err != nil { return nil, err } return result.StatisticalGraph, nil }