Skip to content

Commit c25dc3f

Browse files
authored
17714 kustomer (#17814)
* Kustomer #17714 Actions - Get Custom Objects - Get Custom Object by ID - Get Custom Object by External ID - Update Custom Object by ID * pnpm update * Update Kustomer action descriptions and change rev type in update-custom-object-by-id action * pnpm update * pnpm update
1 parent f0cdf9e commit c25dc3f

File tree

16 files changed

+319
-13
lines changed

16 files changed

+319
-13
lines changed

components/kustomer/actions/create-conversation/create-conversation.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "kustomer-create-conversation",
88
name: "Create Conversation",
99
description: "Creates a new conversation in Kustomer. [See the documentation](https://developer.kustomer.com/kustomer-api-docs/reference/createaconversation)",
10-
version: "0.0.1",
10+
version: "0.0.2",
1111
type: "action",
1212
props: {
1313
kustomer,

components/kustomer/actions/create-customer/create-customer.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "kustomer-create-customer",
88
name: "Create Customer",
99
description: "Creates a new customer in Kustomer. [See the documentation](https://developer.kustomer.com/kustomer-api-docs/reference/createacustomer)",
10-
version: "0.0.1",
10+
version: "0.0.2",
1111
type: "action",
1212
props: {
1313
kustomer,
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import kustomer from "../../kustomer.app.mjs";
3+
4+
export default {
5+
key: "kustomer-get-custom-object-by-external-id",
6+
name: "Get Custom Object by External ID",
7+
description: "Gets a custom object by external ID in Kustomer. [See the documentation](https://developer.kustomer.com/kustomer-api-docs/reference/get-klasses-name-externalid-externalid)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
kustomer,
12+
klassName: {
13+
propDefinition: [
14+
kustomer,
15+
"klassName",
16+
],
17+
},
18+
externalId: {
19+
type: "string",
20+
label: "External ID",
21+
description: "The external ID of the custom object to retrieve",
22+
},
23+
},
24+
async run({ $ }) {
25+
try {
26+
const response = await this.kustomer.getCustomObjectByExternalId({
27+
$,
28+
klassName: this.klassName,
29+
externalId: this.externalId,
30+
});
31+
32+
$.export("$summary", `Successfully retrieved custom object with external ID ${this.externalId}`);
33+
return response;
34+
} catch ({ response }) {
35+
throw new ConfigurationError(response.data.errors[0].title);
36+
}
37+
},
38+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import kustomer from "../../kustomer.app.mjs";
3+
4+
export default {
5+
key: "kustomer-get-custom-object-by-id",
6+
name: "Get Custom Object by ID",
7+
description: "Gets a custom object by ID in Kustomer. [See the documentation](https://developer.kustomer.com/kustomer-api-docs/reference/getkobject)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
kustomer,
12+
klassName: {
13+
propDefinition: [
14+
kustomer,
15+
"klassName",
16+
],
17+
},
18+
customObjectId: {
19+
propDefinition: [
20+
kustomer,
21+
"customObjectId",
22+
({ klassName }) => ({
23+
klassName,
24+
}),
25+
],
26+
},
27+
},
28+
async run({ $ }) {
29+
try {
30+
const response = await this.kustomer.getCustomObjectById({
31+
$,
32+
klassName: this.klassName,
33+
customObjectId: this.customObjectId,
34+
});
35+
36+
$.export("$summary", `Successfully retrieved custom object with ID ${this.customObjectId}`);
37+
return response;
38+
} catch ({ response }) {
39+
throw new ConfigurationError(response.data.errors[0].title);
40+
}
41+
},
42+
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import kustomer from "../../kustomer.app.mjs";
3+
4+
export default {
5+
key: "kustomer-get-custom-objects",
6+
name: "Get Custom Objects",
7+
description: "Gets custom objects in Kustomer. [See the documentation](https://developer.kustomer.com/kustomer-api-docs/reference/getkobjects)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
kustomer,
12+
klassName: {
13+
propDefinition: [
14+
kustomer,
15+
"klassName",
16+
],
17+
},
18+
fromDate: {
19+
type: "string",
20+
label: "From Date",
21+
description: "Date-time string in Internet Date/Time format (ISO 8601) E.g. `2025-07-25T00:00:00Z`",
22+
optional: true,
23+
},
24+
},
25+
async run({ $ }) {
26+
try {
27+
const response = await this.kustomer.listCustomObjects({
28+
$,
29+
klassName: this.klassName,
30+
params: {
31+
fromDate: this.fromDate,
32+
},
33+
});
34+
35+
$.export("$summary", `Successfully retrieved ${response.data.length} custom objects`);
36+
return response;
37+
} catch ({ response }) {
38+
throw new ConfigurationError(response.data.errors[0].title);
39+
}
40+
},
41+
};

components/kustomer/actions/update-conversation/update-conversation.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "kustomer-update-conversation",
88
name: "Update Conversation",
99
description: "Updates an existing conversation in Kustomer. [See the documentation](https://developer.kustomer.com/kustomer-api-docs/reference/updateconversation).",
10-
version: "0.0.1",
10+
version: "0.0.2",
1111
type: "action",
1212
props: {
1313
kustomer,
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import { parseObject } from "../../common/utils.mjs";
3+
import kustomer from "../../kustomer.app.mjs";
4+
5+
export default {
6+
key: "kustomer-update-custom-object-by-id",
7+
name: "Update Custom Object by ID",
8+
description: "Updates a custom object identified by ID in Kustomer. [See the documentation](https://developer.kustomer.com/kustomer-api-docs/reference/updatekobject)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
kustomer,
13+
klassName: {
14+
propDefinition: [
15+
kustomer,
16+
"klassName",
17+
],
18+
},
19+
customObjectId: {
20+
propDefinition: [
21+
kustomer,
22+
"customObjectId",
23+
({ klassName }) => ({
24+
klassName,
25+
}),
26+
],
27+
},
28+
externalId: {
29+
type: "string",
30+
label: "External ID",
31+
description: "The external ID of the custom object to update",
32+
optional: true,
33+
},
34+
title: {
35+
type: "string",
36+
label: "Title",
37+
description: "The title of the custom object to update",
38+
optional: true,
39+
},
40+
description: {
41+
type: "string",
42+
label: "Description",
43+
description: "The description of the custom object to update",
44+
optional: true,
45+
},
46+
data: {
47+
type: "object",
48+
label: "Data",
49+
description: "The data to update the custom object with",
50+
optional: true,
51+
},
52+
custom: {
53+
type: "object",
54+
label: "Custom",
55+
description: "The custom data of the custom object to update",
56+
optional: true,
57+
},
58+
tags: {
59+
propDefinition: [
60+
kustomer,
61+
"tags",
62+
],
63+
label: "Tags",
64+
description: "Tags associated with the custom object",
65+
optional: true,
66+
},
67+
rev: {
68+
type: "integer",
69+
label: "Rev",
70+
description: "The rev of the custom object to update",
71+
optional: true,
72+
},
73+
},
74+
async run({ $ }) {
75+
try {
76+
const response = await this.kustomer.updateCustomObjectById({
77+
$,
78+
klassName: this.klassName,
79+
customObjectId: this.customObjectId,
80+
data: {
81+
externalId: this.externalId,
82+
title: this.title,
83+
description: this.description,
84+
data: parseObject(this.data),
85+
custom: parseObject(this.custom),
86+
tags: parseObject(this.tags),
87+
rev: this.rev,
88+
},
89+
});
90+
91+
$.export("$summary", `Successfully updated custom object with ID ${this.customObjectId}`);
92+
return response;
93+
} catch ({ response }) {
94+
throw new ConfigurationError(response.data.errors[0].title);
95+
}
96+
},
97+
};

components/kustomer/actions/update-customer/update-customer.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "kustomer-update-customer",
88
name: "Update Customer",
99
description: "Updates an existing customer in Kustomer. [See the documentation](https://developer.kustomer.com/kustomer-api-docs/reference/updatecustomer)",
10-
version: "0.0.1",
10+
version: "0.0.2",
1111
type: "action",
1212
props: {
1313
kustomer,

components/kustomer/kustomer.app.mjs

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,49 @@ export default {
127127
}));
128128
},
129129
},
130+
klassName: {
131+
type: "string",
132+
label: "Klass Name",
133+
description: "Klass name of the KObjects (custom objects)",
134+
async options({ page }) {
135+
const { data } = await this.listKlasses({
136+
params: {
137+
page: page + 1,
138+
pageSize: LIMIT * page,
139+
},
140+
});
141+
return data.map(({
142+
attributes: {
143+
name: value, displayName: label,
144+
},
145+
}) => ({
146+
label,
147+
value,
148+
}));
149+
},
150+
},
151+
customObjectId: {
152+
type: "string",
153+
label: "Custom Object ID",
154+
description: "The ID of the custom object to retrieve",
155+
async options({
156+
page, klassName,
157+
}) {
158+
const { data } = await this.listCustomObjects({
159+
klassName,
160+
params: {
161+
page: page + 1,
162+
pageSize: LIMIT * page,
163+
},
164+
});
165+
return data.map(({
166+
id: value, attributes: { title: label },
167+
}) => ({
168+
label,
169+
value,
170+
}));
171+
},
172+
},
130173
externalId: {
131174
type: "string",
132175
label: "External ID",
@@ -327,6 +370,51 @@ export default {
327370
...opts,
328371
});
329372
},
373+
listKlasses(opts = {}) {
374+
return this._makeRequest({
375+
path: "/klasses",
376+
...opts,
377+
});
378+
},
379+
listCustomObjects({
380+
klassName, ...opts
381+
}) {
382+
return this._makeRequest({
383+
path: `/klasses/${klassName}`,
384+
...opts,
385+
});
386+
},
387+
getCustomObjectById({
388+
klassName,
389+
customObjectId,
390+
...opts
391+
}) {
392+
return this._makeRequest({
393+
path: `/klasses/${klassName}/${customObjectId}`,
394+
...opts,
395+
});
396+
},
397+
getCustomObjectByExternalId({
398+
klassName,
399+
externalId,
400+
...opts
401+
}) {
402+
return this._makeRequest({
403+
path: `/klasses/${klassName}/externalId=${externalId}`,
404+
...opts,
405+
});
406+
},
407+
updateCustomObjectById({
408+
klassName,
409+
customObjectId,
410+
...opts
411+
}) {
412+
return this._makeRequest({
413+
method: "PUT",
414+
path: `/klasses/${klassName}/${customObjectId}`,
415+
...opts,
416+
});
417+
},
330418
createWebhook(opts = {}) {
331419
return this._makeRequest({
332420
method: "POST",

components/kustomer/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/kustomer",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Pipedream Kustomer Components",
55
"main": "kustomer.app.mjs",
66
"keywords": [
@@ -13,6 +13,6 @@
1313
"access": "public"
1414
},
1515
"dependencies": {
16-
"@pipedream/platform": "^3.0.3"
16+
"@pipedream/platform": "^3.1.0"
1717
}
1818
}

0 commit comments

Comments
 (0)