-
-
Notifications
You must be signed in to change notification settings - Fork 129
/
tl_account_install_theme_gen.go
359 lines (326 loc) · 8.61 KB
/
tl_account_install_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
// 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/tdjson"
"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{}
_ = tdjson.Encoder{}
)
// AccountInstallThemeRequest represents TL type `account.installTheme#c727bb3b`.
// Install a theme
//
// See https://core.telegram.org/method/account.installTheme for reference.
type AccountInstallThemeRequest struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Whether to install the dark version
Dark bool
// Theme to install
//
// Use SetTheme and GetTheme helpers.
Theme InputThemeClass
// Theme format, a string that identifies the theming engines supported by the client
//
// Use SetFormat and GetFormat helpers.
Format string
// Indicates a basic theme provided by all clients
//
// Use SetBaseTheme and GetBaseTheme helpers.
BaseTheme BaseThemeClass
}
// AccountInstallThemeRequestTypeID is TL type id of AccountInstallThemeRequest.
const AccountInstallThemeRequestTypeID = 0xc727bb3b
// Ensuring interfaces in compile-time for AccountInstallThemeRequest.
var (
_ bin.Encoder = &AccountInstallThemeRequest{}
_ bin.Decoder = &AccountInstallThemeRequest{}
_ bin.BareEncoder = &AccountInstallThemeRequest{}
_ bin.BareDecoder = &AccountInstallThemeRequest{}
)
func (i *AccountInstallThemeRequest) Zero() bool {
if i == nil {
return true
}
if !(i.Flags.Zero()) {
return false
}
if !(i.Dark == false) {
return false
}
if !(i.Theme == nil) {
return false
}
if !(i.Format == "") {
return false
}
if !(i.BaseTheme == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *AccountInstallThemeRequest) String() string {
if i == nil {
return "AccountInstallThemeRequest(nil)"
}
type Alias AccountInstallThemeRequest
return fmt.Sprintf("AccountInstallThemeRequest%+v", Alias(*i))
}
// FillFrom fills AccountInstallThemeRequest from given interface.
func (i *AccountInstallThemeRequest) FillFrom(from interface {
GetDark() (value bool)
GetTheme() (value InputThemeClass, ok bool)
GetFormat() (value string, ok bool)
GetBaseTheme() (value BaseThemeClass, ok bool)
}) {
i.Dark = from.GetDark()
if val, ok := from.GetTheme(); ok {
i.Theme = val
}
if val, ok := from.GetFormat(); ok {
i.Format = val
}
if val, ok := from.GetBaseTheme(); ok {
i.BaseTheme = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*AccountInstallThemeRequest) TypeID() uint32 {
return AccountInstallThemeRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*AccountInstallThemeRequest) TypeName() string {
return "account.installTheme"
}
// TypeInfo returns info about TL type.
func (i *AccountInstallThemeRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "account.installTheme",
ID: AccountInstallThemeRequestTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Dark",
SchemaName: "dark",
Null: !i.Flags.Has(0),
},
{
Name: "Theme",
SchemaName: "theme",
Null: !i.Flags.Has(1),
},
{
Name: "Format",
SchemaName: "format",
Null: !i.Flags.Has(2),
},
{
Name: "BaseTheme",
SchemaName: "base_theme",
Null: !i.Flags.Has(3),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (i *AccountInstallThemeRequest) SetFlags() {
if !(i.Dark == false) {
i.Flags.Set(0)
}
if !(i.Theme == nil) {
i.Flags.Set(1)
}
if !(i.Format == "") {
i.Flags.Set(2)
}
if !(i.BaseTheme == nil) {
i.Flags.Set(3)
}
}
// Encode implements bin.Encoder.
func (i *AccountInstallThemeRequest) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode account.installTheme#c727bb3b as nil")
}
b.PutID(AccountInstallThemeRequestTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *AccountInstallThemeRequest) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode account.installTheme#c727bb3b as nil")
}
i.SetFlags()
if err := i.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode account.installTheme#c727bb3b: field flags: %w", err)
}
if i.Flags.Has(1) {
if i.Theme == nil {
return fmt.Errorf("unable to encode account.installTheme#c727bb3b: field theme is nil")
}
if err := i.Theme.Encode(b); err != nil {
return fmt.Errorf("unable to encode account.installTheme#c727bb3b: field theme: %w", err)
}
}
if i.Flags.Has(2) {
b.PutString(i.Format)
}
if i.Flags.Has(3) {
if i.BaseTheme == nil {
return fmt.Errorf("unable to encode account.installTheme#c727bb3b: field base_theme is nil")
}
if err := i.BaseTheme.Encode(b); err != nil {
return fmt.Errorf("unable to encode account.installTheme#c727bb3b: field base_theme: %w", err)
}
}
return nil
}
// Decode implements bin.Decoder.
func (i *AccountInstallThemeRequest) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode account.installTheme#c727bb3b to nil")
}
if err := b.ConsumeID(AccountInstallThemeRequestTypeID); err != nil {
return fmt.Errorf("unable to decode account.installTheme#c727bb3b: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *AccountInstallThemeRequest) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode account.installTheme#c727bb3b to nil")
}
{
if err := i.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode account.installTheme#c727bb3b: field flags: %w", err)
}
}
i.Dark = i.Flags.Has(0)
if i.Flags.Has(1) {
value, err := DecodeInputTheme(b)
if err != nil {
return fmt.Errorf("unable to decode account.installTheme#c727bb3b: field theme: %w", err)
}
i.Theme = value
}
if i.Flags.Has(2) {
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode account.installTheme#c727bb3b: field format: %w", err)
}
i.Format = value
}
if i.Flags.Has(3) {
value, err := DecodeBaseTheme(b)
if err != nil {
return fmt.Errorf("unable to decode account.installTheme#c727bb3b: field base_theme: %w", err)
}
i.BaseTheme = value
}
return nil
}
// SetDark sets value of Dark conditional field.
func (i *AccountInstallThemeRequest) SetDark(value bool) {
if value {
i.Flags.Set(0)
i.Dark = true
} else {
i.Flags.Unset(0)
i.Dark = false
}
}
// GetDark returns value of Dark conditional field.
func (i *AccountInstallThemeRequest) GetDark() (value bool) {
if i == nil {
return
}
return i.Flags.Has(0)
}
// SetTheme sets value of Theme conditional field.
func (i *AccountInstallThemeRequest) SetTheme(value InputThemeClass) {
i.Flags.Set(1)
i.Theme = value
}
// GetTheme returns value of Theme conditional field and
// boolean which is true if field was set.
func (i *AccountInstallThemeRequest) GetTheme() (value InputThemeClass, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(1) {
return value, false
}
return i.Theme, true
}
// SetFormat sets value of Format conditional field.
func (i *AccountInstallThemeRequest) SetFormat(value string) {
i.Flags.Set(2)
i.Format = value
}
// GetFormat returns value of Format conditional field and
// boolean which is true if field was set.
func (i *AccountInstallThemeRequest) GetFormat() (value string, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(2) {
return value, false
}
return i.Format, true
}
// SetBaseTheme sets value of BaseTheme conditional field.
func (i *AccountInstallThemeRequest) SetBaseTheme(value BaseThemeClass) {
i.Flags.Set(3)
i.BaseTheme = value
}
// GetBaseTheme returns value of BaseTheme conditional field and
// boolean which is true if field was set.
func (i *AccountInstallThemeRequest) GetBaseTheme() (value BaseThemeClass, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(3) {
return value, false
}
return i.BaseTheme, true
}
// AccountInstallTheme invokes method account.installTheme#c727bb3b returning error if any.
// Install a theme
//
// See https://core.telegram.org/method/account.installTheme for reference.
func (c *Client) AccountInstallTheme(ctx context.Context, request *AccountInstallThemeRequest) (bool, error) {
var result BoolBox
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return false, err
}
_, ok := result.Bool.(*BoolTrue)
return ok, nil
}