Instructions for Setting Up and Running the “Fuel Price” Script in Google Apps Script
Creating a Project
- Please go to Google Apps Script.
- Go to “New project” to create a new project.
3. You can rename the project by clicking on “Untitled project”.
Configuring the Project
Open the code editor and delete the contents of Code.gs.
Download to your computer and insert the main script code from the link:
https://drive.google.com/file/d/1K8r2n7KU1lfAGW7206pO6ffrfObP9eM-/view?usp=drive_link
Connecting the Drive API
- Navigate to the “Services” menu on the sidebar.
2. Click the “+” icon next to “Services”.
3. Find Drive API in the list, select it, and click “Add”.
4. Setting up the main parameters of the script
- In the script, locate and configure the following parameters:
-
- UPDATE_CONFIG:
name: Location.- terminalApiKey: Your terminal’s API key from Prime Dash Board.
- prices:
- inputName: Item name in the Excel (e.g., fuel type).
- code: Article (system code in the Prime-fuel).
- NOTIFICATION_RECIPIENTS: List of email addresses for notifications.
We send a notification about the script execution to one or more of your emails.
You can add our address if you want us to receive these messages as well: logs@incust.com
- API_URL: API server URL. Please use for Prime-fuel: https://api.prime-fuel.com/v1/term
- SENDERS: List of email addresses allowed to send files.
IMPORTANT! You must list the email addresses from which files are processed.
This is done for security reasons to prevent an unauthorized person from sending you a file that could change your prices.
- LOG_FILE_NAME: Log file name. Please left as it is.
- OFFSET: PThe time when the price should take effect:
- inFiveMinutes, tomorrow, dayAfterTomorrow, inTwoDays.
- UPDATE_CONFIG:
Setting Up Triggers
Open the “Triggers” section on the sidebar.
2. Click “Add Trigger”.and configure the settings:
- Function to run: Select run.
- Event source: Select Time-driven.
- Type of time-based trigger: e.g., “Hourly”.
- Interval: et an interval (e.g., every 30 minutes or every hour).
3. Click “Save”.
Granting Access Permissions
- On the first run, a window will appear saying “Authorization required”. Click “Review permissions”
2. Select your Google account.
3. If you see the warning “Google hasn’t verified this app”, click:
- “Advanced”.
- “Go to [project name] (unsafe)”.
4. Click “Allow” to grant access.
Recommendations for Use
- Set a trigger to run the script every 30 minutes or hour to prevent inbox clutter.
- New prices are applied according to OFFSET settings, e.g., at 00:01 the next day in the respective timezone.