Skip to content

Commit

Permalink
feat: add code samples for Webhooks (#1354)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-murasovs authored Dec 20, 2024
1 parent 8f36cb5 commit 53c7b02
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const result = await apifyClient
.requestQueue('<QUEUE ID>')
.updateRequest({
id: '<REQUEST ID>',
uniqueKey: 'http://example.com',
url: 'http://example.com',
});

Expand Down
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/webhookDispatch_get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const dispatch = await apifyClient
.webhookDispatch('<DISPATCH ID>')
.get();

console.log(dispatch);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/webhookDispatches_get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const { items } = await apifyClient
.webhookDispatches()
.list();

console.log(items);
8 changes: 8 additions & 0 deletions apify-api/openapi/code_samples/javascript/webhook_delete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
await apifyClient
.webhook('<WEBHOOK ID>')
.delete();
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const { items } = await apifyClient
.webhook('<WEBHOOK ID>')
.dispatches()
.list();

console.log(items);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/webhook_get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const webhook = await apifyClient
.webhook('<WEBHOOK ID>')
.get();

console.log(webhook);
12 changes: 12 additions & 0 deletions apify-api/openapi/code_samples/javascript/webhook_put.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const updatedWebhook = await apifyClient
.webhook('<WEBHOOK ID>')
.update({
eventTypes: ['ACTOR.RUN.FAILED'],
});

console.log(updatedWebhook);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/webhook_test_post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const result = await apifyClient
.webhook('<WEBHOOK ID>')
.test();

console.log(result);
10 changes: 10 additions & 0 deletions apify-api/openapi/code_samples/javascript/webhooks_get.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const { items } = await apifyClient
.webhooks()
.list();

console.log(items);
16 changes: 16 additions & 0 deletions apify-api/openapi/code_samples/javascript/webhooks_post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ApifyClient } from 'apify-client';

const apifyClient = new ApifyClient({
token: '<TOKEN>',
});
const webhook = await apifyClient
.webhooks()
.create({
eventTypes: ['ACTOR.RUN.SUCCEEDED'],
condition: {
actorId: '<ACTOR ID>',
},
requestUrl: 'http://example.com/',
});

console.log(webhook);

0 comments on commit 53c7b02

Please sign in to comment.