-
-
Notifications
You must be signed in to change notification settings - Fork 129
/
tl_account_unregister_device_gen.go
240 lines (216 loc) · 6.56 KB
/
tl_account_unregister_device_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
// 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{}
)
// AccountUnregisterDeviceRequest represents TL type `account.unregisterDevice#3076c4bf`.
// Deletes a device by its token, stops sending PUSH-notifications to it.
//
// See https://core.telegram.org/method/account.unregisterDevice for reference.
type AccountUnregisterDeviceRequest struct {
// Device token type.Possible values:1 - APNS (device token for apple push)2 - FCM
// (firebase token for google firebase)3 - MPNS (channel URI for microsoft push)4 -
// Simple push (endpoint for firefox's simple push API)5 - Ubuntu phone (token for ubuntu
// push)6 - Blackberry (token for blackberry push)7 - Unused8 - WNS (windows push)9 -
// APNS VoIP (token for apple push VoIP)10 - Web push (web push, see below)11 - MPNS VoIP
// (token for microsoft push VoIP)12 - Tizen (token for tizen push)For 10 web push, the
// token must be a JSON-encoded object containing the keys described in PUSH updates¹
//
// Links:
// 1) https://core.telegram.org/api/push-updates
TokenType int
// Device token
Token string
// List of user identifiers of other users currently using the client
OtherUIDs []int
}
// AccountUnregisterDeviceRequestTypeID is TL type id of AccountUnregisterDeviceRequest.
const AccountUnregisterDeviceRequestTypeID = 0x3076c4bf
func (u *AccountUnregisterDeviceRequest) Zero() bool {
if u == nil {
return true
}
if !(u.TokenType == 0) {
return false
}
if !(u.Token == "") {
return false
}
if !(u.OtherUIDs == nil) {
return false
}
return true
}
// String implements fmt.Stringer.
func (u *AccountUnregisterDeviceRequest) String() string {
if u == nil {
return "AccountUnregisterDeviceRequest(nil)"
}
type Alias AccountUnregisterDeviceRequest
return fmt.Sprintf("AccountUnregisterDeviceRequest%+v", Alias(*u))
}
// FillFrom fills AccountUnregisterDeviceRequest from given interface.
func (u *AccountUnregisterDeviceRequest) FillFrom(from interface {
GetTokenType() (value int)
GetToken() (value string)
GetOtherUIDs() (value []int)
}) {
u.TokenType = from.GetTokenType()
u.Token = from.GetToken()
u.OtherUIDs = from.GetOtherUIDs()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*AccountUnregisterDeviceRequest) TypeID() uint32 {
return AccountUnregisterDeviceRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*AccountUnregisterDeviceRequest) TypeName() string {
return "account.unregisterDevice"
}
// TypeInfo returns info about TL type.
func (u *AccountUnregisterDeviceRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "account.unregisterDevice",
ID: AccountUnregisterDeviceRequestTypeID,
}
if u == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "TokenType",
SchemaName: "token_type",
},
{
Name: "Token",
SchemaName: "token",
},
{
Name: "OtherUIDs",
SchemaName: "other_uids",
},
}
return typ
}
// Encode implements bin.Encoder.
func (u *AccountUnregisterDeviceRequest) Encode(b *bin.Buffer) error {
if u == nil {
return fmt.Errorf("can't encode account.unregisterDevice#3076c4bf as nil")
}
b.PutID(AccountUnregisterDeviceRequestTypeID)
return u.EncodeBare(b)
}
// EncodeBare implements bin.BareEncoder.
func (u *AccountUnregisterDeviceRequest) EncodeBare(b *bin.Buffer) error {
if u == nil {
return fmt.Errorf("can't encode account.unregisterDevice#3076c4bf as nil")
}
b.PutInt(u.TokenType)
b.PutString(u.Token)
b.PutVectorHeader(len(u.OtherUIDs))
for _, v := range u.OtherUIDs {
b.PutInt(v)
}
return nil
}
// GetTokenType returns value of TokenType field.
func (u *AccountUnregisterDeviceRequest) GetTokenType() (value int) {
return u.TokenType
}
// GetToken returns value of Token field.
func (u *AccountUnregisterDeviceRequest) GetToken() (value string) {
return u.Token
}
// GetOtherUIDs returns value of OtherUIDs field.
func (u *AccountUnregisterDeviceRequest) GetOtherUIDs() (value []int) {
return u.OtherUIDs
}
// Decode implements bin.Decoder.
func (u *AccountUnregisterDeviceRequest) Decode(b *bin.Buffer) error {
if u == nil {
return fmt.Errorf("can't decode account.unregisterDevice#3076c4bf to nil")
}
if err := b.ConsumeID(AccountUnregisterDeviceRequestTypeID); err != nil {
return fmt.Errorf("unable to decode account.unregisterDevice#3076c4bf: %w", err)
}
return u.DecodeBare(b)
}
// DecodeBare implements bin.BareDecoder.
func (u *AccountUnregisterDeviceRequest) DecodeBare(b *bin.Buffer) error {
if u == nil {
return fmt.Errorf("can't decode account.unregisterDevice#3076c4bf to nil")
}
{
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode account.unregisterDevice#3076c4bf: field token_type: %w", err)
}
u.TokenType = value
}
{
value, err := b.String()
if err != nil {
return fmt.Errorf("unable to decode account.unregisterDevice#3076c4bf: field token: %w", err)
}
u.Token = value
}
{
headerLen, err := b.VectorHeader()
if err != nil {
return fmt.Errorf("unable to decode account.unregisterDevice#3076c4bf: field other_uids: %w", err)
}
for idx := 0; idx < headerLen; idx++ {
value, err := b.Int()
if err != nil {
return fmt.Errorf("unable to decode account.unregisterDevice#3076c4bf: field other_uids: %w", err)
}
u.OtherUIDs = append(u.OtherUIDs, value)
}
}
return nil
}
// Ensuring interfaces in compile-time for AccountUnregisterDeviceRequest.
var (
_ bin.Encoder = &AccountUnregisterDeviceRequest{}
_ bin.Decoder = &AccountUnregisterDeviceRequest{}
_ bin.BareEncoder = &AccountUnregisterDeviceRequest{}
_ bin.BareDecoder = &AccountUnregisterDeviceRequest{}
)
// AccountUnregisterDevice invokes method account.unregisterDevice#3076c4bf returning error if any.
// Deletes a device by its token, stops sending PUSH-notifications to it.
//
// Possible errors:
// 400 TOKEN_INVALID: The provided token is invalid
//
// See https://core.telegram.org/method/account.unregisterDevice for reference.
func (c *Client) AccountUnregisterDevice(ctx context.Context, request *AccountUnregisterDeviceRequest) (bool, error) {
var result BoolBox
if err := c.rpc.InvokeRaw(ctx, request, &result); err != nil {
return false, err
}
_, ok := result.Bool.(*BoolTrue)
return ok, nil
}