Compare commits

...

3 Commits

Author SHA1 Message Date
Rıdvan Akca
daa38ab846 feat(bigin-by-zoho-crm): add create company action 2024-02-22 14:16:48 +03:00
Rıdvan Akca
00e18cf42d feat(bigin-by-zoho-crm): add create event action 2024-02-21 18:14:22 +03:00
Rıdvan Akca
b3d2a1167c feat(bigin-by-zoho-crm): add create contact action 2024-02-21 15:27:35 +03:00
10 changed files with 776 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,217 @@
import defineAction from '../../../../helpers/define-action.js';
export default defineAction({
name: 'Create contact',
key: 'createContact',
description: 'Creates a new contact.',
arguments: [
{
label: 'Contact Owner',
key: 'contactOwnerId',
type: 'dropdown',
required: false,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listContactOwners',
},
],
},
},
{
label: 'First Name',
key: 'firstName',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Last Name',
key: 'lastName',
type: 'string',
required: true,
description: '',
variables: true,
},
{
label: 'Title',
key: 'title',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Email',
key: 'email',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Company ID',
key: 'companyId',
type: 'dropdown',
required: false,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listCompanies',
},
],
},
},
{
label: 'Mobile',
key: 'mobile',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Email Opt Out',
key: 'emailOptOut',
type: 'dropdown',
required: false,
description: '',
variables: true,
options: [
{ label: 'True', value: true },
{ label: 'False', value: false },
],
},
{
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: 'Mailing Street',
key: 'mailingStreet',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Mailing City',
key: 'mailingCity',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Mailing State',
key: 'mailingState',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Mailing Country',
key: 'mailingCountry',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Mailing Zip',
key: 'mailingZip',
type: 'string',
required: false,
description: '',
variables: true,
},
],
async run($) {
const {
contactOwnerId,
firstName,
lastName,
title,
email,
companyId,
mobile,
emailOptOut,
tags,
description,
mailingStreet,
mailingCity,
mailingState,
mailingCountry,
mailingZip,
} = $.step.parameters;
const allTags = tags.map((tag) => ({
name: tag.tag,
}));
const body = {
data: [
{
Owner: {
id: contactOwnerId,
},
Account_Name: {
id: companyId,
},
First_Name: firstName,
Last_Name: lastName,
Title: title,
Email: email,
Mobile: mobile,
Email_Opt_Out: emailOptOut,
Tag: allTags,
Description: description,
Mailing_Street: mailingStreet,
Mailing_City: mailingCity,
Mailing_State: mailingState,
Mailing_Country: mailingCountry,
Mailing_Zip: mailingZip,
},
],
};
const { data } = await $.http.post(`/bigin/v2/Contacts`, body);
$.setActionItem({
raw: data[0],
});
},
});

View File

