1 |
|
2 | const get<%= CAMEL %> = (z, bundle) => {
|
3 | const responsePromise = z.request({
|
4 | url: `https://jsonplaceholder.typicode.com/posts/${bundle.inputData.id}`,
|
5 | });
|
6 | return responsePromise
|
7 | .then(response => z.JSON.parse(response.content));
|
8 | };
|
9 |
|
10 |
|
11 | const list<%= CAMEL %>s = (z) => {
|
12 | const responsePromise = z.request({
|
13 | url: 'https://jsonplaceholder.typicode.com/posts',
|
14 | params: {
|
15 | order_by: 'id desc'
|
16 | }
|
17 | });
|
18 | return responsePromise
|
19 | .then(response => z.JSON.parse(response.content));
|
20 | };
|
21 |
|
22 |
|
23 | const search<%= CAMEL %>s = (z, bundle) => {
|
24 | const responsePromise = z.request({
|
25 | url: 'https://jsonplaceholder.typicode.com/posts',
|
26 | params: {
|
27 | query: `name:${bundle.inputData.name}`
|
28 | }
|
29 | });
|
30 | return responsePromise
|
31 | .then(response => z.JSON.parse(response.content));
|
32 | };
|
33 |
|
34 |
|
35 | const create<%= CAMEL %> = (z, bundle) => {
|
36 | const responsePromise = z.request({
|
37 | method: 'POST',
|
38 | url: 'https://jsonplaceholder.typicode.com/posts',
|
39 | body: {
|
40 | name: bundle.inputData.name
|
41 | }
|
42 | });
|
43 | return responsePromise
|
44 | .then(response => z.JSON.parse(response.content));
|
45 | };
|
46 |
|
47 | module.exports = {
|
48 | key: '<%= KEY %>',
|
49 | noun: '<%= NOUN %>',
|
50 |
|
51 | get: {
|
52 | display: {
|
53 | label: 'Get <%= NOUN %>',
|
54 | description: 'Gets a <%= LOWER_NOUN %>.'
|
55 | },
|
56 | operation: {
|
57 | inputFields: [
|
58 | {key: 'id', required: true}
|
59 | ],
|
60 | perform: get<%= CAMEL %>
|
61 | }
|
62 | },
|
63 |
|
64 | list: {
|
65 | display: {
|
66 | label: 'New <%= NOUN %>',
|
67 | description: 'Lists the <%= LOWER_NOUN %>s.'
|
68 | },
|
69 | operation: {
|
70 | perform: list<%= CAMEL %>s
|
71 | }
|
72 | },
|
73 |
|
74 | search: {
|
75 | display: {
|
76 | label: 'Find <%= NOUN %>',
|
77 | description: 'Finds a <%= LOWER_NOUN %> by searching.'
|
78 | },
|
79 | operation: {
|
80 | inputFields: [
|
81 | {key: 'name', required: true}
|
82 | ],
|
83 | perform: search<%= CAMEL %>s
|
84 | },
|
85 | },
|
86 |
|
87 | create: {
|
88 | display: {
|
89 | label: 'Create <%= NOUN %>',
|
90 | description: 'Creates a new <%= LOWER_NOUN %>.'
|
91 | },
|
92 | operation: {
|
93 | inputFields: [
|
94 | {key: 'name', required: true}
|
95 | ],
|
96 | perform: create<%= CAMEL %>
|
97 | },
|
98 | },
|
99 |
|
100 | sample: {
|
101 | id: 1,
|
102 | name: 'Test'
|
103 | },
|
104 |
|
105 | outputFields: [
|
106 | {key: 'id', label: 'ID'},
|
107 | {key: 'name', label: 'Name'}
|
108 | ]
|
109 | };
|