Skip to content

Commit

Permalink
Reverts change to TrueUSD param name
Browse files Browse the repository at this point in the history
  • Loading branch information
justinkaseman committed Mar 4, 2021
1 parent dbd29c2 commit 821eebc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions trueusd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ https://core-api.real-time-attest.trustexplorer.io/trusttoken/TrueUSD

### Input Params

| Required? | Name | Description | Options | Defaults to |
| :-------: | :----: | :-------------------------------------------------: | :------------------------: | :----------: |
| | `path` | The data point to return from the API response data | `totalTrust`, `totalToken` | `totalTrust` |
| Required? | Name | Description | Options | Defaults to |
| :-------: | :-----: | :-------------------------------------------------: | :------------------------: | :----------: |
| | `field` | The data point to return from the API response data | `totalTrust`, `totalToken` | `totalTrust` |

### Sample Input

```json
{
"id": "1",
"data": {
"path": "totalToken"
"field": "totalToken"
}
}
```
Expand Down
6 changes: 3 additions & 3 deletions trueusd/src/endpoint/trueusd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ export const NAME = 'trueusd'
const customError = (data: any) => data.Response === 'Error'

const customParams = {
path: false,
field: false,
}

export const execute: ExecuteWithConfig<Config> = async (request, config) => {
const validator = new Validator(request, customParams)
if (validator.error) throw validator.error

const jobRunID = validator.validated.id
const path = validator.validated.data.path || 'totalTrust'
const field = validator.validated.data.field || 'totalTrust'
const url = '/trusttoken/TrueUSD'

const options = { ...config.api, url }

const response = await Requester.request(options, customError)
const result = Requester.validateResultNumber(response.data, ['responseData', path])
const result = Requester.validateResultNumber(response.data, ['responseData', field])

return Requester.success(jobRunID, {
data: config.verbose ? { ...response.data, result } : { result },
Expand Down
4 changes: 2 additions & 2 deletions trueusd/test/trueusd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ describe('execute', () => {
},
{
name: 'id is supplied',
testData: { id: jobID, data: { path: 'totalTrust' } },
testData: { id: jobID, data: { field: 'totalTrust' } },
},
{
name: 'trust supply',
testData: { id: jobID, data: { path: 'totalToken' } },
testData: { id: jobID, data: { field: 'totalToken' } },
},
]

Expand Down

0 comments on commit 821eebc

Please sign in to comment.