-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding trigger dropdowns for List Appellations and Varietals
- Loading branch information
1 parent
a58a099
commit ba729d8
Showing
4 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const listAppellations = async (z, bundle) => { | ||
const response = await z.request({ | ||
url: 'https://sutter.innovint.us/api/v1/appellations', | ||
method: 'GET', | ||
headers: { | ||
'Accept': 'application/json', | ||
'Authorization': `Access-Token ${bundle.authData.accessToken}`, | ||
}, | ||
}); | ||
|
||
return response.json.map((appellation) => ({ | ||
id: appellation.id, | ||
name: appellation.name, | ||
})); | ||
}; | ||
|
||
module.exports = { | ||
key: 'listAppellations', | ||
noun: 'Appellation', | ||
display: { | ||
label: 'List Appellations', | ||
description: 'Triggers when a new appellation is added.', | ||
hidden: true, | ||
}, | ||
operation: { | ||
perform: listAppellations, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const listVarietals = async (z, bundle) => { | ||
const response = await z.request({ | ||
url: 'https://sutter.innovint.us/api/v1/varietals', | ||
method: 'GET', | ||
headers: { | ||
'Accept': 'application/json', | ||
'Authorization': `Access-Token ${bundle.authData.accessToken}`, | ||
}, | ||
}); | ||
|
||
return response.json.map((appellation) => ({ | ||
id: appellation.id, | ||
name: appellation.name, | ||
})); | ||
}; | ||
|
||
module.exports = { | ||
key: 'listVarietals', | ||
noun: 'Varietals', | ||
display: { | ||
label: 'List Varietals', | ||
description: 'Triggers when a new varietal is added.', | ||
hidden: true, | ||
}, | ||
operation: { | ||
perform: listVarietals, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const zapier = require('zapier-platform-core'); | ||
const nock = require('nock'); | ||
const App = require('../../index'); | ||
const appTester = zapier.createAppTester(App); | ||
const {bundle} = require('../_bundle'); | ||
const listAppellations = require('../../fields/list_appellations_dropdown'); | ||
|
||
describe('List Appellations Trigger', () => { | ||
zapier.tools.env.inject(); | ||
|
||
it('should load appellation data', async () => { | ||
nock('https://sutter.innovint.us') | ||
.get('/api/v1/appellations') | ||
.reply(200, [ | ||
{id: '1', name: 'Napa Valley'}, | ||
{id: '2', name: 'Sonoma Coast'}, | ||
]); | ||
|
||
const results = await appTester(listAppellations.operation.perform, bundle); | ||
|
||
results.should.containDeep([{id: '1', name: 'Napa Valley'}]); | ||
results.should.containDeep([{id: '2', name: 'Sonoma Coast'}]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const zapier = require('zapier-platform-core'); | ||
const nock = require('nock'); | ||
const App = require('../../index'); | ||
const appTester = zapier.createAppTester(App); | ||
const {bundle} = require('../_bundle'); | ||
const listVarietals = require('../../fields/list_varietals_dropdown'); | ||
|
||
describe('List Varietals Trigger', () => { | ||
zapier.tools.env.inject(); | ||
|
||
it('should load varietals data', async () => { | ||
nock('https://sutter.innovint.us') | ||
.get('/api/v1/varietals') | ||
.reply(200, [ | ||
{id: 'vari_LZ4E0PWYDM8X8LGX6R92JK51', name: 'Acolon'}, | ||
{id: 'vari_9P2VQ0D3NK7LZMZ6WROJ81E4', name: 'Agawam'}, | ||
]); | ||
|
||
const results = await appTester(listVarietals.operation.perform, bundle); | ||
|
||
results.should.containDeep( | ||
[{id: 'vari_LZ4E0PWYDM8X8LGX6R92JK51', name: 'Acolon'}]); | ||
results.should.containDeep( | ||
[{id: 'vari_9P2VQ0D3NK7LZMZ6WROJ81E4', name: 'Agawam'}]); | ||
}); | ||
}); |