/
tl_account_create_theme_gen.go
314 lines (284 loc) · 7.73 KB
/
tl_account_create_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
// 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{}
)
// AccountCreateThemeRequest represents TL type `account.createTheme#8432c21f`.
// Create a theme
//
// See https://core.telegram.org/method/account.createTheme for reference.
type AccountCreateThemeRequest struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Unique theme ID
Slug string
// Theme name
Title string
// Theme file
//
// Use SetDocument and GetDocument helpers.
Document InputDocumentClass
// Theme settings
//
// Use SetSettings and GetSettings helpers.
Settings InputThemeSettings
}
// AccountCreateThemeRequestTypeID is TL type id of AccountCreateThemeRequest.
const AccountCreateThemeRequestTypeID = 0x8432c21f
// Ensuring interfaces in compile-time for AccountCreateThemeRequest.
var (
_ bin.Encoder = &AccountCreateThemeRequest{}
_ bin.Decoder = &AccountCreateThemeRequest{}
_ bin.BareEncoder = &AccountCreateThemeRequest{}
_ bin.BareDecoder = &AccountCreateThemeRequest{}
)
func (c *AccountCreateThemeRequest) Zero() bool {
if c == nil {
return true
}
if !(c.Flags.Zero()) {
return false
}
if !(c.Slug == "") {
return false
}
if !(c.Title == "") {
return false
}
if !(c.Document == nil) {
return false
}
if !(c.Settings.Zero()) {
return false
}
return true
}
// String implements fmt.Stringer.
func (c *AccountCreateThemeRequest) String() string {
if c == nil {
return "AccountCreateThemeRequest(nil)"
}
type Alias AccountCreateThemeRequest
return fmt.Sprintf("AccountCreateThemeRequest%+v", Alias(*c))
}
// FillFrom fills AccountCreateThemeRequest from given interface.
func (c *AccountCreateThemeRequest) FillFrom(from interface {
GetSlug() (value string)
GetTitle() (value string)
GetDocument() (value InputDocumentClass, ok bool)
GetSettings() (value InputThemeSettings, ok bool)
}) {
c.Slug = from.GetSlug()
c.Title = from.GetTitle()
if val, ok := from.GetDocument(); ok {
c.Document = val
}
if val, ok := from.GetSettings(); ok {
c.Settings = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*AccountCreateThemeRequest) TypeID() uint32 {
return AccountCreateThemeRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*AccountCreateThemeRequest) TypeName() string {
return "account.createTheme"
}
// TypeInfo returns info about TL type.
func (c *AccountCreateThemeRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "account.createTheme",
ID: AccountCreateThemeRequestTypeID,
}
if c == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Slug",
SchemaName: "slug",
},
{
Name: "Title",
SchemaName: "title",
},
{
Name: "Document",
SchemaName: "document",
Null: !c.Flags.Has(2),
},
{
Name: "Settings",
SchemaName: "settings",
Null: !c.Flags.Has(3),
},
}
return typ
}
// Encode implements bin.Encoder.
func (c *AccountCreateThemeRequest) Encode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode account.createTheme#8432c21f as nil")
}
b.PutID(AccountCreateThemeRequestTypeID)
return c.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (c *AccountCreateThemeRequest) EncodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't encode account.createTheme#8432c21f as nil")
}
if !(c.Document == nil) {
c.Flags.Set(2)
}
if !(c.Settings.Zero()) {
c.Flags.Set(3)
}
if err := c.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode account.createTheme#8432c21f: field flags: %w", err)
}
b.PutString(c.Slug)
b.PutString(c.Title)
if c.Flags.Has(2) {
if c.Document == nil {
return fmt.Errorf("unable to encode account.createTheme#8432c21f: field document is nil")
}
if err := c.Document.Encode(b); err != nil {
return fmt.Errorf("unable to encode account.createTheme#8432c21f: field document: %w", err)
}
}
if c.Flags.Has(3) {
if err := c.Settings.Encode(b); err != nil {
return fmt.Errorf("unable to encode account.createTheme#8432c21f: field settings: %w", err)
}
}
return nil
}
// Decode implements bin.Decoder.
func (c *AccountCreateThemeRequest) Decode(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode account.createTheme#8432c21f to nil")
}
if err := b.ConsumeID(AccountCreateThemeRequestTypeID); err != nil {
return fmt.Errorf("unable to decode account.createTheme#8432c21f: %w", err)
}
return c.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (c *AccountCreateThemeRequest) DecodeBare(b *bin.Buffer) error {
if c == nil {
return fmt.Errorf("can't decode account.createTheme#8432c21f to nil")
}
{
if err := c.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode account.createTheme#8432c21f: field flags: %w", err)
}
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode account.createTheme#8432c21f: field slug: %w", err)
}
c.Slug = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode account.createTheme#8432c21f: field title: %w", err)
}
c.Title = value
}
if c.Flags.Has(2) {
value, err := DecodeInputDocument(b)
if err != nil {
return fmt.Errorf("unable to decode account.createTheme#8432c21f: field document: %w", err)
}
c.Document = value
}
if c.Flags.Has(3) {
if err := c.Settings.Decode(b); err != nil {
return fmt.Errorf("unable to decode account.createTheme#8432c21f: field settings: %w", err)
}
}
return nil
}
// GetSlug returns value of Slug field.
func (c *AccountCreateThemeRequest) GetSlug() (value string) {
return c.Slug
}
// GetTitle returns value of Title field.
func (c *AccountCreateThemeRequest) GetTitle() (value string) {
return c.Title
}
// SetDocument sets value of Document conditional field.
func (c *AccountCreateThemeRequest) SetDocument(value InputDocumentClass) {
c.Flags.Set(2)
c.Document = value
}
// GetDocument returns value of Document conditional field and
// boolean which is true if field was set.
func (c *AccountCreateThemeRequest) GetDocument() (value InputDocumentClass, ok bool) {
if !c.Flags.Has(2) {
return value, false
}
return c.Document, true
}
// SetSettings sets value of Settings conditional field.
func (c *AccountCreateThemeRequest) SetSettings(value InputThemeSettings) {
c.Flags.Set(3)
c.Settings = value
}
// GetSettings returns value of Settings conditional field and
// boolean which is true if field was set.
func (c *AccountCreateThemeRequest) GetSettings() (value InputThemeSettings, ok bool) {
if !c.Flags.Has(3) {
return value, false
}
return c.Settings, true
}
// GetDocumentAsNotEmpty returns mapped value of Document conditional field and
// boolean which is true if field was set.
func (c *AccountCreateThemeRequest) GetDocumentAsNotEmpty() (*InputDocument, bool) {
if value, ok := c.GetDocument(); ok {
return value.AsNotEmpty()
}
return nil, false
}
// AccountCreateTheme invokes method account.createTheme#8432c21f returning error if any.
// Create a theme
//
// See https://core.telegram.org/method/account.createTheme for reference.
func (c *Client) AccountCreateTheme(ctx context.Context, request *AccountCreateThemeRequest) (*Theme, error) {
var result Theme
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return nil, err
}
return &result, nil
}