Skip to content

Commit

Permalink
PLT-5993: No error returned when calling externalRecordPayment (#6)
Browse files Browse the repository at this point in the history
* refactored recordPayment to return error if there is one

* update readme

* update readme
  • Loading branch information
aland1013 authored Jul 12, 2021
1 parent 8031cd9 commit 03a0397
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# tokensoft-sdk
# @tokensoft/sdk

![Logo](./docs/img/logo.png)

Expand Down Expand Up @@ -69,3 +69,7 @@ const transactionHash = await client.authorizeUser('jay_clayton@gmail.com', '0x0

* Added `recordPayment` function which can be used to call the `externalRecordPayment` endpoint

### 1.1.0 -> 1.1.1

* Refactored `recordPayment` to return an error if there is one

17 changes: 16 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,21 @@ export class TokensoftSDK {
}`
})

return this.sendRequest(body).then(d => d?.data)
const res = await this.sendRequest(body)

if (
(!res.data || Object.values(res.data).find(v => v === null) !== undefined) &&
res.errors &&
res.errors.length
) {
throw new Error(
res.errors
// @ts-ignore
.map(e => e.message)
.join('; ')
)
}

return res.data
}
}

0 comments on commit 03a0397

Please sign in to comment.