-
Notifications
You must be signed in to change notification settings - Fork 102
/
inputCredentials.go
executable file
·176 lines (144 loc) · 6.15 KB
/
inputCredentials.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
// AUTOGENERATED - DO NOT EDIT
package tdlib
import (
"encoding/json"
"fmt"
)
// InputCredentials Contains information about the payment method chosen by the user
type InputCredentials interface {
GetInputCredentialsEnum() InputCredentialsEnum
}
// InputCredentialsEnum Alias for abstract InputCredentials 'Sub-Classes', used as constant-enum here
type InputCredentialsEnum string
// InputCredentials enums
const (
InputCredentialsSavedType InputCredentialsEnum = "inputCredentialsSaved"
InputCredentialsNewType InputCredentialsEnum = "inputCredentialsNew"
InputCredentialsApplePayType InputCredentialsEnum = "inputCredentialsApplePay"
InputCredentialsGooglePayType InputCredentialsEnum = "inputCredentialsGooglePay"
)
func unmarshalInputCredentials(rawMsg *json.RawMessage) (InputCredentials, error) {
if rawMsg == nil {
return nil, nil
}
var objMap map[string]interface{}
err := json.Unmarshal(*rawMsg, &objMap)
if err != nil {
return nil, err
}
switch InputCredentialsEnum(objMap["@type"].(string)) {
case InputCredentialsSavedType:
var inputCredentialsSaved InputCredentialsSaved
err := json.Unmarshal(*rawMsg, &inputCredentialsSaved)
return &inputCredentialsSaved, err
case InputCredentialsNewType:
var inputCredentialsNew InputCredentialsNew
err := json.Unmarshal(*rawMsg, &inputCredentialsNew)
return &inputCredentialsNew, err
case InputCredentialsApplePayType:
var inputCredentialsApplePay InputCredentialsApplePay
err := json.Unmarshal(*rawMsg, &inputCredentialsApplePay)
return &inputCredentialsApplePay, err
case InputCredentialsGooglePayType:
var inputCredentialsGooglePay InputCredentialsGooglePay
err := json.Unmarshal(*rawMsg, &inputCredentialsGooglePay)
return &inputCredentialsGooglePay, err
default:
return nil, fmt.Errorf("Error UnMarshaling, unknown type:" + objMap["@type"].(string))
}
}
// InputCredentialsSaved Applies if a user chooses some previously saved payment credentials. To use their previously saved credentials, the user must have a valid temporary password
type InputCredentialsSaved struct {
tdCommon
SavedCredentialsID string `json:"saved_credentials_id"` // Identifier of the saved credentials
}
// MessageType return the string telegram-type of InputCredentialsSaved
func (inputCredentialsSaved *InputCredentialsSaved) MessageType() string {
return "inputCredentialsSaved"
}
// NewInputCredentialsSaved creates a new InputCredentialsSaved
//
// @param savedCredentialsID Identifier of the saved credentials
func NewInputCredentialsSaved(savedCredentialsID string) *InputCredentialsSaved {
inputCredentialsSavedTemp := InputCredentialsSaved{
tdCommon: tdCommon{Type: "inputCredentialsSaved"},
SavedCredentialsID: savedCredentialsID,
}
return &inputCredentialsSavedTemp
}
// GetInputCredentialsEnum return the enum type of this object
func (inputCredentialsSaved *InputCredentialsSaved) GetInputCredentialsEnum() InputCredentialsEnum {
return InputCredentialsSavedType
}
// InputCredentialsNew Applies if a user enters new credentials on a payment provider website
type InputCredentialsNew struct {
tdCommon
Data string `json:"data"` // Contains JSON-encoded data with a credential identifier from the payment provider
AllowSave bool `json:"allow_save"` // True, if the credential identifier can be saved on the server side
}
// MessageType return the string telegram-type of InputCredentialsNew
func (inputCredentialsNew *InputCredentialsNew) MessageType() string {
return "inputCredentialsNew"
}
// NewInputCredentialsNew creates a new InputCredentialsNew
//
// @param data Contains JSON-encoded data with a credential identifier from the payment provider
// @param allowSave True, if the credential identifier can be saved on the server side
func NewInputCredentialsNew(data string, allowSave bool) *InputCredentialsNew {
inputCredentialsNewTemp := InputCredentialsNew{
tdCommon: tdCommon{Type: "inputCredentialsNew"},
Data: data,
AllowSave: allowSave,
}
return &inputCredentialsNewTemp
}
// GetInputCredentialsEnum return the enum type of this object
func (inputCredentialsNew *InputCredentialsNew) GetInputCredentialsEnum() InputCredentialsEnum {
return InputCredentialsNewType
}
// InputCredentialsApplePay Applies if a user enters new credentials using Apple Pay
type InputCredentialsApplePay struct {
tdCommon
Data string `json:"data"` // JSON-encoded data with the credential identifier
}
// MessageType return the string telegram-type of InputCredentialsApplePay
func (inputCredentialsApplePay *InputCredentialsApplePay) MessageType() string {
return "inputCredentialsApplePay"
}
// NewInputCredentialsApplePay creates a new InputCredentialsApplePay
//
// @param data JSON-encoded data with the credential identifier
func NewInputCredentialsApplePay(data string) *InputCredentialsApplePay {
inputCredentialsApplePayTemp := InputCredentialsApplePay{
tdCommon: tdCommon{Type: "inputCredentialsApplePay"},
Data: data,
}
return &inputCredentialsApplePayTemp
}
// GetInputCredentialsEnum return the enum type of this object
func (inputCredentialsApplePay *InputCredentialsApplePay) GetInputCredentialsEnum() InputCredentialsEnum {
return InputCredentialsApplePayType
}
// InputCredentialsGooglePay Applies if a user enters new credentials using Google Pay
type InputCredentialsGooglePay struct {
tdCommon
Data string `json:"data"` // JSON-encoded data with the credential identifier
}
// MessageType return the string telegram-type of InputCredentialsGooglePay
func (inputCredentialsGooglePay *InputCredentialsGooglePay) MessageType() string {
return "inputCredentialsGooglePay"
}
// NewInputCredentialsGooglePay creates a new InputCredentialsGooglePay
//
// @param data JSON-encoded data with the credential identifier
func NewInputCredentialsGooglePay(data string) *InputCredentialsGooglePay {
inputCredentialsGooglePayTemp := InputCredentialsGooglePay{
tdCommon: tdCommon{Type: "inputCredentialsGooglePay"},
Data: data,
}
return &inputCredentialsGooglePayTemp
}
// GetInputCredentialsEnum return the enum type of this object
func (inputCredentialsGooglePay *InputCredentialsGooglePay) GetInputCredentialsEnum() InputCredentialsEnum {
return InputCredentialsGooglePayType
}