Skip to content

Commit a872631

Browse files
authored
Merge pull request #80 from Tanc009/master
publish jdcloud-sdk-nodejs
2 parents 2b20f5d + 99b187f commit a872631

4 files changed

Lines changed: 332 additions & 1 deletion

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.86",
3+
"version": "1.2.87",
44
"description": "jdcloud openApi sdk",
55
"main": "src/jdcloud.js",
66
"scripts": {

src/repo/asset/v1/asset.js

Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
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+
* JDCLOUD asset API
17+
* API JDCLOUD asset API
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 = 'asset'
29+
Service._services[serviceId] = true
30+
31+
/**
32+
* asset service.
33+
* @version 0.0.2
34+
*/
35+
36+
class ASSET 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 || 'asset.jcloud.com'
43+
options.basePath = '/v1' // 默认要设为空""
44+
super(serviceId, options)
45+
}
46+
47+
/**
48+
* 查询账户金额(总金额、可用金额、冻结金额、可提现金额、提现中金额)
49+
* @param {Object} opts - parameters
50+
* @param {string} regionId - ID of the region
51+
* @param {string} callback - callback
52+
@return {Object} result
53+
* @param string totalAmount 总金额:可用金额+冻结金额
54+
* @param string availableAmount 可用金额
55+
* @param string frozenAmount 冻结金额:提现失败、处理中或预占中金额
56+
* @param string enableWithdrawAmount 可提现金额:排除对公充值金额总额后的充值总额,如果余额大于非对公充值总额,则为非对公充值总额,否则为余额(对公充值=企业线下汇款+企业充值+活动充值金额)
57+
* @param string withdrawingAmount 提现中金额:提现状态为处理中和预占中的金额
58+
*/
59+
60+
describeAccountAmount (opts, regionId = this.config.regionId, callback) {
61+
if (typeof regionId === 'function') {
62+
callback = regionId
63+
regionId = this.config.regionId
64+
}
65+
66+
if (regionId === undefined || regionId === null) {
67+
throw new Error(
68+
"Missing the required parameter 'regionId' when calling describeAccountAmount"
69+
)
70+
}
71+
72+
opts = opts || {}
73+
74+
let postBody = null
75+
let queryParams = {}
76+
77+
let pathParams = {
78+
regionId: regionId
79+
}
80+
81+
let headerParams = {
82+
'User-Agent': 'JdcloudSdkNode/1.0.0 asset/0.0.2'
83+
}
84+
85+
let contentTypes = ['application/json']
86+
let accepts = ['application/json']
87+
88+
// 扩展自定义头
89+
if (opts['x-extra-header']) {
90+
for (let extraHeader in opts['x-extra-header']) {
91+
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
92+
}
93+
94+
if (Array.isArray(opts['x-extra-header']['content-type'])) {
95+
contentTypes = opts['x-extra-header']['content-type']
96+
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
97+
contentTypes = opts['x-extra-header']['content-type'].split(',')
98+
}
99+
100+
if (Array.isArray(opts['x-extra-header']['accept'])) {
101+
accepts = opts['x-extra-header']['accept']
102+
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
103+
accepts = opts['x-extra-header']['accept'].split(',')
104+
}
105+
}
106+
107+
let formParams = {}
108+
109+
let returnType = null
110+
111+
this.config.logger(
112+
`call describeAccountAmount with params:\npathParams:${JSON.stringify(
113+
pathParams
114+
)},\nqueryParams:${JSON.stringify(
115+
queryParams
116+
)}, \nheaderParams:${JSON.stringify(
117+
headerParams
118+
)}, \nformParams:${JSON.stringify(
119+
formParams
120+
)}, \npostBody:${JSON.stringify(postBody)}`,
121+
'DEBUG'
122+
)
123+
124+
let request = super.makeRequest(
125+
'/regions/{regionId}/assets:describeAccountAmount',
126+
'GET',
127+
pathParams,
128+
queryParams,
129+
headerParams,
130+
formParams,
131+
postBody,
132+
contentTypes,
133+
accepts,
134+
returnType,
135+
callback
136+
)
137+
138+
return request.then(
139+
function (result) {
140+
if (callback && typeof callback === 'function') {
141+
return callback(null, result)
142+
}
143+
return result
144+
},
145+
function (error) {
146+
if (callback && typeof callback === 'function') {
147+
return callback(error)
148+
}
149+
return Promise.reject(error)
150+
}
151+
)
152+
}
153+
154+
/**
155+
* 设置余额预警信息
156+
* @param {Object} opts - parameters
157+
* @param {balanceWarningInfoVo} opts.balanceWarningInfoVo
158+
* @param {string} regionId - ID of the region
159+
* @param {string} callback - callback
160+
@return {Object} result
161+
* @param boolean status
162+
*/
163+
164+
modifyBalanceWarningInfo (opts, regionId = this.config.regionId, callback) {
165+
if (typeof regionId === 'function') {
166+
callback = regionId
167+
regionId = this.config.regionId
168+
}
169+
170+
if (regionId === undefined || regionId === null) {
171+
throw new Error(
172+
"Missing the required parameter 'regionId' when calling modifyBalanceWarningInfo"
173+
)
174+
}
175+
176+
opts = opts || {}
177+
178+
if (
179+
opts.balanceWarningInfoVo === undefined ||
180+
opts.balanceWarningInfoVo === null
181+
) {
182+
throw new Error(
183+
"Missing the required parameter 'opts.balanceWarningInfoVo' when calling modifyBalanceWarningInfo"
184+
)
185+
}
186+
187+
let postBody = {}
188+
if (
189+
opts.balanceWarningInfoVo !== undefined &&
190+
opts.balanceWarningInfoVo !== null
191+
) {
192+
postBody['balanceWarningInfoVo'] = opts.balanceWarningInfoVo
193+
}
194+
195+
let queryParams = {}
196+
197+
let pathParams = {
198+
regionId: regionId
199+
}
200+
201+
let headerParams = {
202+
'User-Agent': 'JdcloudSdkNode/1.0.0 asset/0.0.2'
203+
}
204+
205+
let contentTypes = ['application/json']
206+
let accepts = ['application/json']
207+
208+
// 扩展自定义头
209+
if (opts['x-extra-header']) {
210+
for (let extraHeader in opts['x-extra-header']) {
211+
headerParams[extraHeader] = opts['x-extra-header'][extraHeader]
212+
}
213+
214+
if (Array.isArray(opts['x-extra-header']['content-type'])) {
215+
contentTypes = opts['x-extra-header']['content-type']
216+
} else if (typeof opts['x-extra-header']['content-type'] === 'string') {
217+
contentTypes = opts['x-extra-header']['content-type'].split(',')
218+
}
219+
220+
if (Array.isArray(opts['x-extra-header']['accept'])) {
221+
accepts = opts['x-extra-header']['accept']
222+
} else if (typeof opts['x-extra-header']['accept'] === 'string') {
223+
accepts = opts['x-extra-header']['accept'].split(',')
224+
}
225+
}
226+
227+
let formParams = {}
228+
229+
let returnType = null
230+
231+
this.config.logger(
232+
`call modifyBalanceWarningInfo with params:\npathParams:${JSON.stringify(
233+
pathParams
234+
)},\nqueryParams:${JSON.stringify(
235+
queryParams
236+
)}, \nheaderParams:${JSON.stringify(
237+
headerParams
238+
)}, \nformParams:${JSON.stringify(
239+
formParams
240+
)}, \npostBody:${JSON.stringify(postBody)}`,
241+
'DEBUG'
242+
)
243+
244+
let request = super.makeRequest(
245+
'/regions/{regionId}/assets:modifyBalanceWarningInfo',
246+
'POST',
247+
pathParams,
248+
queryParams,
249+
headerParams,
250+
formParams,
251+
postBody,
252+
contentTypes,
253+
accepts,
254+
returnType,
255+
callback
256+
)
257+
258+
return request.then(
259+
function (result) {
260+
if (callback && typeof callback === 'function') {
261+
return callback(null, result)
262+
}
263+
return result
264+
},
265+
function (error) {
266+
if (callback && typeof callback === 'function') {
267+
return callback(error)
268+
}
269+
return Promise.reject(error)
270+
}
271+
)
272+
}
273+
}
274+
module.exports = ASSET

