particle-api-js 10.3.1 → 10.4.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "particle-api-js",
3
- "version": "10.3.1",
3
+ "version": "10.4.1",
4
4
  "description": "Particle API Client",
5
5
  "main": "src/Particle.js",
6
6
  "scripts": {
package/src/Particle.js CHANGED
@@ -2485,17 +2485,17 @@ class Particle {
2485
2485
  * @param {string} [options.org] The Organization ID or slug. If not provided, the request will go to your sandbox account.
2486
2486
  * @param {string} options.ledgerName Ledger name.
2487
2487
  * @param {string} options.scopeValue Scope value.
2488
- * @param {object} options.data The data to set to the instance
2488
+ * @param {object} options.instance The instance with the data
2489
2489
  * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2490
2490
  * @param {Object} [options.context] Request context.
2491
2491
  *
2492
2492
  * @returns {Promise<RequestResponse>} A promise that resolves to the updated ledger instance data.
2493
2493
  */
2494
- setLedgerInstance({ auth, org, ledgerName, scopeValue, data, headers, context }) {
2494
+ setLedgerInstance({ auth, org, ledgerName, scopeValue, instance, headers, context }) {
2495
2495
  return this.put({
2496
2496
  uri: this._namespacedPath(org, `ledgers/${ledgerName}/instances/${scopeValue}`),
2497
2497
  auth,
2498
- data: { data },
2498
+ data: { instance },
2499
2499
  headers,
2500
2500
  context
2501
2501
  });
@@ -2550,6 +2550,57 @@ class Particle {
2550
2550
  });
2551
2551
  }
2552
2552
 
2553
+ /**
2554
+ * List ledger instance versions
2555
+ *
2556
+ * @param {Object} options The options for the ledger instance.
2557
+ * @param {Auth} [options.auth] The access token or basic auth object. Can be ignored if provided in constructor
2558
+ * @param {string} [options.org] The Organization ID or slug. If not provided, the request will go to your sandbox account.
2559
+ * @param {string} options.ledgerName Ledger name.
2560
+ * @param {string} options.scopeValue Scope value.
2561
+ * @param {string} [options.replacedBefore] ISO date string to filter to instances replaced before this time
2562
+ * @param {string} [options.replacedAfter] ISO date string to filter to instances replaced after this time
2563
+ * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2564
+ * @param {Object} [options.context] Request context
2565
+ *
2566
+ * @returns {Promise<RequestResponse>} A promise that resolves to an array of ledger instance data.
2567
+ */
2568
+ listLedgerInstanceVersions({ auth, org, ledgerName, scopeValue, replacedBefore, replacedAfter, headers, context }) {
2569
+ return this.get({
2570
+ uri: this._namespacedPath(org, `ledgers/${ledgerName}/instances/${scopeValue}/versions`),
2571
+ query: {
2572
+ replaced_before: replacedBefore,
2573
+ replaced_after: replacedAfter
2574
+ },
2575
+ auth,
2576
+ headers,
2577
+ context
2578
+ });
2579
+ }
2580
+
2581
+ /**
2582
+ * Get specific ledger instance version
2583
+ *
2584
+ * @param {Object} options The options for the ledger instance.
2585
+ * @param {Auth} [options.auth] The access token or basic auth object. Can be ignored if provided in constructor
2586
+ * @param {string} [options.org] The Organization ID or slug. If not provided, the request will go to your sandbox account.
2587
+ * @param {string} options.ledgerName Ledger name.
2588
+ * @param {string} options.scopeValue Scope value.
2589
+ * @param {string} options.version Version of the ledger instance
2590
+ * @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
2591
+ * @param {Object} [options.context] Request context
2592
+ *
2593
+ * @returns {Promise<RequestResponse>} A promise that resolves to the specified ledger instance data.
2594
+ */
2595
+ getLedgerInstanceVersion({ auth, org, ledgerName, scopeValue, version, headers, context }) {
2596
+ return this.get({
2597
+ uri: this._namespacedPath(org, `ledgers/${ledgerName}/instances/${scopeValue}/versions/${version}`),
2598
+ auth,
2599
+ headers,
2600
+ context
2601
+ });
2602
+ }
2603
+
2553
2604
  /**
2554
2605
  * Set default auth token that will be used in each method if `auth` is not provided
2555
2606
  * @param {Auth} auth The access token or basic auth object
@@ -142,7 +142,10 @@ const props = {
142
142
  description: 'my ledger',
143
143
  direction: 'Downstream'
144
144
  },
145
- scopeValue: '1234'
145
+ scopeValue: '1234',
146
+ instance: {
147
+ property: 'yes'
148
+ }
146
149
  };
147
150
 
148
151
  const product = 'ze-product-v1';
@@ -2869,8 +2872,8 @@ describe('ParticleAPI', () => {
2869
2872
  uri: `/v1/orgs/${org}/ledgers/${props.ledgerName}/instances/${props.scopeValue}`,
2870
2873
  auth: props.auth,
2871
2874
  data: {
2872
- data: {
2873
- sentient: true
2875
+ instance: {
2876
+ property: 'yes'
2874
2877
  }
2875
2878
  }
2876
2879
  });
@@ -2901,6 +2904,30 @@ describe('ParticleAPI', () => {
2901
2904
  });
2902
2905
  });
2903
2906
  });
2907
+
2908
+ describe('listLedgerInstanceVersions', () => {
2909
+ it('generates request', () => {
2910
+ return api.listLedgerInstanceVersions(propsWithOrg).then((results) => {
2911
+ results.should.match({
2912
+ method: 'get',
2913
+ uri: `/v1/orgs/${org}/ledgers/${props.ledgerName}/instances/${props.scopeValue}/versions`,
2914
+ auth: props.auth
2915
+ });
2916
+ });
2917
+ });
2918
+ });
2919
+
2920
+ describe('.getLedgerInstanceVersion', () => {
2921
+ it('generates request', () => {
2922
+ return api.getLedgerInstanceVersion(propsWithOrg).then((results) => {
2923
+ results.should.match({
2924
+ method: 'get',
2925
+ uri: `/v1/orgs/${org}/ledgers/${props.ledgerName}/instances/${props.scopeValue}/versions/${props.version}`,
2926
+ auth: props.auth
2927
+ });
2928
+ });
2929
+ });
2930
+ });
2904
2931
  });
2905
2932
 
2906
2933
  describe('backwards-compatibility function aliases', () => {