aliask / upthing

WebUI and Webhook management interface for Up Bank

Home Page:https://willrobertson.id.au/projects/upthing---up-bank-api-toy-17

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

About UpThing

UpThing uses the Up Bank API to provide a web interface for displaying account information and managing Webhooks.

Account view

Basic account information, including transaction listing is available to view using UpThing.

Webhook actions

The main purpose of creating UpThing was to configure webhooks for sending transaction information to various locations, including to Google Sheets and creating Discord Notifications.

Getting Started

Setting Up(thing)

UpThing is a Laravel-based application. Please follow these instructions to get started.

Once that's done and you can see the login screen, grab your personal access token by following the instructions on Up's website here.

Create a new account on UpThing by using the register link up in the top corner and fill in the necessary details and you should be good to go!

Discord Integration

Create a new Discord webhook on a server you're an admin on:

  1. Open the Discord Server Settings, and go to Integrations
  2. Click Webhooks
  3. Click New Webhook
  4. Type in a name (this is what "user" the messages will come from)
  5. (Optional) Give the Bot an avatar
  6. Copy the Webhook URL
  7. Click Save

Create a new UpThing webhook:

  1. Navigate to Webhooks, Create Webhook
  2. Give it a name
  3. Select Discord Notification for the Action Type
  4. Paste the Discord Webhook URL into the 'Action URL'
  5. Click Create Webhook

Next time a transaction is settled, you should get a Discord Notification!

Google Sheets Integration

A potentially much more useful integration is with Google Sheets, however the setup is a bit more involved.

Firstly, you will need to set up a way for Google Sheets to receive the information from UpThing. This involves creating a script within the sheet (Tools -> Script Editor), and addding the following code:

function getNewRow(sheet) {
  let Avals = sheet.getRange("A1:A").getValues();
  let Alast = Avals.filter(String).length;
  let newRow = Alast + 1;
  return newRow;
}

function doPost(e) {
  let jsonData = JSON.parse(e.postData.contents)
  let transaction = {
    "date": new Date(jsonData.attributes.settledAt),
    "description": jsonData.attributes.description + " (" + jsonData.attributes.rawText + ")",
    "category": jsonData.relationships.category.data.id,
    "value": jsonData.attributes.amount.value
  };
  let ss = SpreadsheetApp.getActiveSpreadsheet();
  let txSheet = ss.getSheetByName("Transactions");
  
  let newRow = getNewRow(txSheet);
  
  txSheet.getRange(newRow, 1, 1, 4).setValues([ [ 
    transaction.date,
    transaction.description,
    transaction.category,
    transaction.value
  ]]);

  let JSONOutput = ContentService.createTextOutput(`{"success":true}`);
  JSONOutput.setMimeType(ContentService.MimeType.JSON);
  return JSONOutput;
}

Once this has been entered, publish the script as a Web App (with anonymous access). Google have some instructions on this process here.

Create a new webhook as a JSON POST, and use the URL of the Google Script.

License

UpThing is open-sourced software licensed under the MIT license.

About

WebUI and Webhook management interface for Up Bank

https://willrobertson.id.au/projects/upthing---up-bank-api-toy-17


Languages

Language:PHP 84.0%Language:Blade 11.9%Language:Less 2.2%Language:Dockerfile 1.1%Language:Shell 0.5%Language:Vue 0.4%