Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions components/sevdesk/actions/create-contact/create-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { CONTACT_CATEGORIES } from "../../common/constants.mjs";
import sevdesk from "../../sevdesk.app.mjs";

export default {
key: "sevdesk-create-contact",
name: "Create Contact",
description: "Create a new contact. [See the documentation](https://api.sevdesk.de/#tag/Contact/operation/createContact)",
version: "0.0.1",
type: "action",
props: {
sevdesk,
category: {
type: "integer",
label: "Category",
description: "Category of the contact",
options: CONTACT_CATEGORIES,
},
parent: {
propDefinition: [
sevdesk,
"contactId",
],
label: "Parent Contact ID",
description: "The parent contact to which this contact belongs. Must be an organization",
optional: true,
},
surename: {
type: "string",
label: "First Name",
description: "The first name of the contact, if it is not an organization.",
optional: true,
},
familyname: {
type: "string",
label: "Last Name",
description: "The last name of the contact, if it is not an organization.",
optional: true,
},
name: {
type: "string",
label: "Name (Organization)",
description: "The name of the contact, if it is an organization.",
optional: true,
},
additionalOptions: {
type: "object",
label: "Additional Options",
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\" }`",
optional: true,
},
},
methods: {
createContact(opts = {}) {
return this.sevdesk._makeRequest({
method: "POST",
path: "/Contact",
...opts,
});
},
},
async run({ $ }) {
const { objects: response } = await this.createContact({
$,
data: {
category: {
id: this.category,
objectName: "Category",
},
parent: this.parent && {
id: this.parent,
objectName: "Contact",
},
surename: this.surename,
familyname: this.familyname,
name: this.name,
...this.additionalOptions,
},
});

$.export("$summary", `Successfully created contact (ID: ${response.id})`);
return response;
},
};
19 changes: 19 additions & 0 deletions components/sevdesk/common/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -748,3 +748,22 @@ export const CURRENCY_OPTIONS = [
label: "Zimbabwean Dollar",
},
];

export const CONTACT_CATEGORIES = [
{
label: "Supplier",
value: 2,
},
{
label: "Customer",
value: 3,
},
{
label: "Partner",
value: 4,
},
{
label: "Prospect Customer",
value: 28,
},
];
4 changes: 2 additions & 2 deletions components/sevdesk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/sevdesk",
"version": "0.1.0",
"version": "0.2.0",
"description": "Pipedream sevDesk Components",
"main": "sevdesk.app.mjs",
"keywords": [
Expand All @@ -13,7 +13,7 @@
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.5.1"
"@pipedream/platform": "^3.0.3"
}
}

4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading