-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
70 lines (57 loc) · 2.31 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const { version: platformVersion } = require('zapier-platform-core');
const { version } = require('./package.json');
// auth
const authentication = require('./authentication/Custom');
// triggers
const newProduct = require('./triggers/NewProduct');
const newLicensee = require('./triggers/NewLicensee');
// searches
const searchProduct = require('./searches/FindProduct');
const searchLicensee = require('./searches/FindLicensee');
// creates
const createProduct = require('./creates/CreateProduct');
const createLicensee = require('./creates/CreateLicensee');
const createLicense = require('./creates/CreateLicense');
// search or creates
const searchOrCreateProduct = require('./search_or_creates/SearchOrCreateProduct');
const searchOrCreateLicensee = require('./search_or_creates/SearchOrCreateLicensee');
const addAuthToHeader = (request, z, bundle) => {
request.headers.Authorization = `Basic ${Buffer.from(`apiKey:${bundle.authData.apiKey}`).toString('base64')}`;
return request;
};
// We can roll up all our behaviors in an App.
const App = {
// This is just shorthand to reference the installed dependencies you have. Zapier will
// need to know these before we can upload
version,
platformVersion,
// basic authentication
authentication,
// beforeRequest & afterResponse are optional hooks into the provided HTTP client
beforeRequest: [addAuthToHeader],
afterResponse: [],
// If you want to define optional resources to simplify creation of triggers, searches, creates - do that here!
resources: {},
// If you want your trigger to show up, you better include it here!
triggers: {
[newProduct.key]: newProduct,
[newLicensee.key]: newLicensee,
},
// If you want your searches to show up, you better include it here!
searches: {
[searchLicensee.key]: searchLicensee,
[searchProduct.key]: searchProduct,
},
// If you want your creates to show up, you better include it here!
creates: {
[createProduct.key]: createProduct,
[createLicensee.key]: createLicensee,
[createLicense.key]: createLicense,
},
searchOrCreates: {
[searchOrCreateProduct.key]: searchOrCreateProduct,
[searchOrCreateLicensee.key]: searchOrCreateLicensee,
},
};
// Finally, export the app.
module.exports = App;