Compare commits

...

2 Commits

Author SHA1 Message Date
Rıdvan Akca
dc3695766c feat(bigin-by-zoho-crm): add create task action 2024-02-22 16:10:13 +03:00
Rıdvan Akca
daa38ab846 feat(bigin-by-zoho-crm): add create company action 2024-02-22 14:16:48 +03:00
4 changed files with 414 additions and 1 deletions

View File

@@ -0,0 +1,161 @@
import defineAction from '../../../../helpers/define-action.js';
export default defineAction({
name: 'Create company',
key: 'createCompany',
description: 'Creates a new company.',
arguments: [
{
label: 'Company Owner',
key: 'companyOwnerId',
type: 'dropdown',
required: false,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listContactOwners',
},
],
},
},
{
label: 'Company Name',
key: 'companyName',
type: 'string',
required: true,
description: '',
variables: true,
},
{
label: 'Phone',
key: 'phone',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Website',
key: 'website',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Tags',
key: 'tags',
type: 'dynamic',
required: false,
description: '',
fields: [
{
label: 'Tag',
key: 'tag',
type: 'string',
required: false,
variables: true,
},
],
},
{
label: 'Description',
key: 'description',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Billing Street',
key: 'billingStreet',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Billing City',
key: 'billingCity',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Billing State',
key: 'billingState',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Billing Country',
key: 'billingCountry',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Billing Code',
key: 'billingCode',
type: 'string',
required: false,
description: '',
variables: true,
},
],
async run($) {
const {
contactOwnerId,
companyName,
phone,
website,
tags,
description,
billingStreet,
billingCity,
billingState,
billingCountry,
billingCode,
} = $.step.parameters;
const allTags = tags.map((tag) => ({
name: tag.tag,
}));
const body = {
data: [
{
Owner: {
id: contactOwnerId,
},
Account_Name: companyName,
Phone: phone,
Website: website,
Tag: allTags,
Description: description,
Billing_Street: billingStreet,
Billing_City: billingCity,
Billing_State: billingState,
Billing_Country: billingCountry,
Billing_Code: billingCode,
},
],
};
const { data } = await $.http.post(`/bigin/v2/Accounts`, body);
$.setActionItem({
raw: data[0],
});
},
});

View File

