diff --git a/components/sevdesk/actions/create-contact/create-contact.mjs b/components/sevdesk/actions/create-contact/create-contact.mjs new file mode 100644 index 0000000000000..4d77364a663de --- /dev/null +++ b/components/sevdesk/actions/create-contact/create-contact.mjs @@ -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; + }, +}; diff --git a/components/sevdesk/common/constants.mjs b/components/sevdesk/common/constants.mjs index dc9cb47bf7b85..5cd84a35bb410 100644 --- a/components/sevdesk/common/constants.mjs +++ b/components/sevdesk/common/constants.mjs @@ -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, + }, +]; diff --git a/components/sevdesk/package.json b/components/sevdesk/package.json index 793f847f56ce4..212e696c08bd7 100644 --- a/components/sevdesk/package.json +++ b/components/sevdesk/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/sevdesk", - "version": "0.1.0", + "version": "0.2.0", "description": "Pipedream sevDesk Components", "main": "sevdesk.app.mjs", "keywords": [ @@ -13,7 +13,7 @@ "access": "public" }, "dependencies": { - "@pipedream/platform": "^1.5.1" + "@pipedream/platform": "^3.0.3" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 461c8c72e48df..b7c64b215573c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11573,8 +11573,8 @@ importers: components/sevdesk: dependencies: '@pipedream/platform': - specifier: ^1.5.1 - version: 1.6.6 + specifier: ^3.0.3 + version: 3.0.3 components/seven: dependencies: