UNPKG

2.02 kBJavaScriptView Raw
1// triggers on a new <%= LOWER_NOUN %> with a certain tag
2const perform = async (z, bundle) => {
3 const response = await z.request({
4 url: 'https://jsonplaceholder.typicode.com/posts',
5 params: {
6 tag: bundle.inputData.tagName
7 }
8 });
9 // this should return an array of objects
10 return response.data;
11};
12
13module.exports = {
14 // see here for a full list of available properties:
15 // https://github.com/zapier/zapier-platform/blob/master/packages/schema/docs/build/schema.md#triggerschema
16 key: '<%= KEY %>',
17 noun: '<%= NOUN %>',
18
19 display: {
20 label: 'New <%= NOUN %>',
21 description: 'Triggers when a new <%= LOWER_NOUN %> is created.'
22 },
23
24 operation: {
25 perform,
26
27 <%= INCLUDE_INTRO_COMMENTS ? [
28 '// `inputFields` defines the fields a user could provide',
29 '// Zapier will pass them in as `bundle.inputData` later. They\'re optional.'
30 ].join('\n ') : '' %>
31 inputFields: [],
32
33 <%= INCLUDE_INTRO_COMMENTS ? [
34 '// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example',
35 '// from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of',
36 '// returned records, and have obvious placeholder values that we can show to any user.'
37 ].join('\n ') : '' %>
38 sample: {
39 id: 1,
40 name: 'Test'
41 },
42
43 <%= INCLUDE_INTRO_COMMENTS ? [
44 '// If fields are custom to each user (like spreadsheet columns), `outputFields` can create human labels',
45 '// For a more complete example of using dynamic fields see',
46 '// https://github.com/zapier/zapier-platform/tree/master/packages/cli#customdynamic-fields',
47 '// Alternatively, a static field definition can be provided, to specify labels for the fields'
48 ].join('\n ') : '' %>
49 outputFields: [
50 // these are placeholders to match the example `perform` above
51 // {key: 'id', label: 'Person ID'},
52 // {key: 'name', label: 'Person Name'}
53 ]
54 }
55};