mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-04 02:04:35 -04:00
Income / Expense TransformeR
This commit is contained in:
parent
d1530c4477
commit
6dd9f7302d
80
app/Helpers/Bank/Yodlee/Transformer/ExpenseTransformer.php
Normal file
80
app/Helpers/Bank/Yodlee/Transformer/ExpenseTransformer.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Helpers\Bank\Yodlee\Transformer;
|
||||
|
||||
/**
|
||||
"date": "string",
|
||||
"sourceId": "string",
|
||||
"symbol": "string",
|
||||
"cusipNumber": "string",
|
||||
"highLevelCategoryId": 0,
|
||||
"detailCategoryId": 0,
|
||||
"description": {},
|
||||
"memo": "string",
|
||||
"settleDate": "string",
|
||||
"type": "string",
|
||||
"intermediary": [],
|
||||
"baseType": "CREDIT",
|
||||
"categorySource": "SYSTEM",
|
||||
"principal": {},
|
||||
"lastUpdated": "string",
|
||||
"interest": {},
|
||||
"price": {},
|
||||
"commission": {},
|
||||
"id": 0,
|
||||
"merchantType": "string",
|
||||
"amount": {
|
||||
"amount": 0,
|
||||
"convertedAmount": 0,
|
||||
"currency": "USD",
|
||||
"convertedCurrency": "USD"
|
||||
},
|
||||
"checkNumber": "string",
|
||||
"isPhysical": true,
|
||||
"quantity": 0,
|
||||
"valoren": "string",
|
||||
"isManual": true,
|
||||
"merchant": {
|
||||
"website": "string",
|
||||
"address": {},
|
||||
"contact": {},
|
||||
"categoryLabel": [],
|
||||
"coordinates": {},
|
||||
"name": "string",
|
||||
"id": "string",
|
||||
"source": "YODLEE",
|
||||
"logoURL": "string"
|
||||
},
|
||||
"sedol": "string",
|
||||
"transactionDate": "string",
|
||||
"categoryType": "TRANSFER",
|
||||
"accountId": 0,
|
||||
"createdDate": "string",
|
||||
"sourceType": "AGGREGATED",
|
||||
"CONTAINER": "bank",
|
||||
"postDate": "string",
|
||||
"parentCategoryId": 0,
|
||||
"subType": "OVERDRAFT_CHARGE",
|
||||
"category": "string",
|
||||
"runningBalance": {},
|
||||
"categoryId": 0,
|
||||
"holdingDescription": "string",
|
||||
"isin": "string",
|
||||
"status": "POSTED"
|
||||
*/
|
||||
|
||||
class ExpenseTransformer
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
80
app/Helpers/Bank/Yodlee/Transformer/IncomeTransformer.php
Normal file
80
app/Helpers/Bank/Yodlee/Transformer/IncomeTransformer.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
|
||||
namespace App\Helpers\Bank\Yodlee\Transformer;
|
||||
|
||||
/**
|
||||
"date": "string",
|
||||
"sourceId": "string",
|
||||
"symbol": "string",
|
||||
"cusipNumber": "string",
|
||||
"highLevelCategoryId": 0,
|
||||
"detailCategoryId": 0,
|
||||
"description": {},
|
||||
"memo": "string",
|
||||
"settleDate": "string",
|
||||
"type": "string",
|
||||
"intermediary": [],
|
||||
"baseType": "CREDIT",
|
||||
"categorySource": "SYSTEM",
|
||||
"principal": {},
|
||||
"lastUpdated": "string",
|
||||
"interest": {},
|
||||
"price": {},
|
||||
"commission": {},
|
||||
"id": 0,
|
||||
"merchantType": "string",
|
||||
"amount": {
|
||||
"amount": 0,
|
||||
"convertedAmount": 0,
|
||||
"currency": "USD",
|
||||
"convertedCurrency": "USD"
|
||||
},
|
||||
"checkNumber": "string",
|
||||
"isPhysical": true,
|
||||
"quantity": 0,
|
||||
"valoren": "string",
|
||||
"isManual": true,
|
||||
"merchant": {
|
||||
"website": "string",
|
||||
"address": {},
|
||||
"contact": {},
|
||||
"categoryLabel": [],
|
||||
"coordinates": {},
|
||||
"name": "string",
|
||||
"id": "string",
|
||||
"source": "YODLEE",
|
||||
"logoURL": "string"
|
||||
},
|
||||
"sedol": "string",
|
||||
"transactionDate": "string",
|
||||
"categoryType": "TRANSFER",
|
||||
"accountId": 0,
|
||||
"createdDate": "string",
|
||||
"sourceType": "AGGREGATED",
|
||||
"CONTAINER": "bank",
|
||||
"postDate": "string",
|
||||
"parentCategoryId": 0,
|
||||
"subType": "OVERDRAFT_CHARGE",
|
||||
"category": "string",
|
||||
"runningBalance": {},
|
||||
"categoryId": 0,
|
||||
"holdingDescription": "string",
|
||||
"isin": "string",
|
||||
"status": "POSTED"
|
||||
*/
|
||||
|
||||
class IncomeTransformer
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ class Yodlee
|
||||
|
||||
public bool $test_mode;
|
||||
|
||||
private string $api_endpoint = '';
|
||||
private string $api_endpoint = 'https://production.api.yodlee.com/ysl';
|
||||
|
||||
private string $test_api_endpoint = 'https://sandbox.api.yodlee.com/ysl';
|
||||
|
||||
@ -69,21 +69,26 @@ class Yodlee
|
||||
|
||||
}
|
||||
|
||||
public function getAccounts($token)
|
||||
public function getAccounts($token, $params = [])
|
||||
{
|
||||
|
||||
$response = $this->bankRequest('/accounts', 'get', [], ["Authorization" => "Bearer {$token}"]);
|
||||
$response = Http::withHeaders($this->getHeaders(["Authorization" => "Bearer {$token}"]))->get($this->api_endpoint. "/accounts", $params);
|
||||
|
||||
if($response->successful())
|
||||
return $response->object();
|
||||
|
||||
if($response->failed())
|
||||
return $response->body();
|
||||
|
||||
|
||||
return $response;
|
||||
|
||||
}
|
||||
|
||||
public function getTransactions($token)
|
||||
public function getTransactions($token, $params = [])
|
||||
{
|
||||
|
||||
$response = Http::withHeaders($this->getHeaders(["Authorization" => "Bearer {$token}"]))->get($this->api_endpoint. "/transactions", ['categoryType' => 'EXPENSE']);
|
||||
// $response = Http::withHeaders($this->getHeaders(["Authorization" => "Bearer {$token}"]))->get($this->api_endpoint. "/transactions");
|
||||
|
||||
$response = Http::withHeaders($this->getHeaders(["Authorization" => "Bearer {$token}"]))->get($this->api_endpoint. "/transactions", $params);
|
||||
|
||||
if($response->successful())
|
||||
return $response->object();
|
||||
@ -93,12 +98,16 @@ class Yodlee
|
||||
|
||||
}
|
||||
|
||||
public function getTransactionCategories($token)
|
||||
public function getTransactionCategories($token, $params = [])
|
||||
{
|
||||
|
||||
$response = $this->bankRequest('/transactions/categories', 'get', [], ["Authorization" => "Bearer {$token}"]);
|
||||
$response = Http::withHeaders($this->getHeaders(["Authorization" => "Bearer {$token}"]))->get($this->api_endpoint. "/transactions/categories", $params);
|
||||
|
||||
return $response;
|
||||
if($response->successful())
|
||||
return $response->object();
|
||||
|
||||
if($response->failed())
|
||||
return $response->body();
|
||||
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ class YodleeApiTest extends TestCase
|
||||
|
||||
$yodlee = new Yodlee(true);
|
||||
|
||||
$access_token = $yodlee->getAccessToken('sbMem62e1e69547bfb1');
|
||||
$access_token = $yodlee->getAccessToken('sbMem62e1e69547bfb2');
|
||||
|
||||
$transactions = $yodlee->getTransactionCategories($access_token);
|
||||
|
||||
@ -394,9 +394,11 @@ class YodleeApiTest extends TestCase
|
||||
|
||||
$yodlee = new Yodlee(true);
|
||||
|
||||
$access_token = $yodlee->getAccessToken('sbMem62e1e69547bfb3');
|
||||
$access_token = $yodlee->getAccessToken('sbMem62e1e69547bfb1');
|
||||
|
||||
$transactions = $yodlee->getTransactions($access_token);
|
||||
nlog($access_token);
|
||||
|
||||
$transactions = $yodlee->getTransactions($access_token, ['categoryId' => 2, 'fromDate' => '2000-01-01']);
|
||||
|
||||
nlog($transactions);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user