particle-api-js 10.4.1 → 10.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/particle.min.js +1 -1
- package/dist/particle.min.js.map +1 -1
- package/docs/api.md +652 -564
- package/package.json +1 -1
- package/src/Agent.js +6 -5
- package/src/Particle.js +34 -23
- package/test/Agent.spec.js +2 -2
- package/test/FakeAgent.js +3 -3
- package/test/Particle.spec.js +46 -72
package/package.json
CHANGED
package/src/Agent.js
CHANGED
|
@@ -103,7 +103,7 @@ class Agent {
|
|
|
103
103
|
* @param {string} params.uri The URI to request
|
|
104
104
|
* @param {Auth} [params.auth] Authorization token to use
|
|
105
105
|
* @param {object} [params.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
106
|
-
* @param {object} [params.data]
|
|
106
|
+
* @param {object} [params.data] Request body
|
|
107
107
|
* @param {object} [params.context] The invocation context, describing the tool and project
|
|
108
108
|
* @returns {Promise<RequestResponse, RequestError>} A promise that resolves with either the requested data or an error object
|
|
109
109
|
*/
|
|
@@ -117,12 +117,13 @@ class Agent {
|
|
|
117
117
|
* @param {string} params.uri The URI to request
|
|
118
118
|
* @param {Auth} [params.auth] Authorization token to use
|
|
119
119
|
* @param {object} [params.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
120
|
-
* @param {object} [params.data]
|
|
120
|
+
* @param {object} [params.data] Request body
|
|
121
|
+
* @param {object} [params.query] Key/Value pairs of query params or a correctly formatted string
|
|
121
122
|
* @param {object} [params.context] The invocation context, describing the tool and project
|
|
122
123
|
* @returns {Promise<RequestResponse, RequestError>} A promise that resolves with either the requested data or an error object
|
|
123
124
|
*/
|
|
124
|
-
put({ uri, auth, headers, data, context }) {
|
|
125
|
-
return this.request({ uri, method: 'put', auth, headers, data, context });
|
|
125
|
+
put({ uri, auth, headers, data, query, context }) {
|
|
126
|
+
return this.request({ uri, method: 'put', auth, headers, data, query, context });
|
|
126
127
|
}
|
|
127
128
|
|
|
128
129
|
/**
|
|
@@ -131,7 +132,7 @@ class Agent {
|
|
|
131
132
|
* @param {string} params.uri The URI to request
|
|
132
133
|
* @param {Auth} [params.auth] Authorization token to use
|
|
133
134
|
* @param {object} [params.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
134
|
-
* @param {object} [params.data]
|
|
135
|
+
* @param {object} [params.data] Request body
|
|
135
136
|
* @param {object} [params.context] The invocation context, describing the tool and project
|
|
136
137
|
* @returns {Promise<RequestResponse, RequestError>} A promise that resolves with either the requested data or an error object
|
|
137
138
|
*/
|
package/src/Particle.js
CHANGED
|
@@ -243,18 +243,20 @@ class Particle {
|
|
|
243
243
|
* @param {String} options.username Email of the new user
|
|
244
244
|
* @param {String} options.password Password
|
|
245
245
|
* @param {String} options.accountInfo Object that contains account information fields such as user real name, company name, business account flag etc
|
|
246
|
+
* @param {Object} [options.utm] Object that contains info about the campaign that lead to this user creation
|
|
246
247
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
247
248
|
* @param {Object} [options.context] Request context
|
|
248
249
|
* @returns {Promise} A promise
|
|
249
250
|
*/
|
|
250
|
-
createUser({ username, password, accountInfo, headers, context }){
|
|
251
|
+
createUser({ username, password, accountInfo, utm, headers, context }){
|
|
251
252
|
return this.post({
|
|
252
253
|
uri: '/v1/users',
|
|
253
254
|
headers,
|
|
254
255
|
data: {
|
|
255
256
|
username,
|
|
256
257
|
password,
|
|
257
|
-
account_info
|
|
258
|
+
account_info: accountInfo,
|
|
259
|
+
utm
|
|
258
260
|
},
|
|
259
261
|
context
|
|
260
262
|
});
|
|
@@ -2162,7 +2164,7 @@ class Particle {
|
|
|
2162
2164
|
* @param {Object} options The options for creating the logic function.
|
|
2163
2165
|
* @param {Auth} [options.auth] The access token or basic auth object. Can be ignored if provided in constructor
|
|
2164
2166
|
* @param {string} [options.org] The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2165
|
-
* @param {
|
|
2167
|
+
* @param {Object} options.logicFunction The logic function object containing the function details.
|
|
2166
2168
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2167
2169
|
* @param {Object} [options.context] Request context
|
|
2168
2170
|
*
|
|
@@ -2208,7 +2210,7 @@ class Particle {
|
|
|
2208
2210
|
* @param {Auth} [options.auth] The access token or basic auth object. Can be ignored if provided in constructor
|
|
2209
2211
|
* @param {string} [options.org] The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2210
2212
|
* @param {string} options.logicFunctionId The ID of the logic function to update.
|
|
2211
|
-
* @param {
|
|
2213
|
+
* @param {Object} options.logicFunction The logic function object containing the logic function details.
|
|
2212
2214
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2213
2215
|
* @param {Object} [options.context] Request context.
|
|
2214
2216
|
*
|
|
@@ -2275,7 +2277,7 @@ class Particle {
|
|
|
2275
2277
|
* @param {Object} options The options for the request.
|
|
2276
2278
|
* @param {Auth} [options.auth] The access token or basic auth object. Can be ignored if provided in constructor
|
|
2277
2279
|
* @param {string} [options.org] The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2278
|
-
* @param {
|
|
2280
|
+
* @param {string} options.logicFunctionId The ID of the logic function for which to retrieve the logic runs.
|
|
2279
2281
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2280
2282
|
* @param {Object} [options.context] Request context
|
|
2281
2283
|
*
|
|
@@ -2296,8 +2298,8 @@ class Particle {
|
|
|
2296
2298
|
* @param {Object} options The options for the request.
|
|
2297
2299
|
* @param {Auth} [options.auth] The access token or basic auth object. Can be ignored if provided in constructor
|
|
2298
2300
|
* @param {string} [options.org] The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2299
|
-
* @param {
|
|
2300
|
-
* @param {
|
|
2301
|
+
* @param {string} options.logicFunctionId The ID of the logic function for which to retrieve the logic run.
|
|
2302
|
+
* @param {string} options.logicRunId The ID of the logic run to retrieve.
|
|
2301
2303
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2302
2304
|
* @param {Object} [options.context] Request context
|
|
2303
2305
|
*
|
|
@@ -2318,8 +2320,8 @@ class Particle {
|
|
|
2318
2320
|
* @param {Object} options The options for the request.
|
|
2319
2321
|
* @param {Auth} [options.auth] The access token or basic auth object. Can be ignored if provided in constructor
|
|
2320
2322
|
* @param {string} [options.org] The unique identifier of the organization.
|
|
2321
|
-
* @param {
|
|
2322
|
-
* @param {
|
|
2323
|
+
* @param {string} options.logicFunctionId The ID of the logic function for which to retrieve the logic run logs.
|
|
2324
|
+
* @param {string} options.logicRunId The ID of the logic run for which to retrieve the logs.
|
|
2323
2325
|
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2324
2326
|
* @param {Object} [options.context] Request context
|
|
2325
2327
|
*
|
|
@@ -2477,23 +2479,31 @@ class Particle {
|
|
|
2477
2479
|
});
|
|
2478
2480
|
}
|
|
2479
2481
|
|
|
2482
|
+
/**
|
|
2483
|
+
* @typedef {"Replace" | "Merge"} SetMode
|
|
2484
|
+
*/
|
|
2485
|
+
|
|
2480
2486
|
/**
|
|
2481
2487
|
* Set ledger instance data.
|
|
2482
2488
|
*
|
|
2483
|
-
* @param {Object}
|
|
2484
|
-
* @param {Auth}
|
|
2485
|
-
* @param {string}
|
|
2486
|
-
* @param {string}
|
|
2487
|
-
* @param {string}
|
|
2488
|
-
* @param {object}
|
|
2489
|
-
* @param {
|
|
2490
|
-
* @param {Object}
|
|
2489
|
+
* @param {Object} options The options for updating the ledger instance.
|
|
2490
|
+
* @param {Auth} [options.auth] The access token or basic auth object. Can be ignored if provided in constructor
|
|
2491
|
+
* @param {string} [options.org] The Organization ID or slug. If not provided, the request will go to your sandbox account.
|
|
2492
|
+
* @param {string} options.ledgerName Ledger name.
|
|
2493
|
+
* @param {string} options.scopeValue Scope value.
|
|
2494
|
+
* @param {object} options.instance The instance with the data
|
|
2495
|
+
* @param {SetMode} [options.setMode] How the data should be set with existing data. Default is "Replace"
|
|
2496
|
+
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2497
|
+
* @param {Object} [options.context] Request context.
|
|
2491
2498
|
*
|
|
2492
2499
|
* @returns {Promise<RequestResponse>} A promise that resolves to the updated ledger instance data.
|
|
2493
2500
|
*/
|
|
2494
|
-
setLedgerInstance({ auth, org, ledgerName, scopeValue, instance, headers, context }) {
|
|
2501
|
+
setLedgerInstance({ auth, org, ledgerName, scopeValue, instance, setMode, headers, context }) {
|
|
2495
2502
|
return this.put({
|
|
2496
2503
|
uri: this._namespacedPath(org, `ledgers/${ledgerName}/instances/${scopeValue}`),
|
|
2504
|
+
query: {
|
|
2505
|
+
set_mode: setMode
|
|
2506
|
+
},
|
|
2497
2507
|
auth,
|
|
2498
2508
|
data: { instance },
|
|
2499
2509
|
headers,
|
|
@@ -2685,7 +2695,7 @@ class Particle {
|
|
|
2685
2695
|
* @param {string} params.uri The URI to request
|
|
2686
2696
|
* @param {Auth} [params.auth] Authorization token to use
|
|
2687
2697
|
* @param {object} [params.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2688
|
-
* @param {string | object} [params.data]
|
|
2698
|
+
* @param {string | object} [params.data] Request body
|
|
2689
2699
|
* @param {object} [params.context] The invocation context, describing the tool and project
|
|
2690
2700
|
* @returns {Promise<RequestResponse, RequestError>} A promise that resolves with either the requested data or an error object
|
|
2691
2701
|
*/
|
|
@@ -2701,14 +2711,15 @@ class Particle {
|
|
|
2701
2711
|
* @param {string} params.uri The URI to request
|
|
2702
2712
|
* @param {Auth} [params.auth] Authorization token to use
|
|
2703
2713
|
* @param {object} [params.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2704
|
-
* @param {string | object} [params.data]
|
|
2714
|
+
* @param {string | object} [params.data] Request body
|
|
2715
|
+
* @param {object} [params.query] Key/Value pairs of query params or a correctly formatted string
|
|
2705
2716
|
* @param {object} [params.context] The invocation context, describing the tool and project
|
|
2706
2717
|
* @returns {Promise<RequestResponse, RequestError>} A promise that resolves with either the requested data or an error object
|
|
2707
2718
|
*/
|
|
2708
|
-
put({ uri, auth, headers, data, context }){
|
|
2719
|
+
put({ uri, auth, headers, data, query, context }){
|
|
2709
2720
|
context = this._buildContext(context);
|
|
2710
2721
|
auth = this._getActiveAuthToken(auth);
|
|
2711
|
-
return this.agent.put({ uri, auth, headers, data, context });
|
|
2722
|
+
return this.agent.put({ uri, auth, headers, data, query, context });
|
|
2712
2723
|
}
|
|
2713
2724
|
|
|
2714
2725
|
/**
|
|
@@ -2717,7 +2728,7 @@ class Particle {
|
|
|
2717
2728
|
* @param {string} params.uri The URI to request
|
|
2718
2729
|
* @param {Auth} [params.auth] Authorization token to use
|
|
2719
2730
|
* @param {object} [params.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
|
|
2720
|
-
* @param {string | object} [params.data]
|
|
2731
|
+
* @param {string | object} [params.data] Request body
|
|
2721
2732
|
* @param {object} [params.context] The invocation context, describing the tool and project
|
|
2722
2733
|
* @returns {Promise<RequestResponse, RequestError>} A promise that resolves with either the requested data or an error object
|
|
2723
2734
|
*/
|
package/test/Agent.spec.js
CHANGED
|
@@ -78,8 +78,8 @@ describe('Agent', () => {
|
|
|
78
78
|
|
|
79
79
|
it('can PUT a resource', () => {
|
|
80
80
|
method = 'put';
|
|
81
|
-
return agent.put({ uri, auth, headers, data, context }).then(() => {
|
|
82
|
-
expect(agent.request).to.be.calledWith({ uri, method, auth, headers, data, context });
|
|
81
|
+
return agent.put({ uri, auth, headers, data, context, query }).then(() => {
|
|
82
|
+
expect(agent.request).to.be.calledWith({ uri, method, auth, headers, data, context, query });
|
|
83
83
|
});
|
|
84
84
|
});
|
|
85
85
|
|
package/test/FakeAgent.js
CHANGED
|
@@ -11,8 +11,8 @@ class FakeAgent {
|
|
|
11
11
|
return this.request({ uri, method: 'post', auth, headers, data, context });
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
put({ uri, auth, headers, data, context }){
|
|
15
|
-
return this.request({ uri, method: 'put', auth, headers, data, context });
|
|
14
|
+
put({ uri, auth, headers, data, query, context }){
|
|
15
|
+
return this.request({ uri, method: 'put', auth, headers, data, query, context });
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
delete({ uri, auth, headers, data, context }){
|
|
@@ -20,7 +20,7 @@ class FakeAgent {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
request(opts){
|
|
23
|
-
return
|
|
23
|
+
return Promise.resolve(opts);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
module.exports = FakeAgent;
|
package/test/Particle.spec.js
CHANGED
|
@@ -66,7 +66,7 @@ const props = {
|
|
|
66
66
|
clientId: 'client-123',
|
|
67
67
|
type: 'web',
|
|
68
68
|
redirect_uri: 'https://example.com',
|
|
69
|
-
scope: '',
|
|
69
|
+
scope: 'Owner',
|
|
70
70
|
deviceName: 'test-device',
|
|
71
71
|
page: 5,
|
|
72
72
|
perPage: 50,
|
|
@@ -78,7 +78,7 @@ const props = {
|
|
|
78
78
|
notes: 'A fancy Photon',
|
|
79
79
|
desiredFirmwareVersion: 42,
|
|
80
80
|
flash: false,
|
|
81
|
-
version: 42,
|
|
81
|
+
version: '42',
|
|
82
82
|
title: 'prod',
|
|
83
83
|
description: 'ready for production',
|
|
84
84
|
file: new Buffer('ELF...'),
|
|
@@ -96,8 +96,8 @@ const props = {
|
|
|
96
96
|
dateRange: '2020-05-15T18:29:45.000Z,2020-05-19T18:29:45.000Z',
|
|
97
97
|
rectBl: '56.185412,-4.049868',
|
|
98
98
|
rectTr: '56.571537,-5.385920',
|
|
99
|
-
logicFunctionId:
|
|
100
|
-
logicRunId:
|
|
99
|
+
logicFunctionId: 'ea838324-a4a7-4fa6-b278-95bdaed7114b',
|
|
100
|
+
logicRunId: 'd0580956-71dc-4f11-89e2-987dcf82a86f',
|
|
101
101
|
logicFunction: {
|
|
102
102
|
enabled: true,
|
|
103
103
|
name: 'function-1',
|
|
@@ -140,12 +140,13 @@ const props = {
|
|
|
140
140
|
scope: 'Owner',
|
|
141
141
|
name: 'myledger',
|
|
142
142
|
description: 'my ledger',
|
|
143
|
-
direction: '
|
|
143
|
+
direction: 'CloudOnly'
|
|
144
144
|
},
|
|
145
|
-
scopeValue: '
|
|
145
|
+
scopeValue: 'abc1234',
|
|
146
146
|
instance: {
|
|
147
147
|
property: 'yes'
|
|
148
|
-
}
|
|
148
|
+
},
|
|
149
|
+
setMode: 'Replace'
|
|
149
150
|
};
|
|
150
151
|
|
|
151
152
|
const product = 'ze-product-v1';
|
|
@@ -315,6 +316,7 @@ describe('ParticleAPI', () => {
|
|
|
315
316
|
method: 'put',
|
|
316
317
|
auth: props.auth,
|
|
317
318
|
headers: props.headers,
|
|
319
|
+
query: undefined,
|
|
318
320
|
data: {
|
|
319
321
|
current_password: props.password,
|
|
320
322
|
},
|
|
@@ -350,7 +352,28 @@ describe('ParticleAPI', () => {
|
|
|
350
352
|
data: {
|
|
351
353
|
username: props.username,
|
|
352
354
|
password: props.password,
|
|
353
|
-
account_info: props.accountInfo
|
|
355
|
+
account_info: props.accountInfo,
|
|
356
|
+
utm: undefined
|
|
357
|
+
},
|
|
358
|
+
context: {}
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
it('allows sending utm parameters', () => {
|
|
363
|
+
props.utm = { utm_source: 'web' };
|
|
364
|
+
return api.createUser(props).then(( results ) => {
|
|
365
|
+
results.should.eql({
|
|
366
|
+
uri: '/v1/users',
|
|
367
|
+
method: 'post',
|
|
368
|
+
auth: undefined,
|
|
369
|
+
headers: props.headers,
|
|
370
|
+
data: {
|
|
371
|
+
username: props.username,
|
|
372
|
+
password: props.password,
|
|
373
|
+
account_info: props.accountInfo,
|
|
374
|
+
utm: {
|
|
375
|
+
utm_source: 'web'
|
|
376
|
+
}
|
|
354
377
|
},
|
|
355
378
|
context: {}
|
|
356
379
|
});
|
|
@@ -1462,6 +1485,7 @@ describe('ParticleAPI', () => {
|
|
|
1462
1485
|
method: 'put',
|
|
1463
1486
|
auth: 'X',
|
|
1464
1487
|
headers: undefined,
|
|
1488
|
+
query: undefined,
|
|
1465
1489
|
data: {
|
|
1466
1490
|
account_info: { first_name: 'John', last_name: 'Scully' }
|
|
1467
1491
|
},
|
|
@@ -1480,6 +1504,7 @@ describe('ParticleAPI', () => {
|
|
|
1480
1504
|
method: 'put',
|
|
1481
1505
|
auth: 'X',
|
|
1482
1506
|
headers: undefined,
|
|
1507
|
+
query: undefined,
|
|
1483
1508
|
data: {
|
|
1484
1509
|
current_password: 'blabla',
|
|
1485
1510
|
username: 'john@skul.ly'
|
|
@@ -1496,6 +1521,7 @@ describe('ParticleAPI', () => {
|
|
|
1496
1521
|
method: 'put',
|
|
1497
1522
|
auth: 'X',
|
|
1498
1523
|
headers: undefined,
|
|
1524
|
+
query: undefined,
|
|
1499
1525
|
data: {
|
|
1500
1526
|
current_password: 'blabla',
|
|
1501
1527
|
username: 'john@skul.ly',
|
|
@@ -1516,6 +1542,7 @@ describe('ParticleAPI', () => {
|
|
|
1516
1542
|
method: 'put',
|
|
1517
1543
|
auth: 'X',
|
|
1518
1544
|
headers: undefined,
|
|
1545
|
+
query: undefined,
|
|
1519
1546
|
data: {
|
|
1520
1547
|
current_password: 'blabla',
|
|
1521
1548
|
password: 'blabla2'
|
|
@@ -1533,6 +1560,7 @@ describe('ParticleAPI', () => {
|
|
|
1533
1560
|
uri: '/v1/user',
|
|
1534
1561
|
auth: 'X',
|
|
1535
1562
|
headers: undefined,
|
|
1563
|
+
query: undefined,
|
|
1536
1564
|
data: {
|
|
1537
1565
|
current_password: 'blabla',
|
|
1538
1566
|
password: 'blabla2',
|
|
@@ -2622,30 +2650,7 @@ describe('ParticleAPI', () => {
|
|
|
2622
2650
|
uri: `/v1/orgs/${org}/logic/functions`,
|
|
2623
2651
|
auth: props.auth,
|
|
2624
2652
|
data: {
|
|
2625
|
-
logic_function:
|
|
2626
|
-
enabled: true,
|
|
2627
|
-
name: 'function-1',
|
|
2628
|
-
description: 'hello world',
|
|
2629
|
-
source: {
|
|
2630
|
-
type: 'JavaScript',
|
|
2631
|
-
code: 'console.log("hello from function-1");'
|
|
2632
|
-
},
|
|
2633
|
-
logic_triggers: [
|
|
2634
|
-
{
|
|
2635
|
-
type: 'Event',
|
|
2636
|
-
enabled: true,
|
|
2637
|
-
product_id: parseInt(props.productId),
|
|
2638
|
-
event_name: props.event,
|
|
2639
|
-
},
|
|
2640
|
-
{
|
|
2641
|
-
type: 'Scheduled',
|
|
2642
|
-
enabled: true,
|
|
2643
|
-
cron: '0 0 1 * *',
|
|
2644
|
-
start_at: '2021-05-15T18:29:45.000Z',
|
|
2645
|
-
end_at: '2021-05-19T18:29:45.000Z',
|
|
2646
|
-
}
|
|
2647
|
-
]
|
|
2648
|
-
}
|
|
2653
|
+
logic_function: props.logicFunction
|
|
2649
2654
|
}
|
|
2650
2655
|
});
|
|
2651
2656
|
});
|
|
@@ -2672,30 +2677,7 @@ describe('ParticleAPI', () => {
|
|
|
2672
2677
|
uri: `/v1/orgs/${org}/logic/functions/${props.logicFunctionId}`,
|
|
2673
2678
|
auth: props.auth,
|
|
2674
2679
|
data: {
|
|
2675
|
-
logic_function:
|
|
2676
|
-
enabled: true,
|
|
2677
|
-
name: 'function-1',
|
|
2678
|
-
description: 'hello world',
|
|
2679
|
-
source: {
|
|
2680
|
-
type: 'JavaScript',
|
|
2681
|
-
code: 'console.log("hello from function-1");'
|
|
2682
|
-
},
|
|
2683
|
-
logic_triggers: [
|
|
2684
|
-
{
|
|
2685
|
-
type: 'Event',
|
|
2686
|
-
enabled: true,
|
|
2687
|
-
product_id: parseInt(props.productId),
|
|
2688
|
-
event_name: props.event,
|
|
2689
|
-
},
|
|
2690
|
-
{
|
|
2691
|
-
type: 'Scheduled',
|
|
2692
|
-
enabled: true,
|
|
2693
|
-
cron: '0 0 1 * *',
|
|
2694
|
-
start_at: '2021-05-15T18:29:45.000Z',
|
|
2695
|
-
end_at: '2021-05-19T18:29:45.000Z',
|
|
2696
|
-
}
|
|
2697
|
-
]
|
|
2698
|
-
}
|
|
2680
|
+
logic_function: props.logicFunction
|
|
2699
2681
|
}
|
|
2700
2682
|
});
|
|
2701
2683
|
});
|
|
@@ -2784,12 +2766,7 @@ describe('ParticleAPI', () => {
|
|
|
2784
2766
|
uri: `/v1/orgs/${org}/ledgers`,
|
|
2785
2767
|
auth: props.auth,
|
|
2786
2768
|
data: {
|
|
2787
|
-
ledger:
|
|
2788
|
-
scope: 'Owner',
|
|
2789
|
-
name: 'myledger',
|
|
2790
|
-
description: 'my ledger',
|
|
2791
|
-
direction: 'Downstream'
|
|
2792
|
-
}
|
|
2769
|
+
ledger: props.ledger
|
|
2793
2770
|
}
|
|
2794
2771
|
});
|
|
2795
2772
|
});
|
|
@@ -2816,12 +2793,7 @@ describe('ParticleAPI', () => {
|
|
|
2816
2793
|
uri: `/v1/orgs/${org}/ledgers/${props.ledgerName}`,
|
|
2817
2794
|
auth: props.auth,
|
|
2818
2795
|
data: {
|
|
2819
|
-
ledger:
|
|
2820
|
-
scope: 'Owner',
|
|
2821
|
-
name: 'myledger',
|
|
2822
|
-
description: 'my ledger',
|
|
2823
|
-
direction: 'Downstream'
|
|
2824
|
-
}
|
|
2796
|
+
ledger: props.ledger
|
|
2825
2797
|
}
|
|
2826
2798
|
});
|
|
2827
2799
|
});
|
|
@@ -2870,11 +2842,12 @@ describe('ParticleAPI', () => {
|
|
|
2870
2842
|
results.should.match({
|
|
2871
2843
|
method: 'put',
|
|
2872
2844
|
uri: `/v1/orgs/${org}/ledgers/${props.ledgerName}/instances/${props.scopeValue}`,
|
|
2845
|
+
query: {
|
|
2846
|
+
set_mode: props.setMode
|
|
2847
|
+
},
|
|
2873
2848
|
auth: props.auth,
|
|
2874
2849
|
data: {
|
|
2875
|
-
instance:
|
|
2876
|
-
property: 'yes'
|
|
2877
|
-
}
|
|
2850
|
+
instance: props.instance
|
|
2878
2851
|
}
|
|
2879
2852
|
});
|
|
2880
2853
|
});
|
|
@@ -3073,7 +3046,7 @@ describe('ParticleAPI', () => {
|
|
|
3073
3046
|
|
|
3074
3047
|
it('calls _buildContext and _getActiveAuthToken from put', () => {
|
|
3075
3048
|
api.agent.put = sinon.stub().returns(result);
|
|
3076
|
-
const options = { uri, auth, headers, data, context };
|
|
3049
|
+
const options = { uri, auth, headers, data, context, query };
|
|
3077
3050
|
const res = api.put(options);
|
|
3078
3051
|
expect(res).to.equal(result);
|
|
3079
3052
|
expect(api.agent.put).to.have.been.calledWith({
|
|
@@ -3081,6 +3054,7 @@ describe('ParticleAPI', () => {
|
|
|
3081
3054
|
auth,
|
|
3082
3055
|
headers,
|
|
3083
3056
|
data,
|
|
3057
|
+
query,
|
|
3084
3058
|
context: contextResult
|
|
3085
3059
|
});
|
|
3086
3060
|
});
|