2017 © Pedro Peláez
 

library php-ynab4

API to read and write transactions to a YNAB4 json database.

image

petrica/php-ynab4

API to read and write transactions to a YNAB4 json database.

  • Tuesday, June 13, 2017
  • by petrica
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PHP YNAB4 Database

Read and write transactions from and to a YNAB4 JSON database., (*1)

Prerequisites

  • PHP 5.4+
  • composer

Quick start

Clone repository to disk, (*2)

git clone git@github.com:petrica/php-ynab4.git

Run composer install in order to create necessary libraries, (*3)

cd php-ynab4
composer install

Play with the sample application, (*4)

cd sample
php index.php

Read transactions

# dropbox driver
$io = new YnabDropboxIO(new Client($auth['access_token'], "MTools"));
# or
# disk driver if you want to access directly on disk the budget database
$io = new YnabDiskIO();

# path to budget folder
$pathToBudget = '/app/ynab/Test~B5C2AEE7.ynab4';
# device id as UUID Version 1, if not provided a new device will be generated
$deviceId = null;
$ynab = new YnabClient($pathToBudget, $io, $deviceId);

# fetch transactions from diff files
$ynab->pull();

# get latest transactions
$transactions = $ynab->getTransactions();

# update device knowledge based on read transactions
$ynab->commit();

# store device id for future calls
$deviceId = $ynab->getDevice()->getDeviceGUID();

Write transactions

# dropbox driver
$io = new YnabDropboxIO(new Client($auth['access_token'], "MTools"));
# or
# disk driver if you want to access directly on disk the budget database
$io = new YnabDiskIO();

# path to budget folder
$pathToBudget = '/app/ynab/Test~B5C2AEE7.ynab4';
# device id as UUID Version 1, if not provided a new device will be generated
$deviceId = null;
$ynab = new YnabClient($pathToBudget, $io, $deviceId);

$transaction = new YnabTransaction();
$transaction->setAccountId('UUID_ACCOUNT_TO_PUSH_TRANSACTION_TO');
$transaction->setAmount('-10.5');
$transaction->setMemo('Some memo');
$transaction->setDate(new \DateTime());

$ynab->setTransactions([
    $transaction
]);

# Create diff file for other devices to read the new transaction
$ynab->push();

# Update device knowledge based on new generated diff file
$ynab->commit();

The Versions

13/06 2017

dev-master

9999999-dev https://github.com/petrica/php-ynab4

API to read and write transactions to a YNAB4 json database.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Petrica Martinescu

api transactions ynab4 budget