-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add code samples for Webhooks (#1354)
- Loading branch information
1 parent
8f36cb5
commit 53c7b02
Showing
10 changed files
with
98 additions
and
0 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
10 changes: 10 additions & 0 deletions
10
apify-api/openapi/code_samples/javascript/webhookDispatch_get.js
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,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
10
apify-api/openapi/code_samples/javascript/webhookDispatches_get.js
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,10 @@ | ||
import { ApifyClient } from 'apify-client'; | ||
|
||
const apifyClient = new ApifyClient({ | ||
token: '<TOKEN>', | ||
}); | ||
const { items } = await apifyClient | ||
.webhookDispatches() | ||
.list(); | ||
|
||
console.log(items); |
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,8 @@ | ||
import { ApifyClient } from 'apify-client'; | ||
|
||
const apifyClient = new ApifyClient({ | ||
token: '<TOKEN>', | ||
}); | ||
await apifyClient | ||
.webhook('<WEBHOOK ID>') | ||
.delete(); |
11 changes: 11 additions & 0 deletions
11
apify-api/openapi/code_samples/javascript/webhook_dispatches_get.js
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,11 @@ | ||
import { ApifyClient } from 'apify-client'; | ||
|
||
const apifyClient = new ApifyClient({ | ||
token: '<TOKEN>', | ||
}); | ||
const { items } = await apifyClient | ||
.webhook('<WEBHOOK ID>') | ||
.dispatches() | ||
.list(); | ||
|
||
console.log(items); |
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,10 @@ | ||
import { ApifyClient } from 'apify-client'; | ||
|
||
const apifyClient = new ApifyClient({ | ||
token: '<TOKEN>', | ||
}); | ||
const webhook = await apifyClient | ||
.webhook('<WEBHOOK ID>') | ||
.get(); | ||
|
||
console.log(webhook); |
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,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
10
apify-api/openapi/code_samples/javascript/webhook_test_post.js
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,10 @@ | ||
import { ApifyClient } from 'apify-client'; | ||
|
||
const apifyClient = new ApifyClient({ | ||
token: '<TOKEN>', | ||
}); | ||
const result = await apifyClient | ||
.webhook('<WEBHOOK ID>') | ||
.test(); | ||
|
||
console.log(result); |
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,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
16
apify-api/openapi/code_samples/javascript/webhooks_post.js
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 { 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); |