Deploying the Synthesize SDK using PowerShell Terminal in Windows

A Comprehensive Guide: Setup, Integration, and Task Scheduling with PowerShell

This guide will walk you through the process of deploying the Synthesize SDK using the PowerShell terminal in Windows. It will cover steps to clone the repository, set up the environment, run commands, and schedule tasks.

Prerequisites

  • PowerShell 7.0 or higher
  • Git installed on your system, or download the .zip repository from GitHub

Step 1: Obtain the Repository

Option 1: Clone the Repository with Git

Open the PowerShell terminal and navigate to the directory where you want to clone the repository. Run the following command:

git clone https://github.com/meetgradient/Synthesize-SDK-PS.git

Option 2: Download the .zip Repository

If you don't have Git installed, you can download the .zip repository from GitHub:

  1. Visit https://github.com/meetgradient/Synthesize-SDK-PS
  2. Click on the green "Code" button and choose "Download ZIP"
  3. Extract the contents of the .zip file to your desired directory

Step 2: Change Directory

Navigate to the cloned or extracted repository by running:

cd Synthesize-SDK-PS

Step 3: Set Up the Environment

Create a .env file to store the API keys and other required variables. Use a text editor to create a new file named ".env" in the root directory of the project. Add the following contents:

makefileCopy code
SYNTHESIZE_API_KEY=your_synthesize_api_key
VENDOR_API_KEY=your_vendor_api_key
GRADIENT_TOKEN=your_gradient_token

Replace "your_synthesize_api_key", "your_vendor_api_key", and "your_gradient_token" with the respective keys and token obtained from the Synthesize platform and your vendor.

Step 4: Load Environment Variables

In the PowerShell terminal, run the following command to load the environment variables:

powershellCopy code
. .\load-env.ps1

Step 5: Update Integration Status

Run the 'update-status' command to update the status of the custom integration to pending:

powershellCopy code
.\update-status.ps1

Step 6: Sync Usage

Once the custom integration is configured, run the 'sync-usage' command to sync usage for the mapped customers and services:

powershellCopy code
.\sync-usage.ps1

Scheduling Recurring Tasks in PowerShell

To schedule a recurring task in PowerShell, you can use the built-in Task Scheduler. Follow these steps:

  1. Open Task Scheduler by searching for it in the Start menu.

  2. Click on "Create Task" in the right-hand pane.

  3. In the "General" tab, give your task a name and description.

  4. Switch to the "Triggers" tab and click on "New" to create a new trigger. Choose the schedule settings as desired (e.g., daily, weekly, or monthly).

  5. Switch to the "Actions" tab and click on "New" to create a new action. In the "Program/script" field, input the path to your PowerShell executable (usually "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"). In the "Add arguments" field, input the following command:

arduinoCopy code
-ExecutionPolicy Bypass -File "path\to\sync-usage.ps1"

Replace "path\to" with the actual path to the "sync-usage.ps1" script in your Synthesize-SDK-PS directory.

  1. Click "OK" to save the action, and then click "OK" again to save the task. The task will now run according to the schedule you specified.

By following these steps, you can set up the Synthesize SDK, integrate it with your vendor, and schedule tasks using the PowerShell terminal in Windows.