/
tl_account_update_theme_gen.go
409 lines (373 loc) · 9.95 KB
/
tl_account_update_theme_gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
// Code generated by gotdgen, DO NOT EDIT.
package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdp"
"github.com/gotd/td/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{}
)
// AccountUpdateThemeRequest represents TL type `account.updateTheme#5cb367d5`.
// Update theme
//
// See https://core.telegram.org/method/account.updateTheme for reference.
type AccountUpdateThemeRequest struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Theme format, a string that identifies the theming engines supported by the client
Format string
// Theme to update
Theme InputThemeClass
// Unique theme ID
//
// Use SetSlug and GetSlug helpers.
Slug string
// Theme name
//
// Use SetTitle and GetTitle helpers.
Title string
// Theme file
//
// Use SetDocument and GetDocument helpers.
Document InputDocumentClass
// Theme settings
//
// Use SetSettings and GetSettings helpers.
Settings InputThemeSettings
}
// AccountUpdateThemeRequestTypeID is TL type id of AccountUpdateThemeRequest.
const AccountUpdateThemeRequestTypeID = 0x5cb367d5
// Ensuring interfaces in compile-time for AccountUpdateThemeRequest.
var (
_ bin.Encoder = &AccountUpdateThemeRequest{}
_ bin.Decoder = &AccountUpdateThemeRequest{}
_ bin.BareEncoder = &AccountUpdateThemeRequest{}
_ bin.BareDecoder = &AccountUpdateThemeRequest{}
)
func (u *AccountUpdateThemeRequest) Zero() bool {
if u == nil {
return true
}
if !(u.Flags.Zero()) {
return false
}
if !(u.Format == "") {
return false
}
if !(u.Theme == nil) {
return false
}
if !(u.Slug == "") {
return false
}
if !(u.Title == "") {
return false
}
if !(u.Document == nil) {
return false
}
if !(u.Settings.Zero()) {
return false
}
return true
}
// String implements fmt.Stringer.
func (u *AccountUpdateThemeRequest) String() string {
if u == nil {
return "AccountUpdateThemeRequest(nil)"
}
type Alias AccountUpdateThemeRequest
return fmt.Sprintf("AccountUpdateThemeRequest%+v", Alias(*u))
}
// FillFrom fills AccountUpdateThemeRequest from given interface.
func (u *AccountUpdateThemeRequest) FillFrom(from interface {
GetFormat() (value string)
GetTheme() (value InputThemeClass)
GetSlug() (value string, ok bool)
GetTitle() (value string, ok bool)
GetDocument() (value InputDocumentClass, ok bool)
GetSettings() (value InputThemeSettings, ok bool)
}) {
u.Format = from.GetFormat()
u.Theme = from.GetTheme()
if val, ok := from.GetSlug(); ok {
u.Slug = val
}
if val, ok := from.GetTitle(); ok {
u.Title = val
}
if val, ok := from.GetDocument(); ok {
u.Document = val
}
if val, ok := from.GetSettings(); ok {
u.Settings = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*AccountUpdateThemeRequest) TypeID() uint32 {
return AccountUpdateThemeRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*AccountUpdateThemeRequest) TypeName() string {
return "account.updateTheme"
}
// TypeInfo returns info about TL type.
func (u *AccountUpdateThemeRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "account.updateTheme",
ID: AccountUpdateThemeRequestTypeID,
}
if u == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Format",
SchemaName: "format",
},
{
Name: "Theme",
SchemaName: "theme",
},
{
Name: "Slug",
SchemaName: "slug",
Null: !u.Flags.Has(0),
},
{
Name: "Title",
SchemaName: "title",
Null: !u.Flags.Has(1),
},
{
Name: "Document",
SchemaName: "document",
Null: !u.Flags.Has(2),
},
{
Name: "Settings",
SchemaName: "settings",
Null: !u.Flags.Has(3),
},
}
return typ
}
// Encode implements bin.Encoder.
func (u *AccountUpdateThemeRequest) Encode(b *bin.Buffer) error {
if u == nil {
return fmt.Errorf("can't encode account.updateTheme#5cb367d5 as nil")
}
b.PutID(AccountUpdateThemeRequestTypeID)
return u.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (u *AccountUpdateThemeRequest) EncodeBare(b *bin.Buffer) error {
if u == nil {
return fmt.Errorf("can't encode account.updateTheme#5cb367d5 as nil")
}
if !(u.Slug == "") {
u.Flags.Set(0)
}
if !(u.Title == "") {
u.Flags.Set(1)
}
if !(u.Document == nil) {
u.Flags.Set(2)
}
if !(u.Settings.Zero()) {
u.Flags.Set(3)
}
if err := u.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode account.updateTheme#5cb367d5: field flags: %w", err)
}
b.PutString(u.Format)
if u.Theme == nil {
return fmt.Errorf("unable to encode account.updateTheme#5cb367d5: field theme is nil")
}
if err := u.Theme.Encode(b); err != nil {
return fmt.Errorf("unable to encode account.updateTheme#5cb367d5: field theme: %w", err)
}
if u.Flags.Has(0) {
b.PutString(u.Slug)
}
if u.Flags.Has(1) {
b.PutString(u.Title)
}
if u.Flags.Has(2) {
if u.Document == nil {
return fmt.Errorf("unable to encode account.updateTheme#5cb367d5: field document is nil")
}
if err := u.Document.Encode(b); err != nil {
return fmt.Errorf("unable to encode account.updateTheme#5cb367d5: field document: %w", err)
}
}
if u.Flags.Has(3) {
if err := u.Settings.Encode(b); err != nil {
return fmt.Errorf("unable to encode account.updateTheme#5cb367d5: field settings: %w", err)
}
}
return nil
}
// Decode implements bin.Decoder.
func (u *AccountUpdateThemeRequest) Decode(b *bin.Buffer) error {
if u == nil {
return fmt.Errorf("can't decode account.updateTheme#5cb367d5 to nil")
}
if err := b.ConsumeID(AccountUpdateThemeRequestTypeID); err != nil {
return fmt.Errorf("unable to decode account.updateTheme#5cb367d5: %w", err)
}
return u.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (u *AccountUpdateThemeRequest) DecodeBare(b *bin.Buffer) error {
if u == nil {
return fmt.Errorf("can't decode account.updateTheme#5cb367d5 to nil")
}
{
if err := u.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode account.updateTheme#5cb367d5: field flags: %w", err)
}
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode account.updateTheme#5cb367d5: field format: %w", err)
}
u.Format = value
}
{
value, err := DecodeInputTheme(b)
if err != nil {
return fmt.Errorf("unable to decode account.updateTheme#5cb367d5: field theme: %w", err)
}
u.Theme = value
}
if u.Flags.Has(0) {
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode account.updateTheme#5cb367d5: field slug: %w", err)
}
u.Slug = value
}
if u.Flags.Has(1) {
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode account.updateTheme#5cb367d5: field title: %w", err)
}
u.Title = value
}
if u.Flags.Has(2) {
value, err := DecodeInputDocument(b)
if err != nil {
return fmt.Errorf("unable to decode account.updateTheme#5cb367d5: field document: %w", err)
}
u.Document = value
}
if u.Flags.Has(3) {
if err := u.Settings.Decode(b); err != nil {
return fmt.Errorf("unable to decode account.updateTheme#5cb367d5: field settings: %w", err)
}
}
return nil
}
// GetFormat returns value of Format field.
func (u *AccountUpdateThemeRequest) GetFormat() (value string) {
return u.Format
}
// GetTheme returns value of Theme field.
func (u *AccountUpdateThemeRequest) GetTheme() (value InputThemeClass) {
return u.Theme
}
// SetSlug sets value of Slug conditional field.
func (u *AccountUpdateThemeRequest) SetSlug(value string) {
u.Flags.Set(0)
u.Slug = value
}
// GetSlug returns value of Slug conditional field and
// boolean which is true if field was set.
func (u *AccountUpdateThemeRequest) GetSlug() (value string, ok bool) {
if !u.Flags.Has(0) {
return value, false
}
return u.Slug, true
}
// SetTitle sets value of Title conditional field.
func (u *AccountUpdateThemeRequest) SetTitle(value string) {
u.Flags.Set(1)
u.Title = value
}
// GetTitle returns value of Title conditional field and
// boolean which is true if field was set.
func (u *AccountUpdateThemeRequest) GetTitle() (value string, ok bool) {
if !u.Flags.Has(1) {
return value, false
}
return u.Title, true
}
// SetDocument sets value of Document conditional field.
func (u *AccountUpdateThemeRequest) SetDocument(value InputDocumentClass) {
u.Flags.Set(2)
u.Document = value
}
// GetDocument returns value of Document conditional field and
// boolean which is true if field was set.
func (u *AccountUpdateThemeRequest) GetDocument() (value InputDocumentClass, ok bool) {
if !u.Flags.Has(2) {
return value, false
}
return u.Document, true
}
// SetSettings sets value of Settings conditional field.
func (u *AccountUpdateThemeRequest) SetSettings(value InputThemeSettings) {
u.Flags.Set(3)
u.Settings = value
}
// GetSettings returns value of Settings conditional field and
// boolean which is true if field was set.
func (u *AccountUpdateThemeRequest) GetSettings() (value InputThemeSettings, ok bool) {
if !u.Flags.Has(3) {
return value, false
}
return u.Settings, true
}
// GetDocumentAsNotEmpty returns mapped value of Document conditional field and
// boolean which is true if field was set.
func (u *AccountUpdateThemeRequest) GetDocumentAsNotEmpty() (*InputDocument, bool) {
if value, ok := u.GetDocument(); ok {
return value.AsNotEmpty()
}
return nil, false
}
// AccountUpdateTheme invokes method account.updateTheme#5cb367d5 returning error if any.
// Update theme
//
// See https://core.telegram.org/method/account.updateTheme for reference.
func (c *Client) AccountUpdateTheme(ctx context.Context, request *AccountUpdateThemeRequest) (*Theme, error) {
var result Theme
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return nil, err
}
return &result, nil
}