src/services/all.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,6 @@ module.exports = {
7979
IOTCLOUDGATEWAY: require('./iotcloudgateway'),
8080
INDUSTRYDATA: require('./industrydata'),
8181
JDW: require('./jdw'),
82+
ASSET: require('./asset'),
8283
USER: require('./user')
8384
}

src/services/asset.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
* JDCLOUD asset API
17+
* API JDCLOUD asset API
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+
const JDCloud = require('../lib/core')
26+
var Service = JDCloud.Service
27+
var serviceId = 'asset'
28+
Service._services[serviceId] = true
29+
30+
/**
31+
* asset service.
32+
*/
33+
34+
JDCloud.ASSET = class ASSET {
35+
constructor (config = {}) {
36+
this.init(config)
37+
return new this.service(config)
38+
}
39+
init (config) {
40+
let serviceName = 'asset'
41+
let version = config.version || JDCloud.config.version
42+
let versionFlag = 'v1'
43+
if (version && version[serviceName]) {
44+
versionFlag = version[serviceName]
45+
}
46+
try {
47+
this.service = require(`../repo/${serviceName}/${versionFlag}/${serviceName}`)
48+
} catch (e) {
49+
throw new Error(
50+
`The version '${versionFlag}' of API ${serviceName} is undefined!`
51+
)
52+
}
53+
}
54+
}
55+
56+
module.exports = JDCloud.ASSET

0 commit comments

Comments
 (0)