Skip to content

Commit

Permalink
Pause resume callback method add (#57)
Browse files Browse the repository at this point in the history
* add pause and resume callback method

* 0.2.37
  • Loading branch information
impin2rex authored May 6, 2024
1 parent 1eb3654 commit b89293d
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ callback namespace:
- `list()`: Returns a list of all the callbacks registered for a user.
- `addAddresses()`: Add Addresses in Callback.
- `removeAddresses()`: Remove Addresses from callback.
- `pause()`: Pause a callback.
- `resume()`: Resume a callback.

### RPC

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.2.36",
"version": "0.2.37",
"license": "MIT",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down
34 changes: 34 additions & 0 deletions src/api/callback-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,40 @@ export class CallbackClient {
}
}

async pause(input: { id: string }): Promise<boolean> {
try {
const reqBody = {
id: input.id,
};
const response = await restApiCall(this.config.apiKey, {
method: 'post',
url: 'callback/pause',
data: reqBody,
});
const isPaused = response.success as boolean;
return isPaused;
} catch (error) {
throw error;
}
}

async resume(input: { id: string }): Promise<boolean> {
try {
const reqBody = {
id: input.id,
};
const response = await restApiCall(this.config.apiKey, {
method: 'post',
url: 'callback/resume',
data: reqBody,
});
const isResumed = response.success as boolean;
return isResumed;
} catch (error) {
throw error;
}
}

private isValidUrl(url: string) {
try {
new URL(url);
Expand Down
14 changes: 14 additions & 0 deletions tests/callback-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,18 @@ describe('callback test', () => {
console.log(callbacks);
expect(callbacks[0]).toBe('object');
}, 50000);

it('pause callback', async () => {
const isPaused = await shyft.callback.pause({
id: '663889899aabe8e58dd4decb',
});
expect(isPaused).toBe(true);
}, 50000);

it('resume callback', async () => {
const isResumed = await shyft.callback.resume({
id: '663889899aabe8e58dd4decb',
});
expect(isResumed).toBe(true);
}, 50000);
});

0 comments on commit b89293d

Please sign in to comment.