2038 zapier integration 1 initialize a zapier app with a twenty related account (#2089)
* Add doc for Zapier development * Add twenty-zapier package * Install zapier packages * Update doc * Add twenty-zapier app * Update doc * Update apiKey slug * Update integration * Update create people to person * Update version * Fix lint * Remove useless comments * Update docs * Update version * Update naming * Add prettier * Simplify docs * Remove twenty related stuff from public doc * Use typescript boilerplate * Update details
This commit is contained in:
84
packages/twenty-zapier/src/creates/create_person.ts
Normal file
84
packages/twenty-zapier/src/creates/create_person.ts
Normal file
@ -0,0 +1,84 @@
|
||||
import { Bundle, ZObject } from 'zapier-platform-core';
|
||||
|
||||
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}}`,
|
||||
},
|
||||
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 Person in Twenty',
|
||||
hidden: false,
|
||||
label: 'Create New Person',
|
||||
},
|
||||
key: 'create_person',
|
||||
noun: 'Person',
|
||||
operation: {
|
||||
inputFields: [
|
||||
{
|
||||
key: 'firstName',
|
||||
label: 'First Name',
|
||||
type: 'string',
|
||||
required: true,
|
||||
list: false,
|
||||
altersDynamicFields: false,
|
||||
},
|
||||
{
|
||||
key: 'lastName',
|
||||
label: 'Last Name',
|
||||
type: 'string',
|
||||
required: false,
|
||||
list: false,
|
||||
altersDynamicFields: false,
|
||||
},
|
||||
{
|
||||
key: 'email',
|
||||
label: 'Email',
|
||||
type: 'string',
|
||||
required: true,
|
||||
list: false,
|
||||
altersDynamicFields: false,
|
||||
},
|
||||
{
|
||||
key: 'phone',
|
||||
label: 'Phone',
|
||||
type: 'string',
|
||||
required: false,
|
||||
list: false,
|
||||
altersDynamicFields: false,
|
||||
},
|
||||
{
|
||||
key: 'city',
|
||||
label: 'City',
|
||||
type: 'string',
|
||||
required: false,
|
||||
list: false,
|
||||
altersDynamicFields: false,
|
||||
},
|
||||
],
|
||||
sample: {
|
||||
firstName: 'John',
|
||||
lastName: 'Doe',
|
||||
email: 'johndoe@gmail.com',
|
||||
},
|
||||
perform,
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user