From 22cea145f8e5bfc967286dc4a5dd428fe6f796c4 Mon Sep 17 00:00:00 2001 From: Faruk AYDIN Date: Mon, 7 Nov 2022 19:17:25 +0100 Subject: [PATCH] docs: Add global variable page --- packages/docs/pages/.vitepress/config.js | 4 ++ .../build-integrations/global-variable.md | 39 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 packages/docs/pages/build-integrations/global-variable.md diff --git a/packages/docs/pages/.vitepress/config.js b/packages/docs/pages/.vitepress/config.js index 92ec8bf0..b549dc45 100644 --- a/packages/docs/pages/.vitepress/config.js +++ b/packages/docs/pages/.vitepress/config.js @@ -189,6 +189,10 @@ export default defineConfig({ text: 'App', link: '/build-integrations/app', }, + { + text: 'Global variable', + link: '/build-integrations/global-variable', + }, ], }, { diff --git a/packages/docs/pages/build-integrations/global-variable.md b/packages/docs/pages/build-integrations/global-variable.md new file mode 100644 index 00000000..a3bff21c --- /dev/null +++ b/packages/docs/pages/build-integrations/global-variable.md @@ -0,0 +1,39 @@ +# Global Variable + +Before handling authentication and building a trigger and an action, it's better to explain the `global variable` concept in Automatisch. Automatisch provides you the global variable that you need to use with authentication, triggers, action, and basically all the stuff you will build for the integration. + +The global variable is represented as `$` variable in the codebase, and it's a JSON object that contains the following properties: + +## $.auth.set + +```typescript +$.auth.set({ + key: 'value', +}); +``` + +It's used to set the authentication data, and you can use this method with multiple pairs. The data will be stored in the database and can be retrieved later by using `$.auth.data` property. We use this method when we store the credentials of the third-party service. Note that Automatisch encrypts the data before storing it in the database. + +## $.auth.data + +```typescript +$.auth.data; // { key: 'value' } +``` + +It's used to retrieve the authentication data that we set with `$.auth.set()`. The data will be retrieved from the database. We use the data property with the key name when we need to get one specific value from the data object. + +## $.app.baseUrl + +```typescript +$.app.baseUrl; // https://thecatapi.com +``` + +It's used to retrieve the base URL of the app that we defined previously. In our example, it returns `https://thecatapi.com`. We use this property when we need to use the base URL of the third-party service. + +## $.app.apiBaseUrl + +```typescript +$.app.apiBaseUrl; // https://api.thecatapi.com +``` + +It's used to retrieve the API base URL of the app that we defined previously. In our example, it returns `https://api.thecatapi.com`. We use this property when we need to use the API base URL of the third-party service.