|
| 1 | +import suitedash from "../../suitedash.app.mjs"; |
| 2 | + |
| 3 | +export default { |
| 4 | + key: "suitedash-create-company", |
| 5 | + name: "Create Company", |
| 6 | + description: "Creates a new company in SuiteDash. [See the documentation](https://app.suitedash.com/secure-api/swagger)", |
| 7 | + version: "0.0.1", |
| 8 | + type: "action", |
| 9 | + props: { |
| 10 | + suitedash, |
| 11 | + companyName: { |
| 12 | + propDefinition: [ |
| 13 | + suitedash, |
| 14 | + "companyName", |
| 15 | + ], |
| 16 | + }, |
| 17 | + companyRole: { |
| 18 | + propDefinition: [ |
| 19 | + suitedash, |
| 20 | + "role", |
| 21 | + ], |
| 22 | + }, |
| 23 | + firstName: { |
| 24 | + type: "string", |
| 25 | + label: "First Name", |
| 26 | + description: "First name of the company's primary contact", |
| 27 | + }, |
| 28 | + lastName: { |
| 29 | + type: "string", |
| 30 | + label: "Last Name", |
| 31 | + description: "Last name of the company's primary contact", |
| 32 | + }, |
| 33 | + email: { |
| 34 | + type: "string", |
| 35 | + label: "Email", |
| 36 | + description: "Email address of the company's primary contact", |
| 37 | + }, |
| 38 | + sendWelcomeEmail: { |
| 39 | + type: "boolean", |
| 40 | + label: "Send Welcome Email", |
| 41 | + description: "Send welcome email to the primary contact. Default: `false`", |
| 42 | + optional: true, |
| 43 | + default: false, |
| 44 | + }, |
| 45 | + createPrimaryContactIfNotExists: { |
| 46 | + type: "boolean", |
| 47 | + label: "Create Primary Contact If Not Exists", |
| 48 | + description: "Create a Primary Contact with all provided data if the email does not exist. Default: `true`", |
| 49 | + optional: true, |
| 50 | + default: true, |
| 51 | + }, |
| 52 | + preventIndividualMode: { |
| 53 | + type: "boolean", |
| 54 | + label: "Prevent Individual Mode", |
| 55 | + description: "Prevent this Primary Contact from switching into `Individual Mode`. Default: `false`", |
| 56 | + optional: true, |
| 57 | + default: false, |
| 58 | + }, |
| 59 | + }, |
| 60 | + async run({ $ }) { |
| 61 | + const response = await this.suitedash.createCompany({ |
| 62 | + $, |
| 63 | + data: { |
| 64 | + name: this.companyName, |
| 65 | + role: this.companyRole, |
| 66 | + primaryContact: { |
| 67 | + first_name: this.firstName, |
| 68 | + last_name: this.lastName, |
| 69 | + email: this.email, |
| 70 | + send_welcome_email: this.sendWelcomeEmail, |
| 71 | + create_primary_contact_if_not_exists: this.createPrimaryContactIfNotExists, |
| 72 | + prevent_individual_mode: this.preventIndividualMode, |
| 73 | + }, |
| 74 | + }, |
| 75 | + }); |
| 76 | + $.export("$summary", `Successfully created company ${this.companyName}`); |
| 77 | + return response; |
| 78 | + }, |
| 79 | +}; |
0 commit comments