-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
850 additions
and
380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
ACTIONSTEP_API_URL=https://ap-southeast-2.actionstep.com/api/rest | ||
ACTIONSTEP_TOKEN_URL=https://tools.thinkconveyancing.com.au/api/actionstep/key/get | ||
ACTIONSTEP_TOKEN_URL= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# actionstep-sandbox | ||
|
||
Test ActionStep endpoints | ||
|
||
## Getting Started | ||
|
||
Buid monorepo | ||
|
||
``` | ||
cd monorepo | ||
npm i | ||
npm run build | ||
``` | ||
|
||
Copy `.env.example` and edit to suit | ||
|
||
``` | ||
cd actionstep-sandbox | ||
cp .env.example .env | ||
``` | ||
|
||
Edit `.env` file and set value for `ACTIONSTEP_TOKEN_URL` which is the endpoint which returns the stored ActionStep token. | ||
|
||
Determine if token service is considered current or legacy and edit `runner.ts` and use the appropriate `actionStepTokenClient` or `actionStepLegacyTokenClient`. | ||
|
||
A token service should return tokens in the following format: | ||
|
||
```json | ||
{ | ||
"access_token": "...", | ||
"api_endpoint": "https://ap-southeast-2.actionstep.com/api/", | ||
"expires_at": "2024-03-08T09:04:49.747Z", | ||
"expires_in": 28800, | ||
"orgkey": "...", | ||
"refresh_token": "...", | ||
"token_type": "bearer" | ||
} | ||
``` | ||
|
||
A legacy token service should return tokens in the following format: | ||
|
||
```json | ||
{ | ||
"status": 200, | ||
"message": "OK", | ||
"data": { | ||
"actionstep": { | ||
"id": "1", | ||
"access_token": "...", | ||
"token_type": "bearer", | ||
"expires_in": "28800", | ||
"api_endpoint": "https://ap-southeast-2.actionstep.com/api/", | ||
"orgkey": "...", | ||
"refresh_token": "...", | ||
"generated": "2024-03-08 11:40:25", | ||
"date_expiry": "2024-03-08 19:40:25" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Test endpoints by passing endpoint name to the runner eg. `getActions` | ||
|
||
``` | ||
npm run runner getActions | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
monorepo/actionstep-sandbox/src/endpoints/createActionParticipant.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { ActionStepTokenClient, actionStepClient } from '@dbc-tech/actionstep' | ||
|
||
export const createActionParticipant = async ( | ||
tokenClient: ActionStepTokenClient, | ||
) => { | ||
const { actionParticipants: client } = actionStepClient(tokenClient) | ||
|
||
const testActionId = 68330 // or 84407 | ||
const testParticipantId = 113702 | ||
const testParticipantType = 71 | ||
|
||
const { data: createdActionParticipant, error } = | ||
await client.createActionParticipant({ | ||
actionparticipants: { | ||
links: { | ||
action: testActionId, | ||
participant: testParticipantId, | ||
participantType: testParticipantType, | ||
}, | ||
}, | ||
}) | ||
if (error) console.error('error:', error) | ||
else | ||
console.log('created action participant:', { | ||
id: createdActionParticipant.actionparticipants.id, | ||
number: createdActionParticipant.actionparticipants.participantNumber, | ||
}) | ||
} |
15 changes: 15 additions & 0 deletions
15
monorepo/actionstep-sandbox/src/endpoints/deleteActionParticipant.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ActionStepTokenClient, actionStepClient } from '@dbc-tech/actionstep' | ||
|
||
export const deleteActionParticipant = async ( | ||
tokenClient: ActionStepTokenClient, | ||
) => { | ||
const { actionParticipants: client } = actionStepClient(tokenClient) | ||
|
||
const testParticipantId = '68330--71--113702' | ||
|
||
const response = await client.deleteActionParticipant(testParticipantId) | ||
if (response.error) console.error('error:', response.error) | ||
else { | ||
console.log(`Status code:${response.response.status}`) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ActionStepTokenClient, actionStepClient } from '@dbc-tech/actionstep' | ||
|
||
export const getAction = async (tokenClient: ActionStepTokenClient) => { | ||
const { actions: client } = actionStepClient(tokenClient) | ||
|
||
const testActionId = 68330 // or 84407 | ||
|
||
const { data: action, error } = await client.getAction(testActionId) | ||
if (error) console.error('error:', error) | ||
else | ||
console.log('get action:', { | ||
id: action.actions.id, | ||
name: action.actions.name, | ||
reference: action.actions.reference, | ||
}) | ||
} |
19 changes: 19 additions & 0 deletions
19
monorepo/actionstep-sandbox/src/endpoints/getActionParticipant.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { ActionStepTokenClient, actionStepClient } from '@dbc-tech/actionstep' | ||
|
||
export const getActionParticipant = async ( | ||
tokenClient: ActionStepTokenClient, | ||
) => { | ||
const { actionParticipants: client } = actionStepClient(tokenClient) | ||
|
||
const testParticipantId = '113702' | ||
|
||
const { data: actionParticipant, error } = | ||
await client.getActionParticipant(testParticipantId) | ||
if (error) console.error('error:', error) | ||
else { | ||
console.log('get action participant:', { | ||
id: actionParticipant.actionparticipants.id, | ||
number: actionParticipant.actionparticipants.participantNumber, | ||
}) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
monorepo/actionstep-sandbox/src/endpoints/getActionParticipants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { ActionStepTokenClient, actionStepClient } from '@dbc-tech/actionstep' | ||
|
||
export const getActionParticipants = async ( | ||
tokenClient: ActionStepTokenClient, | ||
) => { | ||
const { actionParticipants: client } = actionStepClient(tokenClient) | ||
|
||
const { data, error } = await client.getActionParticipants(1, 5) | ||
if (error) console.error('error:', error) | ||
else { | ||
for (const participant of data.actionparticipants) { | ||
console.log('get action participant:', { | ||
id: participant.id, | ||
number: participant.participantNumber, | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { ActionStepTokenClient, actionStepClient } from '@dbc-tech/actionstep' | ||
|
||
export const getActions = async (tokenClient: ActionStepTokenClient) => { | ||
const { actions: client } = actionStepClient(tokenClient) | ||
|
||
const { data, error } = await client.getActions(1, 5) | ||
if (error) console.error('error:', error) | ||
else { | ||
for (const action of data.actions) { | ||
console.log('get action:', { | ||
id: action.id, | ||
name: action.name, | ||
reference: action.reference, | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ActionStepTokenClient, actionStepClient } from '@dbc-tech/actionstep' | ||
|
||
export const updateAction = async (tokenClient: ActionStepTokenClient) => { | ||
const { actions: client } = actionStepClient(tokenClient) | ||
|
||
const testActionId = 68330 // or 84407 | ||
|
||
const { data: updatedAction, error } = await client.updateAction( | ||
testActionId, | ||
{ | ||
actions: { | ||
reference: 'TEST07', | ||
}, | ||
}, | ||
) | ||
if (error) console.error('error:', error) | ||
else | ||
console.log('updated action:', { | ||
id: updatedAction.actions.id, | ||
name: updatedAction.actions.name, | ||
reference: updatedAction.actions.reference, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { actionStepLegacyTokenClient } from '@dbc-tech/actionstep' | ||
import * as dotenv from 'dotenv' | ||
import { getActions } from './endpoints/getActions' | ||
import { getAction } from './endpoints/getAction' | ||
import { updateAction } from './endpoints/updateAction' | ||
import { getActionParticipants } from './endpoints/getActionParticipants' | ||
import { getActionParticipant } from './endpoints/getActionParticipant' | ||
import { createActionParticipant } from './endpoints/createActionParticipant' | ||
import { deleteActionParticipant } from './endpoints/deleteActionParticipant' | ||
dotenv.config() | ||
|
||
const runner = async (endpointName: string) => { | ||
console.log('running:', endpointName) | ||
|
||
// const tokenClient = actionStepTokenClient( | ||
// process.env.ACTIONSTEP_TOKEN_URL, | ||
// process.env.ACTIONSTEP_API_URL, | ||
// ) | ||
const tokenClient = actionStepLegacyTokenClient( | ||
process.env.ACTIONSTEP_TOKEN_URL, | ||
process.env.ACTIONSTEP_API_URL, | ||
) | ||
|
||
switch (endpointName) { | ||
case 'getActions': | ||
return getActions(tokenClient) | ||
case 'getAction': | ||
return getAction(tokenClient) | ||
case 'updateAction': | ||
return updateAction(tokenClient) | ||
case 'getActionParticipants': | ||
return getActionParticipants(tokenClient) | ||
case 'getActionParticipant': | ||
return getActionParticipant(tokenClient) | ||
case 'createActionParticipant': | ||
return createActionParticipant(tokenClient) | ||
case 'deleteActionParticipant': | ||
return deleteActionParticipant(tokenClient) | ||
} | ||
} | ||
|
||
runner(process.argv[2]) | ||
.then(() => console.log('done')) | ||
.catch(console.error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import { ActionStepTokenClient } from './types/action-step-auth.type' | ||
import { actionsClient } from './api/actions' | ||
import { actionParticipantsClient } from './api/actionparticipants' | ||
|
||
export const actionStepClient = (tokenClient: ActionStepTokenClient) => { | ||
return { | ||
actions: actionsClient(tokenClient), | ||
actionParticipants: actionParticipantsClient(tokenClient), | ||
} | ||
} |
Oops, something went wrong.