-
Notifications
You must be signed in to change notification settings - Fork 102
/
authenticationCodeInfo.go
executable file
·69 lines (58 loc) · 2.49 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
// AUTOGENERATED - DO NOT EDIT
package tdlib
import (
"encoding/json"
)
// AuthenticationCodeInfo Information about the authentication code that was sent
type AuthenticationCodeInfo struct {
tdCommon
PhoneNumber string `json:"phone_number"` // A phone number that is being authenticated
Type AuthenticationCodeType `json:"type"` // Describes the way the code was sent to the user
NextType AuthenticationCodeType `json:"next_type"` // Describes the way the next code will be sent to the user; may be null
Timeout int32 `json:"timeout"` // Timeout before the code can be re-sent, in seconds
}
// MessageType return the string telegram-type of AuthenticationCodeInfo
func (authenticationCodeInfo *AuthenticationCodeInfo) MessageType() string {
return "authenticationCodeInfo"
}
// NewAuthenticationCodeInfo creates a new AuthenticationCodeInfo
//
// @param phoneNumber A phone number that is being authenticated
// @param typeParam Describes the way the code was sent to the user
// @param nextType Describes the way the next code will be sent to the user; may be null
// @param timeout Timeout before the code can be re-sent, in seconds
func NewAuthenticationCodeInfo(phoneNumber string, typeParam AuthenticationCodeType, nextType AuthenticationCodeType, timeout int32) *AuthenticationCodeInfo {
authenticationCodeInfoTemp := AuthenticationCodeInfo{
tdCommon: tdCommon{Type: "authenticationCodeInfo"},
PhoneNumber: phoneNumber,
Type: typeParam,
NextType: nextType,
Timeout: timeout,
}
return &authenticationCodeInfoTemp
}
// UnmarshalJSON unmarshal to json
func (authenticationCodeInfo *AuthenticationCodeInfo) UnmarshalJSON(b []byte) error {
var objMap map[string]*json.RawMessage
err := json.Unmarshal(b, &objMap)
if err != nil {
return err
}
tempObj := struct {
tdCommon
PhoneNumber string `json:"phone_number"` // A phone number that is being authenticated
Timeout int32 `json:"timeout"` // Timeout before the code can be re-sent, in seconds
}{}
err = json.Unmarshal(b, &tempObj)
if err != nil {
return err
}
authenticationCodeInfo.tdCommon = tempObj.tdCommon
authenticationCodeInfo.PhoneNumber = tempObj.PhoneNumber
authenticationCodeInfo.Timeout = tempObj.Timeout
fieldType, _ := unmarshalAuthenticationCodeType(objMap["type"])
authenticationCodeInfo.Type = fieldType
fieldNextType, _ := unmarshalAuthenticationCodeType(objMap["next_type"])
authenticationCodeInfo.NextType = fieldNextType
return nil
}