Skip to content

Commit

Permalink
Merge pull request #179 from particle-iot/feature/sc-124365/particle-…
Browse files Browse the repository at this point in the history
…api-js-fix-setledgerinstance-having

feat: [sc-124365] Fix setLedgerInstance Having Wrong Request Body
  • Loading branch information
cole-abbeduto-particle committed Jan 2, 2024
2 parents b19e641 + 2c4ab73 commit 23cdac8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Particle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2485,17 +2485,17 @@ class Particle {
* @param {string} [options.org] The Organization ID or slug. If not provided, the request will go to your sandbox account.
* @param {string} options.ledgerName Ledger name.
* @param {string} options.scopeValue Scope value.
* @param {object} options.data The data to set to the instance
* @param {object} options.instance The instance with the data
* @param {Object} [options.headers] Key/Value pairs like `{ 'X-FOO': 'foo', X-BAR: 'bar' }` to send as headers.
* @param {Object} [options.context] Request context.
*
* @returns {Promise<RequestResponse>} A promise that resolves to the updated ledger instance data.
*/
setLedgerInstance({ auth, org, ledgerName, scopeValue, data, headers, context }) {
setLedgerInstance({ auth, org, ledgerName, scopeValue, instance, headers, context }) {
return this.put({
uri: this._namespacedPath(org, `ledgers/${ledgerName}/instances/${scopeValue}`),
auth,
data: { data },
data: { instance },
headers,
context
});
Expand Down
9 changes: 6 additions & 3 deletions test/Particle.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ const props = {
description: 'my ledger',
direction: 'Downstream'
},
scopeValue: '1234'
scopeValue: '1234',
instance: {
property: 'yes'
}
};

const product = 'ze-product-v1';
Expand Down Expand Up @@ -2869,8 +2872,8 @@ describe('ParticleAPI', () => {
uri: `/v1/orgs/${org}/ledgers/${props.ledgerName}/instances/${props.scopeValue}`,
auth: props.auth,
data: {
data: {
sentient: true
instance: {
property: 'yes'
}
}
});
Expand Down

0 comments on commit 23cdac8

Please sign in to comment.