@@ -0,0 +1,246 @@
import defineAction from '../../../../helpers/define-action.js';
export default defineAction({
name: 'Create task',
key: 'createTask',
description: 'Creates a new task.',
arguments: [
{
label: 'Task Owner',
key: 'taskOwnerId',
type: 'dropdown',
required: false,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listContactOwners',
},
],
},
},
{
label: 'Subject',
key: 'subject',
type: 'string',
required: true,
description: '',
variables: true,
},
{
label: 'Due Date',
key: 'dueDate',
type: 'string',
required: true,
description: 'The date format is yyyy-mm-dd.',
variables: true,
},
{
label: 'Frequency (Recurring Activity)',
key: 'frequency',
type: 'dropdown',
required: false,
description:
'Specifies the frequency of event recurrence. The options include DAILY, WEEKLY, MONTHLY, or YEARLY.',
variables: true,
options: [
{ label: 'None', value: 'NONE' },
{ label: 'Daily Events', value: 'DAILY' },
{ label: 'Weekly Events', value: 'WEEKLY' },
{ label: 'Monthly Events', value: 'MONTHLY' },
],
},
{
label: 'Interval (Recurring Activity)',
key: 'interval',
type: 'string',
required: false,
description:
'Specifies the time difference between individual events. The INTERVAL can be anywhere from 1 to 99. For instance, with a WEEKLY event set at an INTERVAL of 2, there will be a two-week gap between each occurrence.',
variables: true,
},
{
label: 'Start Date (Recurring Activity)',
key: 'startDate',
type: 'string',
required: false,
description: 'The date format is yyyy-mm-dd.',
variables: true,
},
{
label: 'By Month Day (Recurring Activity)',
key: 'byMonthDay',
type: 'string',
required: false,
description:
'This specifies the date within the month when the event recurs. The BYMONTHDAY value can be any number from 1 to 31. This rule applies exclusively to events that repeat monthly or yearly.',
variables: true,
},
{
label: 'By Week (Recurring Activity)',
key: 'byWeek',
type: 'dropdown',
required: false,
description:
'Only relevant for events that occur on a monthly or yearly basis.',
variables: true,
options: [
{ label: 'First week of the month', value: '1' },
{ label: 'Second week of the month', value: '2' },
{ label: 'Third week of the month', value: '3' },
{ label: 'Fourth week of the month', value: '4' },
{ label: 'Last week of the month', value: '-1' },
],
},
{
label: 'By Day (Recurring Activity)',
key: 'byDay',
type: 'dropdown',
required: false,
description:
'This signifies the weekday when the event recurs. This rule applies to events that repeat daily, weekly, monthly, and yearly (should not be combined with INTERVAL).',
variables: true,
options: [
{ label: 'Sunday', value: 'SU' },
{ label: 'Monday', value: 'MO' },
{ label: 'Tuesday', value: 'TU' },
{ label: 'Wednesday', value: 'WE' },
{ label: 'Thursday', value: 'TH' },
{ label: 'Friday', value: 'FR' },
{ label: 'Saturday', value: 'SA' },
],
},
{
label: 'Count (Recurring Activity)',
key: 'count',
type: 'string',
required: false,
description:
'Specifies the number of events you wish to generate. The count value range from 1 to 99.',
variables: true,
},
{
label: 'Until (Recurring Activity)',
key: 'until',
type: 'string',
required: false,
description:
'Specifies the concluding date for the event recurrence. Please input the date in the YYYY-MM-DD format.',
variables: true,
},
{
label: 'Description',
key: 'description',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Priority',
key: 'priority',
type: 'dropdown',
required: false,
description: '',
variables: true,
options: [
{ label: 'High', value: 'High' },
{ label: 'Normal', value: 'Normal' },
],
},
{
label: 'Status',
key: 'status',
type: 'dropdown',
required: false,
description: '',
variables: true,
options: [
{ label: 'In Progress', value: 'In Progress' },
{ label: 'Completed', value: 'Completed' },
],
},
{
label: 'Tags',
key: 'tags',
type: 'dynamic',
required: false,
description: '',
fields: [
{
label: 'Tag',
key: 'tag',
type: 'string',
required: false,
variables: true,
},
],
},
],
async run($) {
const {
taskOwnerId,
subject,
dueDate,
frequency,
startDate,
interval,
byMonthDay,
byDay,
byWeek,
count,
until,
description,
priority,
status,
tags,
} = $.step.parameters;
const allTags = tags.map((tag) => ({
name: tag.tag,
}));
let rrule;
if (frequency) rrule += `FREQ=${frequency};`;
if (interval) rrule += `INTERVAL=${interval};`;
if (count) rrule += `COUNT=${count};`;
if (byMonthDay) rrule += `BYMONTHDAY=${byMonthDay};`;
if (byDay) rrule += `BYDAY=${byDay};`;
if (byWeek) rrule += `BYSETPOS=${byWeek};`;
if (until) rrule += `UNTIL=${until};`;
if (startDate) rrule += `DTSTART=${startDate}`;
const body = {
data: [
{
Owner: {
id: taskOwnerId,
},
Subject: subject,
Due_Date: dueDate,
Description: description,
Priority: priority,
Status: status,
Tag: allTags,
},
],
};
if (rrule) {
body.data[0].Recurring_Activity = {
RRULE: rrule,
};
}
const { data } = await $.http.post(`/bigin/v2/Tasks`, body);
$.setActionItem({
raw: data,
});
},
});

View File

@@ -1,4 +1,6 @@
import createCompany from './create-company/index.js';
import createContact from './create-contact/index.js'; import createContact from './create-contact/index.js';
import createEvent from './create-event/index.js'; import createEvent from './create-event/index.js';
import createTask from './create-task/index.js';
export default [createContact, createEvent]; export default [createCompany, createContact, createEvent, createTask];

View File

@@ -1,10 +1,14 @@
--- ---
favicon: /favicons/bigin-by-zoho-crm.svg favicon: /favicons/bigin-by-zoho-crm.svg
items: items:
- name: Create company
desc: Creates a new company.
- name: Create contact - name: Create contact
desc: Creates a new contact. desc: Creates a new contact.
- name: Create event - name: Create event
desc: Creates a new event. desc: Creates a new event.
- name: Create task
desc: Creates a new task.
--- ---
<script setup> <script setup>