// 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{} ) // SetGiftResalePriceRequest represents TL type `setGiftResalePrice#aabc698d`. type SetGiftResalePriceRequest struct { // Identifier of the unique gift ReceivedGiftID string // The new price for the unique gift; 0 or // getOption("gift_resale_star_count_min")-getOption("gift_resale_star_count_max"). Pass // 0 to disallow gift resale. ResaleStarCount int64 } // SetGiftResalePriceRequestTypeID is TL type id of SetGiftResalePriceRequest. const SetGiftResalePriceRequestTypeID = 0xaabc698d // Ensuring interfaces in compile-time for SetGiftResalePriceRequest. var ( _ bin.Encoder = &SetGiftResalePriceRequest{} _ bin.Decoder = &SetGiftResalePriceRequest{} _ bin.BareEncoder = &SetGiftResalePriceRequest{} _ bin.BareDecoder = &SetGiftResalePriceRequest{} ) func (s *SetGiftResalePriceRequest) Zero() bool { if s == nil { return true } if !(s.ReceivedGiftID == "") { return false } if !(s.ResaleStarCount == 0) { return false } return true } // String implements fmt.Stringer. func (s *SetGiftResalePriceRequest) String() string { if s == nil { return "SetGiftResalePriceRequest(nil)" } type Alias SetGiftResalePriceRequest return fmt.Sprintf("SetGiftResalePriceRequest%+v", Alias(*s)) } // TypeID returns type id in TL schema. // // See https://core.telegram.org/mtproto/TL-tl#remarks. func (*SetGiftResalePriceRequest) TypeID() uint32 { return SetGiftResalePriceRequestTypeID } // TypeName returns name of type in TL schema. func (*SetGiftResalePriceRequest) TypeName() string { return "setGiftResalePrice" } // TypeInfo returns info about TL type. func (s *SetGiftResalePriceRequest) TypeInfo() tdp.Type { typ := tdp.Type{ Name: "setGiftResalePrice", ID: SetGiftResalePriceRequestTypeID, } if s == nil { typ.Null = true return typ } typ.Fields = []tdp.Field{ { Name: "ReceivedGiftID", SchemaName: "received_gift_id", }, { Name: "ResaleStarCount", SchemaName: "resale_star_count", }, } return typ } // Encode implements bin.Encoder. func (s *SetGiftResalePriceRequest) Encode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode setGiftResalePrice#aabc698d as nil") } b.PutID(SetGiftResalePriceRequestTypeID) return s.EncodeBare(b) } // EncodeBare implements bin.BareEncoder. func (s *SetGiftResalePriceRequest) EncodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't encode setGiftResalePrice#aabc698d as nil") } b.PutString(s.ReceivedGiftID) b.PutInt53(s.ResaleStarCount) return nil } // Decode implements bin.Decoder. func (s *SetGiftResalePriceRequest) Decode(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode setGiftResalePrice#aabc698d to nil") } if err := b.ConsumeID(SetGiftResalePriceRequestTypeID); err != nil { return fmt.Errorf("unable to decode setGiftResalePrice#aabc698d: %w", err) } return s.DecodeBare(b) } // DecodeBare implements bin.BareDecoder. func (s *SetGiftResalePriceRequest) DecodeBare(b *bin.Buffer) error { if s == nil { return fmt.Errorf("can't decode setGiftResalePrice#aabc698d to nil") } { value, err := b.String() if err != nil { return fmt.Errorf("unable to decode setGiftResalePrice#aabc698d: field received_gift_id: %w", err) } s.ReceivedGiftID = value } { value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode setGiftResalePrice#aabc698d: field resale_star_count: %w", err) } s.ResaleStarCount = value } return nil } // EncodeTDLibJSON implements tdjson.TDLibEncoder. func (s *SetGiftResalePriceRequest) EncodeTDLibJSON(b tdjson.Encoder) error { if s == nil { return fmt.Errorf("can't encode setGiftResalePrice#aabc698d as nil") } b.ObjStart() b.PutID("setGiftResalePrice") b.Comma() b.FieldStart("received_gift_id") b.PutString(s.ReceivedGiftID) b.Comma() b.FieldStart("resale_star_count") b.PutInt53(s.ResaleStarCount) b.Comma() b.StripComma() b.ObjEnd() return nil } // DecodeTDLibJSON implements tdjson.TDLibDecoder. func (s *SetGiftResalePriceRequest) DecodeTDLibJSON(b tdjson.Decoder) error { if s == nil { return fmt.Errorf("can't decode setGiftResalePrice#aabc698d to nil") } return b.Obj(func(b tdjson.Decoder, key []byte) error { switch string(key) { case tdjson.TypeField: if err := b.ConsumeID("setGiftResalePrice"); err != nil { return fmt.Errorf("unable to decode setGiftResalePrice#aabc698d: %w", err) } case "received_gift_id": value, err := b.String() if err != nil { return fmt.Errorf("unable to decode setGiftResalePrice#aabc698d: field received_gift_id: %w", err) } s.ReceivedGiftID = value case "resale_star_count": value, err := b.Int53() if err != nil { return fmt.Errorf("unable to decode setGiftResalePrice#aabc698d: field resale_star_count: %w", err) } s.ResaleStarCount = value default: return b.Skip() } return nil }) } // GetReceivedGiftID returns value of ReceivedGiftID field. func (s *SetGiftResalePriceRequest) GetReceivedGiftID() (value string) { if s == nil { return } return s.ReceivedGiftID } // GetResaleStarCount returns value of ResaleStarCount field. func (s *SetGiftResalePriceRequest) GetResaleStarCount() (value int64) { if s == nil { return } return s.ResaleStarCount } // SetGiftResalePrice invokes method setGiftResalePrice#aabc698d returning error if any. func (c *Client) SetGiftResalePrice(ctx context.Context, request *SetGiftResalePriceRequest) error { var ok Ok if err := c.rpc.Invoke(ctx, request, &ok); err != nil { return err } return nil }