-
-
Notifications
You must be signed in to change notification settings - Fork 134
/
tl_input_secure_value_gen.go
623 lines (577 loc) · 15.6 KB
/
tl_input_secure_value_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
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
// 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{}
)
// InputSecureValue represents TL type `inputSecureValue#db21d0a7`.
// Secure value, for more info see the passport docs »¹
//
// Links:
// 1) https://core.telegram.org/passport/encryption#encryption
//
// See https://core.telegram.org/constructor/inputSecureValue for reference.
type InputSecureValue struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Secure passport¹ value type
//
// Links:
// 1) https://core.telegram.org/passport
Type SecureValueTypeClass
// Encrypted Telegram Passport¹ element data
//
// Links:
// 1) https://core.telegram.org/passport
//
// Use SetData and GetData helpers.
Data SecureData
// Encrypted passport¹ file with the front side of the document
//
// Links:
// 1) https://core.telegram.org/passport
//
// Use SetFrontSide and GetFrontSide helpers.
FrontSide InputSecureFileClass
// Encrypted passport¹ file with the reverse side of the document
//
// Links:
// 1) https://core.telegram.org/passport
//
// Use SetReverseSide and GetReverseSide helpers.
ReverseSide InputSecureFileClass
// Encrypted passport¹ file with a selfie of the user holding the document
//
// Links:
// 1) https://core.telegram.org/passport
//
// Use SetSelfie and GetSelfie helpers.
Selfie InputSecureFileClass
// Array of encrypted passport¹ files with translated versions of the provided documents
//
// Links:
// 1) https://core.telegram.org/passport
//
// Use SetTranslation and GetTranslation helpers.
Translation []InputSecureFileClass
// Array of encrypted passport¹ files with photos the of the documents
//
// Links:
// 1) https://core.telegram.org/passport
//
// Use SetFiles and GetFiles helpers.
Files []InputSecureFileClass
// Plaintext verified passport¹ data
//
// Links:
// 1) https://core.telegram.org/passport
//
// Use SetPlainData and GetPlainData helpers.
PlainData SecurePlainDataClass
}
// InputSecureValueTypeID is TL type id of InputSecureValue.
const InputSecureValueTypeID = 0xdb21d0a7
// Ensuring interfaces in compile-time for InputSecureValue.
var (
_ bin.Encoder = &InputSecureValue{}
_ bin.Decoder = &InputSecureValue{}
_ bin.BareEncoder = &InputSecureValue{}
_ bin.BareDecoder = &InputSecureValue{}
)
func (i *InputSecureValue) Zero() bool {
if i == nil {
return true
}
if !(i.Flags.Zero()) {
return false
}
if !(i.Type == nil) {
return false
}
if !(i.Data.Zero()) {
return false
}
if !(i.FrontSide == nil) {
return false
}
if !(i.ReverseSide == nil) {
return false
}
if !(i.Selfie == nil) {
return false
}
if !(i.Translation == nil) {
return false
}
if !(i.Files == nil) {
return false
}
if !(i.PlainData == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (i *InputSecureValue) String() string {
if i == nil {
return "InputSecureValue(nil)"
}
type Alias InputSecureValue
return fmt.Sprintf("InputSecureValue%+v", Alias(*i))
}
// FillFrom fills InputSecureValue from given interface.
func (i *InputSecureValue) FillFrom(from interface {
GetType() (value SecureValueTypeClass)
GetData() (value SecureData, ok bool)
GetFrontSide() (value InputSecureFileClass, ok bool)
GetReverseSide() (value InputSecureFileClass, ok bool)
GetSelfie() (value InputSecureFileClass, ok bool)
GetTranslation() (value []InputSecureFileClass, ok bool)
GetFiles() (value []InputSecureFileClass, ok bool)
GetPlainData() (value SecurePlainDataClass, ok bool)
}) {
i.Type = from.GetType()
if val, ok := from.GetData(); ok {
i.Data = val
}
if val, ok := from.GetFrontSide(); ok {
i.FrontSide = val
}
if val, ok := from.GetReverseSide(); ok {
i.ReverseSide = val
}
if val, ok := from.GetSelfie(); ok {
i.Selfie = val
}
if val, ok := from.GetTranslation(); ok {
i.Translation = val
}
if val, ok := from.GetFiles(); ok {
i.Files = val
}
if val, ok := from.GetPlainData(); ok {
i.PlainData = val
}
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*InputSecureValue) TypeID() uint32 {
return InputSecureValueTypeID
}
// TypeName returns name of type in TL schema.
func (*InputSecureValue) TypeName() string {
return "inputSecureValue"
}
// TypeInfo returns info about TL type.
func (i *InputSecureValue) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "inputSecureValue",
ID: InputSecureValueTypeID,
}
if i == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "Type",
SchemaName: "type",
},
{
Name: "Data",
SchemaName: "data",
Null: !i.Flags.Has(0),
},
{
Name: "FrontSide",
SchemaName: "front_side",
Null: !i.Flags.Has(1),
},
{
Name: "ReverseSide",
SchemaName: "reverse_side",
Null: !i.Flags.Has(2),
},
{
Name: "Selfie",
SchemaName: "selfie",
Null: !i.Flags.Has(3),
},
{
Name: "Translation",
SchemaName: "translation",
Null: !i.Flags.Has(6),
},
{
Name: "Files",
SchemaName: "files",
Null: !i.Flags.Has(4),
},
{
Name: "PlainData",
SchemaName: "plain_data",
Null: !i.Flags.Has(5),
},
}
return typ
}
// SetFlags sets flags for non-zero fields.
func (i *InputSecureValue) SetFlags() {
if !(i.Data.Zero()) {
i.Flags.Set(0)
}
if !(i.FrontSide == nil) {
i.Flags.Set(1)
}
if !(i.ReverseSide == nil) {
i.Flags.Set(2)
}
if !(i.Selfie == nil) {
i.Flags.Set(3)
}
if !(i.Translation == nil) {
i.Flags.Set(6)
}
if !(i.Files == nil) {
i.Flags.Set(4)
}
if !(i.PlainData == nil) {
i.Flags.Set(5)
}
}
// Encode implements bin.Encoder.
func (i *InputSecureValue) Encode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputSecureValue#db21d0a7 as nil")
}
b.PutID(InputSecureValueTypeID)
return i.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (i *InputSecureValue) EncodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't encode inputSecureValue#db21d0a7 as nil")
}
i.SetFlags()
if err := i.Flags.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputSecureValue#db21d0a7: field flags: %w", err)
}
if i.Type == nil {
return fmt.Errorf("unable to encode inputSecureValue#db21d0a7: field type is nil")
}
if err := i.Type.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputSecureValue#db21d0a7: field type: %w", err)
}
if i.Flags.Has(0) {
if err := i.Data.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputSecureValue#db21d0a7: field data: %w", err)
}
}
if i.Flags.Has(1) {
if i.FrontSide == nil {
return fmt.Errorf("unable to encode inputSecureValue#db21d0a7: field front_side is nil")
}
if err := i.FrontSide.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputSecureValue#db21d0a7: field front_side: %w", err)
}
}
if i.Flags.Has(2) {
if i.ReverseSide == nil {
return fmt.Errorf("unable to encode inputSecureValue#db21d0a7: field reverse_side is nil")
}
if err := i.ReverseSide.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputSecureValue#db21d0a7: field reverse_side: %w", err)
}
}
if i.Flags.Has(3) {
if i.Selfie == nil {
return fmt.Errorf("unable to encode inputSecureValue#db21d0a7: field selfie is nil")
}
if err := i.Selfie.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputSecureValue#db21d0a7: field selfie: %w", err)
}
}
if i.Flags.Has(6) {
b.PutVectorHeader(len(i.Translation))
for idx, v := range i.Translation {
if v == nil {
return fmt.Errorf("unable to encode inputSecureValue#db21d0a7: field translation element with index %d is nil", idx)
}
if err := v.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputSecureValue#db21d0a7: field translation element with index %d: %w", idx, err)
}
}
}
if i.Flags.Has(4) {
b.PutVectorHeader(len(i.Files))
for idx, v := range i.Files {
if v == nil {
return fmt.Errorf("unable to encode inputSecureValue#db21d0a7: field files element with index %d is nil", idx)
}
if err := v.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputSecureValue#db21d0a7: field files element with index %d: %w", idx, err)
}
}
}
if i.Flags.Has(5) {
if i.PlainData == nil {
return fmt.Errorf("unable to encode inputSecureValue#db21d0a7: field plain_data is nil")
}
if err := i.PlainData.Encode(b); err != nil {
return fmt.Errorf("unable to encode inputSecureValue#db21d0a7: field plain_data: %w", err)
}
}
return nil
}
// Decode implements bin.Decoder.
func (i *InputSecureValue) Decode(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputSecureValue#db21d0a7 to nil")
}
if err := b.ConsumeID(InputSecureValueTypeID); err != nil {
return fmt.Errorf("unable to decode inputSecureValue#db21d0a7: %w", err)
}
return i.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (i *InputSecureValue) DecodeBare(b *bin.Buffer) error {
if i == nil {
return fmt.Errorf("can't decode inputSecureValue#db21d0a7 to nil")
}
{
if err := i.Flags.Decode(b); err != nil {
return fmt.Errorf("unable to decode inputSecureValue#db21d0a7: field flags: %w", err)
}
}
{
value, err := DecodeSecureValueType(b)
if err != nil {
return fmt.Errorf("unable to decode inputSecureValue#db21d0a7: field type: %w", err)
}
i.Type = value
}
if i.Flags.Has(0) {
if err := i.Data.Decode(b); err != nil {
return fmt.Errorf("unable to decode inputSecureValue#db21d0a7: field data: %w", err)
}
}
if i.Flags.Has(1) {
value, err := DecodeInputSecureFile(b)
if err != nil {
return fmt.Errorf("unable to decode inputSecureValue#db21d0a7: field front_side: %w", err)
}
i.FrontSide = value
}
if i.Flags.Has(2) {
value, err := DecodeInputSecureFile(b)
if err != nil {
return fmt.Errorf("unable to decode inputSecureValue#db21d0a7: field reverse_side: %w", err)
}
i.ReverseSide = value
}
if i.Flags.Has(3) {
value, err := DecodeInputSecureFile(b)
if err != nil {
return fmt.Errorf("unable to decode inputSecureValue#db21d0a7: field selfie: %w", err)
}
i.Selfie = value
}
if i.Flags.Has(6) {
headerLen, err := b.VectorHeader()
if err != nil {
return fmt.Errorf("unable to decode inputSecureValue#db21d0a7: field translation: %w", err)
}
if headerLen > 0 {
i.Translation = make([]InputSecureFileClass, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
value, err := DecodeInputSecureFile(b)
if err != nil {
return fmt.Errorf("unable to decode inputSecureValue#db21d0a7: field translation: %w", err)
}
i.Translation = append(i.Translation, value)
}
}
if i.Flags.Has(4) {
headerLen, err := b.VectorHeader()
if err != nil {
return fmt.Errorf("unable to decode inputSecureValue#db21d0a7: field files: %w", err)
}
if headerLen > 0 {
i.Files = make([]InputSecureFileClass, 0, headerLen%bin.PreallocateLimit)
}
for idx := 0; idx < headerLen; idx++ {
value, err := DecodeInputSecureFile(b)
if err != nil {
return fmt.Errorf("unable to decode inputSecureValue#db21d0a7: field files: %w", err)
}
i.Files = append(i.Files, value)
}
}
if i.Flags.Has(5) {
value, err := DecodeSecurePlainData(b)
if err != nil {
return fmt.Errorf("unable to decode inputSecureValue#db21d0a7: field plain_data: %w", err)
}
i.PlainData = value
}
return nil
}
// GetType returns value of Type field.
func (i *InputSecureValue) GetType() (value SecureValueTypeClass) {
if i == nil {
return
}
return i.Type
}
// SetData sets value of Data conditional field.
func (i *InputSecureValue) SetData(value SecureData) {
i.Flags.Set(0)
i.Data = value
}
// GetData returns value of Data conditional field and
// boolean which is true if field was set.
func (i *InputSecureValue) GetData() (value SecureData, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(0) {
return value, false
}
return i.Data, true
}
// SetFrontSide sets value of FrontSide conditional field.
func (i *InputSecureValue) SetFrontSide(value InputSecureFileClass) {
i.Flags.Set(1)
i.FrontSide = value
}
// GetFrontSide returns value of FrontSide conditional field and
// boolean which is true if field was set.
func (i *InputSecureValue) GetFrontSide() (value InputSecureFileClass, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(1) {
return value, false
}
return i.FrontSide, true
}
// SetReverseSide sets value of ReverseSide conditional field.
func (i *InputSecureValue) SetReverseSide(value InputSecureFileClass) {
i.Flags.Set(2)
i.ReverseSide = value
}
// GetReverseSide returns value of ReverseSide conditional field and
// boolean which is true if field was set.
func (i *InputSecureValue) GetReverseSide() (value InputSecureFileClass, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(2) {
return value, false
}
return i.ReverseSide, true
}
// SetSelfie sets value of Selfie conditional field.
func (i *InputSecureValue) SetSelfie(value InputSecureFileClass) {
i.Flags.Set(3)
i.Selfie = value
}
// GetSelfie returns value of Selfie conditional field and
// boolean which is true if field was set.
func (i *InputSecureValue) GetSelfie() (value InputSecureFileClass, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(3) {
return value, false
}
return i.Selfie, true
}
// SetTranslation sets value of Translation conditional field.
func (i *InputSecureValue) SetTranslation(value []InputSecureFileClass) {
i.Flags.Set(6)
i.Translation = value
}
// GetTranslation returns value of Translation conditional field and
// boolean which is true if field was set.
func (i *InputSecureValue) GetTranslation() (value []InputSecureFileClass, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(6) {
return value, false
}
return i.Translation, true
}
// SetFiles sets value of Files conditional field.
func (i *InputSecureValue) SetFiles(value []InputSecureFileClass) {
i.Flags.Set(4)
i.Files = value
}
// GetFiles returns value of Files conditional field and
// boolean which is true if field was set.
func (i *InputSecureValue) GetFiles() (value []InputSecureFileClass, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(4) {
return value, false
}
return i.Files, true
}
// SetPlainData sets value of PlainData conditional field.
func (i *InputSecureValue) SetPlainData(value SecurePlainDataClass) {
i.Flags.Set(5)
i.PlainData = value
}
// GetPlainData returns value of PlainData conditional field and
// boolean which is true if field was set.
func (i *InputSecureValue) GetPlainData() (value SecurePlainDataClass, ok bool) {
if i == nil {
return
}
if !i.Flags.Has(5) {
return value, false
}
return i.PlainData, true
}
// MapTranslation returns field Translation wrapped in InputSecureFileClassArray helper.
func (i *InputSecureValue) MapTranslation() (value InputSecureFileClassArray, ok bool) {
if !i.Flags.Has(6) {
return value, false
}
return InputSecureFileClassArray(i.Translation), true
}
// MapFiles returns field Files wrapped in InputSecureFileClassArray helper.
func (i *InputSecureValue) MapFiles() (value InputSecureFileClassArray, ok bool) {
if !i.Flags.Has(4) {
return value, false
}
return InputSecureFileClassArray(i.Files), true
}