Skip to content

Commit

Permalink
Merge pull request #77 from Nickm615/update-webhook-js-samples
Browse files Browse the repository at this point in the history
updated webhook samples
  • Loading branch information
saminamhk authored Jan 29, 2024
2 parents 6ad8bf5 + a1438a3 commit e722e80
Show file tree
Hide file tree
Showing 12 changed files with 141 additions and 6 deletions.
2 changes: 1 addition & 1 deletion js/management-api-v2/cm_api_v2_delete_legacy_webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ const client = new ManagementClient({
apiKey: '<YOUR_API_KEY>'
});

const response = await client.deleteWebhook()
const response = await client.deleteLegacyWebhook()
.byId("d53360f7-79e1-42f4-a524-1b53a417d03e")
.toPromise();
12 changes: 12 additions & 0 deletions js/management-api-v2/cm_api_v2_delete_webhook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Tip: Find more about JS/TS SDKs at https://kontent.ai/learn/javascript
// Using ES6 syntax
import { ManagementClient } from '@kontent-ai/management-sdk';

const client = new ManagementClient({
environmentId: '<YOUR_ENVIRONMENT_ID>',
apiKey: '<YOUR_API_KEY>'
});

const response = await client.deleteWebhook()
.byId("d53360f7-79e1-42f4-a524-1b53a417d03e")
.toPromise();
2 changes: 1 addition & 1 deletion js/management-api-v2/cm_api_v2_get_legacy_webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ const client = new ManagementClient({
apiKey: '<YOUR_API_KEY>'
});

const response = await client.getWebhook()
const response = await client.getLegacyWebhook()
.byId("5df74e27-1213-484e-b9ae-bcbe90bd5990")
.toPromise();
2 changes: 1 addition & 1 deletion js/management-api-v2/cm_api_v2_get_legacy_webhooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ const client = new ManagementClient({
apiKey: '<YOUR_API_KEY>'
});

const response = await client.listWebhooks()
const response = await client.listLegacyWebhooks()
.toPromise();
12 changes: 12 additions & 0 deletions js/management-api-v2/cm_api_v2_get_webhook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Tip: Find more about JS/TS SDKs at https://kontent.ai/learn/javascript
// Using ES6 syntax
import { ManagementClient } from '@kontent-ai/management-sdk';

const client = new ManagementClient({
environmentId: '<YOUR_ENVIRONMENT_ID>',
apiKey: '<YOUR_API_KEY>'
});

const response = await client.getWebhook()
.byId("5df74e27-1213-484e-b9ae-bcbe90bd5990")
.toPromise();
11 changes: 11 additions & 0 deletions js/management-api-v2/cm_api_v2_get_webhooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Tip: Find more about JS/TS SDKs at https://kontent.ai/learn/javascript
// Using ES6 syntax
import { ManagementClient } from '@kontent-ai/management-sdk';

const client = new ManagementClient({
environmentId: '<YOUR_ENVIRONMENT_ID>',
apiKey: '<YOUR_API_KEY>'
});

const response = await client.listWebhooks()
.toPromise();
2 changes: 1 addition & 1 deletion js/management-api-v2/cm_api_v2_post_legacy_webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const client = new ManagementClient({
apiKey: '<YOUR_API_KEY>'
});

const response = await client.addWebhook()
const response = await client.addLegacyWebhook()
.withData(
{
name: "Example webhook",
Expand Down
76 changes: 76 additions & 0 deletions js/management-api-v2/cm_api_v2_post_webhook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Tip: Find more about JS/TS SDKs at https://kontent.ai/learn/javascript
// Using ES6 syntax
import { ManagementClient } from '@kontent-ai/management-sdk';

const client = new ManagementClient({
environmentId: '<YOUR_ENVIRONMENT_ID>',
apiKey: '<YOUR_API_KEY>'
});

const response = await client.addWebhook()
.withData(
{
name: "Example webhook",
url: "https://example.com/webhook",
secret: "secret_key",
delivery_triggers: {
slot: "preview",
events: "specific",
content_type: {
enabled: "true",
actions: [
{
action: "changed"
}
]
},
asset: {
enabled: "true",
actions: [
{
action: "deleted"
}
]
},
taxonomy: {
enabled: "true",
actions: [
{
action: "term_changed"
}
]
},
language: {
enabled: "true",
actions: [
{
action: "changed"
},
{
action: "created"
}
]
},
content_item: {
enabled: "true",
actions: [
{
action: "workflow_step_changed",
transition_to: []
}
],
filters: {
collections: [
{}
],
content_types: [
{}
],
languages: [
{}
]
}
}
}
})
.toPromise();
2 changes: 1 addition & 1 deletion js/management-api-v2/mapi_v2_disable_legacy_webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ const client = new ManagementClient({
apiKey: '<YOUR_API_KEY>'
});

const response = await client.disableWebhook()
const response = await client.disableLegacyWebhook()
.byId("5df74e27-1213-484e-b9ae-bcbe90bd5990")
.toPromise();
12 changes: 12 additions & 0 deletions js/management-api-v2/mapi_v2_disable_webhook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Tip: Find more about JS/TS SDKs at https://kontent.ai/learn/javascript
// Using ES6 syntax
import { ManagementClient } from '@kontent-ai/management-sdk';

const client = new ManagementClient({
environmentId: '<YOUR_ENVIRONMENT_ID>',
apiKey: '<YOUR_API_KEY>'
});

const response = await client.disableWebhook()
.byId("5df74e27-1213-484e-b9ae-bcbe90bd5990")
.toPromise();
2 changes: 1 addition & 1 deletion js/management-api-v2/mapi_v2_enable_legacy_webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ const client = new ManagementClient({
apiKey: '<YOUR_API_KEY>'
});

const response = await client.enableWebhook()
const response = await client.enableLegacyWebhook()
.byId("5df74e27-1213-484e-b9ae-bcbe90bd5990")
.toPromise();
12 changes: 12 additions & 0 deletions js/management-api-v2/mapi_v2_enable_webhook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Tip: Find more about JS/TS SDKs at https://kontent.ai/learn/javascript
// Using ES6 syntax
import { ManagementClient } from '@kontent-ai/management-sdk';

const client = new ManagementClient({
environmentId: '<YOUR_ENVIRONMENT_ID>',
apiKey: '<YOUR_API_KEY>'
});

const response = await client.enableWebhook()
.byId("5df74e27-1213-484e-b9ae-bcbe90bd5990")
.toPromise();

0 comments on commit e722e80

Please sign in to comment.