diff --git a/samples/client/petstore/zapier/README.md b/samples/client/petstore/zapier/README.md index 01e3559bf81a..d12e0e96be25 100644 --- a/samples/client/petstore/zapier/README.md +++ b/samples/client/petstore/zapier/README.md @@ -6,12 +6,10 @@ This generator generates a partial implementation of a zapier integration from a It's a partial integration because you have to put in some code for it to be 100% complete, code that depends only on how your api is structured. -Here there are all the parts you need to complete by yourself: +Here there are all the parts you need to complete by yourself: ### 1) **utils/utils.js** isSearchAction method - This method has to return either true or false if a method is a [zapier search action](https://platform.zapier.com/docs/search-create). - ``` const isSearchAction = (key) => { // TODO: custom logic @@ -20,7 +18,6 @@ const isSearchAction = (key) => { ``` ### 2) **utils/utils.js** searchMiddleware method - This method has to return an array of resources (searches must return an array), if you have pagination or you api returns an array inside nested fields, here you have to extract the array. ``` @@ -30,34 +27,13 @@ const searchMiddleware = (action) => { } ``` -### 3) **utils/utils.js** isTrigger method - -This method has to return either true or false if a method is a [zapier search action](https://platform.zapier.com/docs/search-create). - -``` -const isTrigger = (key) => { - // TODO: custom logic - return false -} -``` - -### 4) **utils/utils.js** searchMiddleware method - -``` -const triggerMiddleware = (action) => { - return action -} -``` - ### 3) **authentication.js** - This file must be written completely according to your api authentication, you can get it generated automatically by creating the integration on the zapier website and filling the requested data, or you can build it yourself following [this guide](https://platform.zapier.com/cli_tutorials/getting-started#adding-authentication). ## Samples +To get your app made public on zapier you must provide a sample (json example response) for each of your actions, these samples get automatically generated by this generator but you have to have actual response examples in you openapi file. -To get your app made public on zapier you must provide a sample (json example response) for each of your actions, these samples get automatically generated by this generator but you have to have actual response examples in you openapi file. - -For example: +For example: ``` CreateUserResponse: diff --git a/samples/client/petstore/zapier/index.js b/samples/client/petstore/zapier/index.js index 8f60b0c7b1e6..2e98dba0e32c 100644 --- a/samples/client/petstore/zapier/index.js +++ b/samples/client/petstore/zapier/index.js @@ -1,5 +1,5 @@ const authentication = require('./authentication'); -const { searchActions, createActions } = require('./operations/actions'); +const { searchActions, createActions, triggers } = require('./operations/actions'); module.exports = { version: require('./package.json').version, @@ -7,4 +7,5 @@ module.exports = { authentication: authentication, searches: searchActions(), creates: createActions(), + triggers: triggers(), }; diff --git a/samples/client/petstore/zapier/operations/actions.js b/samples/client/petstore/zapier/operations/actions.js index d9a6a9afbbab..6e9b6d9478e7 100644 --- a/samples/client/petstore/zapier/operations/actions.js +++ b/samples/client/petstore/zapier/operations/actions.js @@ -1,7 +1,7 @@ const PetApi = require('../apis/PetApi'); const StoreApi = require('../apis/StoreApi'); const UserApi = require('../apis/UserApi'); -const { searchMiddleware, hasSearchRequisites, isSearchAction } = require('../utils/utils'); +const { triggerMiddleware, isTrigger, searchMiddleware, hasSearchRequisites, isSearchAction } = require('../utils/utils'); const actions = { [PetApi.addPet.key]: PetApi.addPet, @@ -29,4 +29,5 @@ const actions = { module.exports = { searchActions: () => Object.entries(actions).reduce((actions, [key, value]) => isSearchAction(key) && hasSearchRequisites(value) ? {...actions, [key]: searchMiddleware(value)} : actions, {}), createActions: () => Object.entries(actions).reduce((actions, [key, value]) => !isSearchAction(key) ? {...actions, [key]: value} : actions, {}), -} \ No newline at end of file + triggers: () => Object.entries(actions).reduce((actions, [key, value]) => isTrigger(key) ? {...actions, [key]: triggerMiddleware(value)} : actions, {}), +} diff --git a/samples/client/petstore/zapier/utils/utils.js b/samples/client/petstore/zapier/utils/utils.js index b00174f3f7b0..07c4915aaae3 100644 --- a/samples/client/petstore/zapier/utils/utils.js +++ b/samples/client/petstore/zapier/utils/utils.js @@ -30,6 +30,15 @@ const requestOptionsMiddleware = (z, bundle, requestOptions) => { return requestOptions } +const isTrigger = (key) => { + // TODO: custom logic + return false +} + +const triggerMiddleware = (action) => { + return action +} + module.exports = { replacePathParameters: replacePathParameters, childMapping: childMapping, @@ -39,4 +48,6 @@ module.exports = { isSearchAction: isSearchAction, searchMiddleware: searchMiddleware, requestOptionsMiddleware: requestOptionsMiddleware, + isTrigger: isTrigger, + triggerMiddleware: triggerMiddleware, }