forked from huaweicloud/huaweicloud-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
requests.go
239 lines (177 loc) · 7.06 KB
/
requests.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
package realnameauth
import (
"github.com/gophercloud/gophercloud"
)
type IndividualRealNameAuthOpts struct {
//Customer ID.
CustomerId string `json:"customerId" required:"true"`
//Authentication method.
IdentifyType *int `json:"identifyType" required:"true"`
//Certificate type.
VerifiedType int `json:"verifiedType,omitempty"`
//Attachment URL for individual certificate authentication.
VerifiedFileURL []string `json:"verifiedFileURL" required:"true"`
//Name
Name string `json:"name" required:"true"`
//Certificate number.
VerifiedNumber string `json:"verifiedNumber" required:"true"`
//Change type.
ChangeType int `json:"changeType,omitempty"`
//Platform ID assigned by Huawei to a partner.
XaccountType string `json:"xaccountType" required:"true"`
}
type EnterpriseRealNameAuthOpts struct {
//Customer ID.
CustomerId string `json:"customerId" required:"true"`
//Authentication method.
IdentifyType *int `json:"identifyType" required:"true"`
//Enterprise certificate type.
CertificateType int `json:"certificateType,omitempty"`
//URL of the certificate attachment file used for enterprise certificate authentication.
VerifiedFileURL []string `json:"verifiedFileURL" required:"true"`
//Organization name.
CorpName string `json:"corpName" required:"true"`
//Enterprise certificate number.
VerifiedNumber string `json:"verifiedNumber" required:"true"`
//Registration country entered for real-name authentication.
RegCountry string `json:"regCountry,omitempty"`
//Enterprise registration address for real-name authentication.
RegAddress string `json:"regAddress,omitempty"`
//Platform ID assigned by Huawei to a partner.。
XaccountType string `json:"xaccountType" required:"true"`
//Enterprise person information.
EnterprisePerson EnterprisePerson `json:"enterprisePerson,omitempty"`
}
type ChangeEnterpriseRealNameAuthOpts struct {
//Customer ID.
CustomerId string `json:"customerId" required:"true"`
//Authentication method.
IdentifyType *int `json:"identifyType" required:"true"`
//Enterprise certificate type.
CertificateType int `json:"certificateType,omitempty"`
//URL of the certificate attachment file used for enterprise certificate authentication.
VerifiedFileURL []string `json:"verifiedFileURL" required:"true"`
//Organization name.
CorpName string `json:"corpName" required:"true"`
//Enterprise certificate number.
VerifiedNumber string `json:"verifiedNumber" required:"true"`
//Registration country entered for real-name authentication.
RegCountry string `json:"regCountry,omitempty"`
//Enterprise registration address for real-name authentication.
RegAddress string `json:"regAddress,omitempty"`
//Change type
ChangeType *int `json:"changeType" required:"true"`
//Platform ID assigned by Huawei to a partner.
XaccountType string `json:"xaccountType" required:"true"`
//Enterprise person information.
EnterprisePerson EnterprisePerson `json:"enterprisePerson,omitempty"`
}
type EnterprisePerson struct {
//Legal entity name.
LegelName string `json:"legelName" required:"true"`
//Legal entity card ID.
LegelIdNumber string `json:"legelIdNumber" required:"true"`
//Legal entity role.
CertifierRole string `json:"certifierRole,omitempty"`
}
type QueryRealNameAuthOpts struct {
//Customer ID.
CustomerId string `q:"customerId" required:"true"`
}
type QueryRealNameAuthOptsBuilder interface {
ToQueryRealNameAuthMap() (string, error)
}
func (opts QueryRealNameAuthOpts) ToQueryRealNameAuthMap() (string, error) {
q, err := gophercloud.BuildQueryString(opts)
return q.String(), err
}
type EnterpriseRealNameAuthOptsBuilder interface {
ToEnterpriseRealNameAuthMap() (map[string]interface{}, error)
}
func (opts EnterpriseRealNameAuthOpts) ToEnterpriseRealNameAuthMap() (map[string]interface{}, error) {
return gophercloud.BuildRequestBody(opts, "")
}
type IndividualRealNameAuthOptsBuilder interface {
ToIndividualRealNameAuthMap() (map[string]interface{}, error)
}
func (opts IndividualRealNameAuthOpts) ToIndividualRealNameAuthMap() (map[string]interface{}, error) {
return gophercloud.BuildRequestBody(opts, "")
}
type ChangeEnterpriseRealNameAuthOptsBuilder interface {
ToChangeEnterpriseRealNameAuthMap() (map[string]interface{}, error)
}
func (opts ChangeEnterpriseRealNameAuthOpts) ToChangeEnterpriseRealNameAuthMap() (map[string]interface{}, error) {
return gophercloud.BuildRequestBody(opts, "")
}
/**
* An individual customer can apply for real-name authentication on the partner sales platform. Currently, two authentication methods are supported: using the individual certificate and using individual bank card.
* This API can be invoked only by the partner account AK/SK or token.ken.
*/
func IndividualRealNameAuth(client *gophercloud.ServiceClient, opts IndividualRealNameAuthOptsBuilder) (r IndividualRealNameAuthResult) {
domainID := client.ProviderClient.DomainID
if opts != nil {
body, err := opts.ToIndividualRealNameAuthMap()
if err != nil {
r.Err = err
return
}
_, r.Err = client.Post(getIndividualRealNameAuthURL(client, domainID), body, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
}
return
}
/**
* Enterprise customers can perform enterprise real-name authentication on the partner sales platform.
* This API can be invoked only by the partner account AK/SK or token.
*/
func EnterpriseRealNameAuth(client *gophercloud.ServiceClient, opts EnterpriseRealNameAuthOptsBuilder) (r EnterpriseRealNameAuthResult) {
domainID := client.ProviderClient.DomainID
if opts != nil {
body, err := opts.ToEnterpriseRealNameAuthMap()
if err != nil {
r.Err = err
return
}
_, r.Err = client.Post(getEnterpriseRealNameAuthURL(client, domainID), body, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
}
return
}
/**
* If the response to a real-name authentication application or real-name authentication change application indicates that manual review is required, this API can be used to query the review result.
* This API can be invoked only by the partner account AK/SK or token.
*/
func QueryRealNameAuth(client *gophercloud.ServiceClient, opts QueryRealNameAuthOptsBuilder)(r QueryRealNameAuthResult) {
domainID := client.ProviderClient.DomainID
url := getQueryRealNameAuthURL(client, domainID)
if opts != nil {
query, err := opts.ToQueryRealNameAuthMap()
if err != nil {
r.Err = err
return
}
url += query
_, r.Err = client.Get(url, &r.Body, nil)
}
return
}
/**
* The customer applies for a real-name certification change on the partner sales platform. Currently, it supports personal transfer to enterprise changes.
* The api is only allowed to be called with the partner AK/SK or Token.
*/
func ChangeEnterpriseRealNameAuth(client *gophercloud.ServiceClient, opts ChangeEnterpriseRealNameAuthOptsBuilder) (r ChangeEnterpriseRealNameAuthResult) {
domainID := client.ProviderClient.DomainID
if opts != nil {
body, err := opts.ToChangeEnterpriseRealNameAuthMap()
if err != nil {
r.Err = err
return
}
_, r.Err = client.Put(getChangeEnterpriseRealNameAuthURL(client, domainID), body, &r.Body, &gophercloud.RequestOpts{
OkCodes: []int{200},
})
}
return
}