From a1438a30436602ad8d98156d237cc4efe68736d5 Mon Sep 17 00:00:00 2001 From: Nicholas Margaritondo Date: Mon, 22 Jan 2024 11:58:49 -0600 Subject: [PATCH] updated webhook samples --- .../cm_api_v2_delete_legacy_webhook.js | 2 +- .../cm_api_v2_delete_webhook.js | 12 +++ .../cm_api_v2_get_legacy_webhook.js | 2 +- .../cm_api_v2_get_legacy_webhooks.js | 2 +- js/management-api-v2/cm_api_v2_get_webhook.js | 12 +++ .../cm_api_v2_get_webhooks.js | 11 +++ .../cm_api_v2_post_legacy_webhook.js | 2 +- .../cm_api_v2_post_webhook.js | 76 +++++++++++++++++++ .../mapi_v2_disable_legacy_webhook.js | 2 +- .../mapi_v2_disable_webhook.js | 12 +++ .../mapi_v2_enable_legacy_webhook.js | 2 +- .../mapi_v2_enable_webhook.js | 12 +++ 12 files changed, 141 insertions(+), 6 deletions(-) create mode 100644 js/management-api-v2/cm_api_v2_delete_webhook.js create mode 100644 js/management-api-v2/cm_api_v2_get_webhook.js create mode 100644 js/management-api-v2/cm_api_v2_get_webhooks.js create mode 100644 js/management-api-v2/cm_api_v2_post_webhook.js create mode 100644 js/management-api-v2/mapi_v2_disable_webhook.js create mode 100644 js/management-api-v2/mapi_v2_enable_webhook.js diff --git a/js/management-api-v2/cm_api_v2_delete_legacy_webhook.js b/js/management-api-v2/cm_api_v2_delete_legacy_webhook.js index 4356c920..490da4e0 100644 --- a/js/management-api-v2/cm_api_v2_delete_legacy_webhook.js +++ b/js/management-api-v2/cm_api_v2_delete_legacy_webhook.js @@ -7,6 +7,6 @@ const client = new ManagementClient({ apiKey: '' }); -const response = await client.deleteWebhook() +const response = await client.deleteLegacyWebhook() .byId("d53360f7-79e1-42f4-a524-1b53a417d03e") .toPromise(); \ No newline at end of file diff --git a/js/management-api-v2/cm_api_v2_delete_webhook.js b/js/management-api-v2/cm_api_v2_delete_webhook.js new file mode 100644 index 00000000..4356c920 --- /dev/null +++ b/js/management-api-v2/cm_api_v2_delete_webhook.js @@ -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: '', + apiKey: '' +}); + +const response = await client.deleteWebhook() + .byId("d53360f7-79e1-42f4-a524-1b53a417d03e") + .toPromise(); \ No newline at end of file diff --git a/js/management-api-v2/cm_api_v2_get_legacy_webhook.js b/js/management-api-v2/cm_api_v2_get_legacy_webhook.js index 79fcd7d5..8da11415 100644 --- a/js/management-api-v2/cm_api_v2_get_legacy_webhook.js +++ b/js/management-api-v2/cm_api_v2_get_legacy_webhook.js @@ -7,6 +7,6 @@ const client = new ManagementClient({ apiKey: '' }); -const response = await client.getWebhook() +const response = await client.getLegacyWebhook() .byId("5df74e27-1213-484e-b9ae-bcbe90bd5990") .toPromise(); \ No newline at end of file diff --git a/js/management-api-v2/cm_api_v2_get_legacy_webhooks.js b/js/management-api-v2/cm_api_v2_get_legacy_webhooks.js index 23233ecf..4e1f96b3 100644 --- a/js/management-api-v2/cm_api_v2_get_legacy_webhooks.js +++ b/js/management-api-v2/cm_api_v2_get_legacy_webhooks.js @@ -7,5 +7,5 @@ const client = new ManagementClient({ apiKey: '' }); -const response = await client.listWebhooks() +const response = await client.listLegacyWebhooks() .toPromise(); \ No newline at end of file diff --git a/js/management-api-v2/cm_api_v2_get_webhook.js b/js/management-api-v2/cm_api_v2_get_webhook.js new file mode 100644 index 00000000..79fcd7d5 --- /dev/null +++ b/js/management-api-v2/cm_api_v2_get_webhook.js @@ -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: '', + apiKey: '' +}); + +const response = await client.getWebhook() + .byId("5df74e27-1213-484e-b9ae-bcbe90bd5990") + .toPromise(); \ No newline at end of file diff --git a/js/management-api-v2/cm_api_v2_get_webhooks.js b/js/management-api-v2/cm_api_v2_get_webhooks.js new file mode 100644 index 00000000..23233ecf --- /dev/null +++ b/js/management-api-v2/cm_api_v2_get_webhooks.js @@ -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: '', + apiKey: '' +}); + +const response = await client.listWebhooks() + .toPromise(); \ No newline at end of file diff --git a/js/management-api-v2/cm_api_v2_post_legacy_webhook.js b/js/management-api-v2/cm_api_v2_post_legacy_webhook.js index 20a8133d..768c5103 100644 --- a/js/management-api-v2/cm_api_v2_post_legacy_webhook.js +++ b/js/management-api-v2/cm_api_v2_post_legacy_webhook.js @@ -7,7 +7,7 @@ const client = new ManagementClient({ apiKey: '' }); -const response = await client.addWebhook() +const response = await client.addLegacyWebhook() .withData( { name: "Example webhook", diff --git a/js/management-api-v2/cm_api_v2_post_webhook.js b/js/management-api-v2/cm_api_v2_post_webhook.js new file mode 100644 index 00000000..0c8d6e34 --- /dev/null +++ b/js/management-api-v2/cm_api_v2_post_webhook.js @@ -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: '', + apiKey: '' +}); + +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(); \ No newline at end of file diff --git a/js/management-api-v2/mapi_v2_disable_legacy_webhook.js b/js/management-api-v2/mapi_v2_disable_legacy_webhook.js index a2452df7..5814664e 100644 --- a/js/management-api-v2/mapi_v2_disable_legacy_webhook.js +++ b/js/management-api-v2/mapi_v2_disable_legacy_webhook.js @@ -7,6 +7,6 @@ const client = new ManagementClient({ apiKey: '' }); -const response = await client.disableWebhook() +const response = await client.disableLegacyWebhook() .byId("5df74e27-1213-484e-b9ae-bcbe90bd5990") .toPromise(); \ No newline at end of file diff --git a/js/management-api-v2/mapi_v2_disable_webhook.js b/js/management-api-v2/mapi_v2_disable_webhook.js new file mode 100644 index 00000000..a2452df7 --- /dev/null +++ b/js/management-api-v2/mapi_v2_disable_webhook.js @@ -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: '', + apiKey: '' +}); + +const response = await client.disableWebhook() + .byId("5df74e27-1213-484e-b9ae-bcbe90bd5990") + .toPromise(); \ No newline at end of file diff --git a/js/management-api-v2/mapi_v2_enable_legacy_webhook.js b/js/management-api-v2/mapi_v2_enable_legacy_webhook.js index 93c03146..e2a55b65 100644 --- a/js/management-api-v2/mapi_v2_enable_legacy_webhook.js +++ b/js/management-api-v2/mapi_v2_enable_legacy_webhook.js @@ -7,6 +7,6 @@ const client = new ManagementClient({ apiKey: '' }); -const response = await client.enableWebhook() +const response = await client.enableLegacyWebhook() .byId("5df74e27-1213-484e-b9ae-bcbe90bd5990") .toPromise(); \ No newline at end of file diff --git a/js/management-api-v2/mapi_v2_enable_webhook.js b/js/management-api-v2/mapi_v2_enable_webhook.js new file mode 100644 index 00000000..93c03146 --- /dev/null +++ b/js/management-api-v2/mapi_v2_enable_webhook.js @@ -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: '', + apiKey: '' +}); + +const response = await client.enableWebhook() + .byId("5df74e27-1213-484e-b9ae-bcbe90bd5990") + .toPromise(); \ No newline at end of file