Skip to content

Commit 785fbe4

Browse files
authored
Merge pull request #92 from Tanc009/master
publish jdcloud-sdk-nodejs
2 parents 493eaa7 + 48bf099 commit 785fbe4

12 files changed

Lines changed: 4183 additions & 1195 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jdcloud-sdk-js",
3-
"version": "1.2.102",
3+
"version": "1.2.104",
44
"description": "jdcloud openApi sdk",
55
"main": "src/jdcloud.js",
66
"scripts": {

src/repo/captcha/v1/captcha.js

Lines changed: 303 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,303 @@
1+
/*
2+
* Copyright 2018 JDCLOUD.COM
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http:#www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* 策略管理类接口
17+
* 京东云验证码-OpenAPI策略管理类接口
18+
*
19+
* OpenAPI spec version: v1
20+
* Contact:
21+
*
22+
* NOTE: This class is auto generated by the jdcloud code generator program.
23+
*/
24+
25+
require('../../../lib/node_loader')
26+
var JDCloud = require('../../../lib/core')
27+
var Service = JDCloud.Service
28+
var serviceId = 'captcha'
29+
Service._services[serviceId] = true
30+
31+
/**
32+
* captcha service.
33+
* @version 1.0.0
34+
*/
35+
36+
class CAPTCHA extends Service {
37+
constructor (options = {}) {
38+
options._defaultEndpoint = {}
39+
options._defaultEndpoint.protocol =
40+
options._defaultEndpoint.protocol || 'https'
41+
options._defaultEndpoint.host =
42+
options._defaultEndpoint.host || 'captcha.jdcloud-api.com'
43+
options.basePath = '/v1' // 默认要设为空""
44+
super(serviceId, options)
45+
}
46+
47+
/**
48+
* 获取会话id
49+
* @param {Object} opts - parameters
50+
* @param {} [opts.appId] - 应用id optional
51+
* @param {} [opts.sceneId] - 场景id optional
52+
* @param {} [opts.secret] - 密钥,从界面获取 optional
53+
* @param {} [opts.uuid] - uuid,ios客户端传openudid, android客户端传androidid optional
54+
* @param {} [opts.ip] - 客户端ip optional
55+
* @param {} [opts.userAgent] - 客户端userAgent optional
56+
* @param {} [opts.fingerPrint] - 指纹,客户端sdk获取 optional
57+
* @param {} [opts.clientType] - 客户端类型, android, ios optional
58+
* @param {} [opts.clientVersion] - 客户端版本,用户端app版本,可选 optional
59+
* @param {string} callback - callback
60+
@return {Object} result
61+
* @param sessionDataResp data
62+
*/
63+
64+
getSessionId (opts, callback) {
65+
opts = opts || {}
66+
67+
let postBody = {}
68+
if (opts.appId !== undefined && opts.appId !== null) {
69+
postBody['appId'] = opts.appId
70+
}
71+
if (opts.sceneId !== undefined && opts.sceneId !== null) {
72+
postBody['sceneId'] = opts.sceneId
73+
}
74+
if (opts.secret !== undefined && opts.secret !== null) {
75+
postBody['secret'] = opts.secret
76+
}
77+
if (opts.uuid !== undefined && opts.uuid !== null) {
78+
postBody['uuid'] = opts.uuid
79+
}
80+
if (opts.ip !== undefined && opts.ip !== null) {
81+
postBody['ip'] = opts.ip
82+
}
83+
if (opts.userAgent !== undefined && opts.userAgent !== null) {
84+
postBody['userAgent'] = opts.userAgent
85+
}
86+
if (opts.fingerPrint !== undefined && opts.fingerPrint !== null) {
87+
postBody['fingerPrint'] = opts.fingerPrint
88+
}
89+
if (opts.clientType !== undefined && opts.clientType !== null) {
90+
postBody['clientType'] = opts.clientType
91+
}
92+
if (opts.clientVersion !== undefined && opts.clientVersion !== null) {
93+
postBody['clientVersion'] = opts.clientVersion
94+
}
95+
96+
let queryParams = {}
97+
98+
let pathParams = {
99+
regionId: 'jdcloud'
100+
}
101+
102+
let headerParams = {
103+
'User-Agent': 'JdcloudSdkNode/1.0.0 captcha/1.0.0'
104+
}
105+
106+
let contentTypes = ['application/json']
107+
let accepts = ['application/json']
108+
109+
// 扩展自定义头
110+
if (opts['x-extra-header']) {
111+
for (let extraHeader in opts['x-extra-header']) {
112+
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
113+
}
114+
115+
if (Array.isArray(opts['x-extra-header']['content-type'])) {
116+
contentTypes = opts['x-extra-header']['content-type']
117+
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
118+
contentTypes = opts['x-extra-header']['content-type'].split(',')
119+
}
120+
121+
if (Array.isArray(opts['x-extra-header']['accept'])) {
122+
accepts = opts['x-extra-header']['accept']
123+
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
124+
accepts = opts['x-extra-header']['accept'].split(',')
125+
}
126+
}
127+
128+
let formParams = {}
129+
130+
let returnType = null
131+
132+
this.config.logger(
133+
`call getSessionId with params:\npathParams:${JSON.stringify(
134+
pathParams
135+
)},\nqueryParams:${JSON.stringify(
136+
queryParams
137+
)}, \nheaderParams:${JSON.stringify(
138+
headerParams
139+
)}, \nformParams:${JSON.stringify(
140+
formParams
141+
)}, \npostBody:${JSON.stringify(postBody)}`,
142+
'DEBUG'
143+
)
144+
145+
let request = super.makeRequest(
146+
'/captcha:getsessionid',
147+
'POST',
148+
pathParams,
149+
queryParams,
150+
headerParams,
151+
formParams,
152+
postBody,
153+
contentTypes,
154+
accepts,
155+
returnType,
156+
callback
157+
)
158+
159+
return request.then(
160+
function (result) {
161+
if (callback && typeof callback === 'function') {
162+
return callback(null, result)
163+
}
164+
return result
165+
},
166+
function (error) {
167+
if (callback && typeof callback === 'function') {
168+
return callback(error)
169+
}
170+
return Promise.reject(error)
171+
}
172+
)
173+
}
174+
175+
/**
176+
* 验证verifyToken
177+
* @param {Object} opts - parameters
178+
* @param {} [opts.verifyToken] - 提交后台校验的token,客户端sdk获取 optional
179+
* @param {} [opts.sessionId] - 验证码会话id,getsessionid返回 optional
180+
* @param {} [opts.appId] - 应用id optional
181+
* @param {} [opts.sceneId] - 场景id optional
182+
* @param {} [opts.ip] - 客户端ip optional
183+
* @param {} [opts.userAgent] - 客户端userAgent optional
184+
* @param {} [opts.fingerPrint] - 指纹,客户端sdk获取 optional
185+
* @param {} [opts.clientType] - 客户端类型, android, ios optional
186+
* @param {} [opts.clientVersion] - 客户端版本,用户端app版本,可选 optional
187+
* @param {string} callback - callback
188+
@return {Object} result
189+
* @param verifyDataResp data
190+
*/
191+
192+
verifyToken (opts, callback) {
193+
opts = opts || {}
194+
195+
let postBody = {}
196+
if (opts.verifyToken !== undefined && opts.verifyToken !== null) {
197+
postBody['verifyToken'] = opts.verifyToken
198+
}
199+
if (opts.sessionId !== undefined && opts.sessionId !== null) {
200+
postBody['sessionId'] = opts.sessionId
201+
}
202+
if (opts.appId !== undefined && opts.appId !== null) {
203+
postBody['appId'] = opts.appId
204+
}
205+
if (opts.sceneId !== undefined && opts.sceneId !== null) {
206+
postBody['sceneId'] = opts.sceneId
207+
}
208+
if (opts.ip !== undefined && opts.ip !== null) {
209+
postBody['ip'] = opts.ip
210+
}
211+
if (opts.userAgent !== undefined && opts.userAgent !== null) {
212+
postBody['userAgent'] = opts.userAgent
213+
}
214+
if (opts.fingerPrint !== undefined && opts.fingerPrint !== null) {
215+
postBody['fingerPrint'] = opts.fingerPrint
216+
}
217+
if (opts.clientType !== undefined && opts.clientType !== null) {
218+
postBody['clientType'] = opts.clientType
219+
}
220+
if (opts.clientVersion !== undefined && opts.clientVersion !== null) {
221+
postBody['clientVersion'] = opts.clientVersion
222+
}
223+
224+
let queryParams = {}
225+
226+
let pathParams = {
227+
regionId: 'jdcloud'
228+
}
229+
230+
let headerParams = {
231+
'User-Agent': 'JdcloudSdkNode/1.0.0 captcha/1.0.0'
232+
}
233+
234+
let contentTypes = ['application/json']
235+
let accepts = ['application/json']
236+
237+
// 扩展自定义头
238+
if (opts['x-extra-header']) {
239+
for (let extraHeader in opts['x-extra-header']) {
240+
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
241+
}
242+
243+
if (Array.isArray(opts['x-extra-header']['content-type'])) {
244+
contentTypes = opts['x-extra-header']['content-type']
245+
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
246+
contentTypes = opts['x-extra-header']['content-type'].split(',')
247+
}
248+
249+
if (Array.isArray(opts['x-extra-header']['accept'])) {
250+
accepts = opts['x-extra-header']['accept']
251+
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
252+
accepts = opts['x-extra-header']['accept'].split(',')
253+
}
254+
}
255+
256+
let formParams = {}
257+
258+
let returnType = null
259+
260+
this.config.logger(
261+
`call verifyToken with params:\npathParams:${JSON.stringify(
262+
pathParams
263+
)},\nqueryParams:${JSON.stringify(
264+
queryParams
265+
)}, \nheaderParams:${JSON.stringify(
266+
headerParams
267+
)}, \nformParams:${JSON.stringify(
268+
formParams
269+
)}, \npostBody:${JSON.stringify(postBody)}`,
270+
'DEBUG'
271+
)
272+
273+
let request = super.makeRequest(
274+
'/captcha:verifytoken',
275+
'POST',
276+
pathParams,
277+
queryParams,
278+
headerParams,
279+
formParams,
280+
postBody,
281+
contentTypes,
282+
accepts,
283+
returnType,
284+
callback
285+
)
286+
287+
return request.then(
288+
function (result) {
289+
if (callback && typeof callback === 'function') {
290+
return callback(null, result)
291+
}
292+
return result
293+
},
294+
function (error) {
295+
if (callback && typeof callback === 'function') {
296+
return callback(error)
297+
}
298+
return Promise.reject(error)
299+
}
300+
)
301+
}
302+
}
303+
module.exports = CAPTCHA

0 commit comments

Comments
 (0)