/
authenticationCodeInfo.go
executable file
·143 lines (110 loc) · 5.17 KB
/
authenticationCodeInfo.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
// AUTOGENERATED - DO NOT EDIT
package client
import (
"encoding/json"
"github.com/Arman92/go-tdlib/v2/tdlib"
)
// ChangePhoneNumber Changes the phone number of the user and sends an authentication code to the user's new phone number. On success, returns information about the sent code
// @param phoneNumber The new phone number of the user in international format
// @param settings Settings for the authentication of the user's phone number
func (client *Client) ChangePhoneNumber(phoneNumber string, settings *tdlib.PhoneNumberAuthenticationSettings) (*tdlib.AuthenticationCodeInfo, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "changePhoneNumber",
"phone_number": phoneNumber,
"settings": settings,
})
if err != nil {
return nil, err
}
if result.Data["@type"].(string) == "error" {
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var authenticationCodeInfo tdlib.AuthenticationCodeInfo
err = json.Unmarshal(result.Raw, &authenticationCodeInfo)
return &authenticationCodeInfo, err
}
// ResendChangePhoneNumberCode Re-sends the authentication code sent to confirm a new phone number for the current user. Works only if the previously received authenticationCodeInfo next_code_type was not null and the server-specified timeout has passed
func (client *Client) ResendChangePhoneNumberCode() (*tdlib.AuthenticationCodeInfo, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "resendChangePhoneNumberCode",
})
if err != nil {
return nil, err
}
if result.Data["@type"].(string) == "error" {
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var authenticationCodeInfo tdlib.AuthenticationCodeInfo
err = json.Unmarshal(result.Raw, &authenticationCodeInfo)
return &authenticationCodeInfo, err
}
// SendPhoneNumberVerificationCode Sends a code to verify a phone number to be added to a user's Telegram Passport
// @param phoneNumber The phone number of the user, in international format
// @param settings Settings for the authentication of the user's phone number
func (client *Client) SendPhoneNumberVerificationCode(phoneNumber string, settings *tdlib.PhoneNumberAuthenticationSettings) (*tdlib.AuthenticationCodeInfo, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "sendPhoneNumberVerificationCode",
"phone_number": phoneNumber,
"settings": settings,
})
if err != nil {
return nil, err
}
if result.Data["@type"].(string) == "error" {
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var authenticationCodeInfo tdlib.AuthenticationCodeInfo
err = json.Unmarshal(result.Raw, &authenticationCodeInfo)
return &authenticationCodeInfo, err
}
// ResendPhoneNumberVerificationCode Re-sends the code to verify a phone number to be added to a user's Telegram Passport
func (client *Client) ResendPhoneNumberVerificationCode() (*tdlib.AuthenticationCodeInfo, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "resendPhoneNumberVerificationCode",
})
if err != nil {
return nil, err
}
if result.Data["@type"].(string) == "error" {
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var authenticationCodeInfo tdlib.AuthenticationCodeInfo
err = json.Unmarshal(result.Raw, &authenticationCodeInfo)
return &authenticationCodeInfo, err
}
// SendPhoneNumberConfirmationCode Sends phone number confirmation code to handle links of the type internalLinkTypePhoneNumberConfirmation
// @param hash Hash value from the link
// @param phoneNumber Phone number value from the link
// @param settings Settings for the authentication of the user's phone number
func (client *Client) SendPhoneNumberConfirmationCode(hash string, phoneNumber string, settings *tdlib.PhoneNumberAuthenticationSettings) (*tdlib.AuthenticationCodeInfo, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "sendPhoneNumberConfirmationCode",
"hash": hash,
"phone_number": phoneNumber,
"settings": settings,
})
if err != nil {
return nil, err
}
if result.Data["@type"].(string) == "error" {
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var authenticationCodeInfo tdlib.AuthenticationCodeInfo
err = json.Unmarshal(result.Raw, &authenticationCodeInfo)
return &authenticationCodeInfo, err
}
// ResendPhoneNumberConfirmationCode Resends phone number confirmation code
func (client *Client) ResendPhoneNumberConfirmationCode() (*tdlib.AuthenticationCodeInfo, error) {
result, err := client.SendAndCatch(tdlib.UpdateData{
"@type": "resendPhoneNumberConfirmationCode",
})
if err != nil {
return nil, err
}
if result.Data["@type"].(string) == "error" {
return nil, tdlib.RequestError{Code: int(result.Data["code"].(float64)), Message: result.Data["message"].(string)}
}
var authenticationCodeInfo tdlib.AuthenticationCodeInfo
err = json.Unmarshal(result.Raw, &authenticationCodeInfo)
return &authenticationCodeInfo, err
}