2052 zapier integration 5 deploy twenty zapier app into the public repository (#2101)
* Add create_company Zap action * Add testing for that action * Core review returns
This commit is contained in:
106
packages/twenty-zapier/src/creates/create_company.ts
Normal file
106
packages/twenty-zapier/src/creates/create_company.ts
Normal file
@ -0,0 +1,106 @@
|
||||
import { Bundle, ZObject } from 'zapier-platform-core';
|
||||
import handleQueryParams from '../utils/handleQueryParams';
|
||||
|
||||
const perform = async (z: ZObject, bundle: Bundle) => {
|
||||
const response = await z.request({
|
||||
body: {
|
||||
query: `
|
||||
mutation CreateCompany {
|
||||
createOneCompany(
|
||||
data:{${handleQueryParams(bundle.inputData)}}
|
||||
)
|
||||
{id}
|
||||
}`,
|
||||
},
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Accept: 'application/json',
|
||||
Authorization: `Bearer ${bundle.authData.apiKey}`,
|
||||
},
|
||||
method: 'POST',
|
||||
url: `${process.env.SERVER_BASE_URL}/graphql`,
|
||||
});
|
||||
return response.json;
|
||||
};
|
||||
export default {
|
||||
display: {
|
||||
description: 'Creates a new Company in Twenty',
|
||||
hidden: false,
|
||||
label: 'Create New Company',
|
||||
},
|
||||
key: 'create_company',
|
||||
noun: 'Company',
|
||||
operation: {
|
||||
inputFields: [
|
||||
{
|
||||
key: 'name',
|
||||
label: 'Company Name',
|
||||
type: 'string',
|
||||
required: true,
|
||||
list: false,
|
||||
altersDynamicFields: false,
|
||||
},
|
||||
{
|
||||
key: 'address',
|
||||
label: 'Address',
|
||||
type: 'string',
|
||||
required: true,
|
||||
list: false,
|
||||
altersDynamicFields: false,
|
||||
},
|
||||
{
|
||||
key: 'domainName',
|
||||
label: 'Url',
|
||||
type: 'string',
|
||||
required: true,
|
||||
list: false,
|
||||
altersDynamicFields: false,
|
||||
},
|
||||
{
|
||||
key: 'linkedinUrl',
|
||||
label: 'Linkedin',
|
||||
type: 'string',
|
||||
required: false,
|
||||
list: false,
|
||||
altersDynamicFields: false,
|
||||
},
|
||||
{
|
||||
key: 'xUrl',
|
||||
label: 'Twitter',
|
||||
type: 'string',
|
||||
required: false,
|
||||
list: false,
|
||||
altersDynamicFields: false,
|
||||
},
|
||||
{
|
||||
key: 'annualRecurringRevenue',
|
||||
label: 'ARR (Annual Recurring Revenue)',
|
||||
type: 'number',
|
||||
required: false,
|
||||
list: false,
|
||||
altersDynamicFields: false,
|
||||
},
|
||||
{
|
||||
key: 'idealCustomerProfile',
|
||||
label: 'ICP (Ideal Customer Profile)',
|
||||
type: 'boolean',
|
||||
required: false,
|
||||
list: false,
|
||||
altersDynamicFields: false,
|
||||
},
|
||||
{
|
||||
key: 'employees',
|
||||
label: 'Employees (number of)',
|
||||
type: 'number',
|
||||
required: false,
|
||||
list: false,
|
||||
altersDynamicFields: false,
|
||||
},
|
||||
],
|
||||
sample: {
|
||||
name: 'Apple',
|
||||
address: 'Cupertino',
|
||||
},
|
||||
perform,
|
||||
},
|
||||
};
|
||||
@ -1,17 +1,16 @@
|
||||
import { Bundle, ZObject } from 'zapier-platform-core';
|
||||
import handleQueryParams from '../utils/handleQueryParams';
|
||||
|
||||
const perform = async (z: ZObject, bundle: Bundle) => {
|
||||
const response = await z.request({
|
||||
body: {
|
||||
query: `mutation
|
||||
CreatePerson {
|
||||
createOnePerson(data:{
|
||||
firstName: "${bundle.inputData.firstName}",
|
||||
lastName: "${bundle.inputData.lastName}",
|
||||
email: "${bundle.inputData.email}",
|
||||
phone: "${bundle.inputData.phone}",
|
||||
city: "${bundle.inputData.city}"
|
||||
}){id}}`,
|
||||
query: `
|
||||
mutation CreatePerson {
|
||||
createOnePerson(
|
||||
data:{${handleQueryParams(bundle.inputData)}}
|
||||
)
|
||||
{id}
|
||||
}`,
|
||||
},
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
Reference in New Issue
Block a user