@@ -0,0 +1,293 @@
import defineAction from '../../../../helpers/define-action.js';
export default defineAction({
name: 'Create event',
key: 'createEvent',
description: 'Creates a new event.',
arguments: [
{
label: 'Host',
key: 'hostId',
type: 'dropdown',
required: false,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listContactOwners',
},
],
},
},
{
label: 'Title',
key: 'title',
type: 'string',
required: true,
description: '',
variables: true,
},
{
label: 'From',
key: 'from',
type: 'string',
required: true,
description: 'The date format is ISO8601 (yyyy-mm-ddTHH:mm:ssZ).',
variables: true,
},
{
label: 'To',
key: 'to',
type: 'string',
required: true,
description: 'The date format is ISO8601 (yyyy-mm-ddTHH:mm:ssZ).',
variables: true,
},
{
label: 'All Day',
key: 'allDay',
type: 'dropdown',
required: false,
description: '',
variables: true,
options: [
{ label: 'True', value: true },
{ label: 'False', value: false },
],
},
{
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: '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: '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: 'string',
required: false,
description:
'This signifies the weekday when the event recurs. The options include SU, MO, TU, WE, TH, FR, or SA. This rule applies to events that repeat daily, weekly, monthly, and yearly (should not be combined with INTERVAL).',
variables: true,
},
{
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: 'Reminder',
key: 'reminder',
type: 'dropdown',
required: false,
description:
'Provide the reminder list to notify or prompt participants prior to the event.',
variables: true,
options: [
{ label: '5 min', value: '5 minutes' },
{ label: '10 min', value: '10 minutes' },
{ label: '15 min', value: '15 minutes' },
{ label: '1 hrs', value: '1 hours' },
{ label: '2 hrs', value: '2 hours' },
{ label: '1 days', value: '1 days' },
{ label: '2 days', value: '2 days' },
{ label: '1 weeks', value: '1 weeks' },
],
},
{
label: 'Location',
key: 'location',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Related Module',
key: 'relatedModule',
type: 'dropdown',
required: false,
description: '',
variables: true,
options: [
{ label: 'Companies', value: 'Accounts' },
{ label: 'Contacts', value: 'Contacts' },
{ label: 'Deals', value: 'Deals' },
],
},
{
label: 'Participants',
key: 'participants',
type: 'dynamic',
required: false,
description: 'Email Address of participants.',
fields: [
{
label: 'Participant',
key: 'participant',
type: 'string',
required: false,
variables: true,
},
],
},
{
label: 'Description',
key: 'description',
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,
},
],
},
],
async run($) {
const {
hostId,
title,
from,
to,
allDay,
frequency,
interval,
byMonthDay,
byDay,
byWeek,
count,
until,
reminder,
location,
relatedModule,
participants,
description,
tags,
} = $.step.parameters;
const allTags = tags.map((tag) => ({
name: tag.tag,
}));
const allParticipants = participants.map((participant) => ({
type: 'email',
participant: participant.participant,
}));
const [unit, period] = reminder.split(' ');
let rrule = `FREQ=${frequency};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};`;
const body = {
data: [
{
Owner: {
id: hostId,
},
Event_Title: title,
Start_DateTime: from,
End_DateTime: to,
All_day: allDay,
$se_module: relatedModule,
Recurring_Activity: {
RRULE: rrule,
},
Remind_At: [
{
unit: Number(unit),
period,
},
],
Venue: location,
Participants: allParticipants,
Description: description,
Tag: allTags,
},
],
};
const { data } = await $.http.post(`/bigin/v2/Events`, body);
$.setActionItem({
raw: data,
});
},
});

View File

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

View File

@@ -1,3 +1,5 @@
import listCompanies from './list-companies/index.js';
import listOrganizations from './list-organizations/index.js';
import listContactOwners from './list-contact-owners/index.js';
export default [listOrganizations];
export default [listCompanies, listOrganizations, listContactOwners];

View File

@@ -0,0 +1,39 @@
export default {
name: 'List companies',
key: 'listCompanies',
async run($) {
const companies = {
data: [],
};
const params = new URLSearchParams({
page: 1,
pageSize: 200,
fields: 'Account_Name',
});
let next = false;
do {
const { data } = await $.http.get('/bigin/v2/Accounts', { params });
if (data.info.more_records) {
params.page = params.page + 1;
next = true;
} else {
next = false;
}
if (data.data) {
for (const account of data.data) {
companies.data.push({
value: account.id,
name: account.Account_Name,
});
}
}
} while (next);
return companies;
},
};

View File

@@ -0,0 +1,39 @@
export default {
name: 'List contact owners',
key: 'listContactOwners',
async run($) {
const contactOwners = {
data: [],
};
const params = {
type: 'AllUsers',
page: 1,
pageSize: 200,
};
let next = false;
do {
const { data } = await $.http.get('/bigin/v2/users', params);
if (data.users.length === params.pageSize) {
next = true;
params.page = params.page + 1;
} else {
next = false;
}
if (data.users) {
for (const user of data.users) {
contactOwners.data.push({
value: user.id,
name: user.full_name,
});
}
}
} while (next);
return contactOwners;
},
};

View File

@@ -4,6 +4,7 @@ import auth from './auth/index.js';
import setBaseUrl from './common/set-base-url.js';
import triggers from './triggers/index.js';
import dynamicData from './dynamic-data/index.js';
import actions from './actions/index.js';
export default defineApp({
name: 'Bigin By Zoho CRM',
@@ -18,4 +19,5 @@ export default defineApp({
auth,
triggers,
dynamicData,
actions,
});

View File

@@ -38,6 +38,7 @@ export default defineConfig({
collapsed: true,
items: [
{ text: 'Triggers', link: '/apps/bigin-by-zoho-crm/triggers' },
{ text: 'Actions', link: '/apps/bigin-by-zoho-crm/actions' },
{ text: 'Connection', link: '/apps/bigin-by-zoho-crm/connection' },
],
},

View File

@@ -0,0 +1,16 @@
---
favicon: /favicons/bigin-by-zoho-crm.svg
items:
- name: Create company
desc: Creates a new company.
- name: Create contact
desc: Creates a new contact.
- name: Create event
desc: Creates a new event.
---
<script setup>
import CustomListing from '../../components/CustomListing.vue'
</script>
<CustomListing />