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