Skip to content

Commit f15cf0d

Browse files
authored
Sevdesk new action (Create Contact) (#16277)
* package + pnpm * Adding 'Create Contact' action
1 parent 5c478e4 commit f15cf0d

File tree

4 files changed

+106
-4
lines changed

4 files changed

+106
-4
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import { CONTACT_CATEGORIES } from "../../common/constants.mjs";
2+
import sevdesk from "../../sevdesk.app.mjs";
3+
4+
export default {
5+
key: "sevdesk-create-contact",
6+
name: "Create Contact",
7+
description: "Create a new contact. [See the documentation](https://api.sevdesk.de/#tag/Contact/operation/createContact)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
sevdesk,
12+
category: {
13+
type: "integer",
14+
label: "Category",
15+
description: "Category of the contact",
16+
options: CONTACT_CATEGORIES,
17+
},
18+
parent: {
19+
propDefinition: [
20+
sevdesk,
21+
"contactId",
22+
],
23+
label: "Parent Contact ID",
24+
description: "The parent contact to which this contact belongs. Must be an organization",
25+
optional: true,
26+
},
27+
surename: {
28+
type: "string",
29+
label: "First Name",
30+
description: "The first name of the contact, if it is not an organization.",
31+
optional: true,
32+
},
33+
familyname: {
34+
type: "string",
35+
label: "Last Name",
36+
description: "The last name of the contact, if it is not an organization.",
37+
optional: true,
38+
},
39+
name: {
40+
type: "string",
41+
label: "Name (Organization)",
42+
description: "The name of the contact, if it is an organization.",
43+
optional: true,
44+
},
45+
additionalOptions: {
46+
type: "object",
47+
label: "Additional Options",
48+
description: "Additional parameters to set for the contact. [See the documentation](https://api.sevdesk.de/#tag/Contact/operation/createContact) for all available parameters. Example: `{ \"description\": \"Contact description\" }`",
49+
optional: true,
50+
},
51+
},
52+
methods: {
53+
createContact(opts = {}) {
54+
return this.sevdesk._makeRequest({
55+
method: "POST",
56+
path: "/Contact",
57+
...opts,
58+
});
59+
},
60+
},
61+
async run({ $ }) {
62+
const { objects: response } = await this.createContact({
63+
$,
64+
data: {
65+
category: {
66+
id: this.category,
67+
objectName: "Category",
68+
},
69+
parent: this.parent && {
70+
id: this.parent,
71+
objectName: "Contact",
72+
},
73+
surename: this.surename,
74+
familyname: this.familyname,
75+
name: this.name,
76+
...this.additionalOptions,
77+
},
78+
});
79+
80+
$.export("$summary", `Successfully created contact (ID: ${response.id})`);
81+
return response;
82+
},
83+
};

components/sevdesk/common/constants.mjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,3 +748,22 @@ export const CURRENCY_OPTIONS = [
748748
label: "Zimbabwean Dollar",
749749
},
750750
];
751+
752+
export const CONTACT_CATEGORIES = [
753+
{
754+
label: "Supplier",
755+
value: 2,
756+
},
757+
{
758+
label: "Customer",
759+
value: 3,
760+
},
761+
{
762+
label: "Partner",
763+
value: 4,
764+
},
765+
{
766+
label: "Prospect Customer",
767+
value: 28,
768+
},
769+
];

components/sevdesk/package.json

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

pnpm-lock.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)