1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 00:11:35 +02:00

Refresh accounts

This commit is contained in:
David Bomba 2022-08-11 12:39:43 +10:00
parent 5a2a2cce4a
commit f7eb506e0d
6 changed files with 59 additions and 24 deletions

View File

@ -70,6 +70,9 @@ class AccountTransformer implements AccountTransformerInterface
$data = [];
if(!property_exists($yodlee_account, 'account'))
return [];
foreach($yodlee_account->account as $account)
{
$data[] = $this->transformAccount($account);

View File

@ -119,6 +119,9 @@ class IncomeTransformer implements BankRevenueInterface
$data = [];
if(!property_exists($transaction, 'transaction'))
return [];
foreach($transaction->transaction as $transaction)
{
$data[] = $this->transformTransaction($transaction);

View File

@ -11,6 +11,7 @@
namespace App\Helpers\Bank\Yodlee;
use App\Exceptions\YodleeApiException;
use App\Helpers\Bank\Yodlee\Transformer\AccountTransformer;
use App\Helpers\Bank\Yodlee\Transformer\IncomeTransformer;
use Illuminate\Support\Facades\Http;
@ -83,8 +84,7 @@ class Yodlee
$user = $this->bank_account_id ?: $this->admin_name;
$response = $this->bankFormRequest('/auth/token', 'post', [], ['loginName' => $user]);
//catch failures here
nlog($response);
return $response->token->accessToken;
}
@ -135,10 +135,7 @@ class Yodlee
return $response->object();
if($response->failed())
return $response->body();
return $response;
throw new YodleeApiException($response->body());
}
@ -152,15 +149,13 @@ class Yodlee
if($response->successful()){
$at = new AccountTransformer();
nlog($response->object());
return $at->transform($response->object());
}
if($response->failed())
return $response->body();
return $response;
throw new YodleeApiException($response->body());
}
@ -178,7 +173,7 @@ class Yodlee
}
if($response->failed())
return $response->body();
throw new YodleeApiException($response->body());
}
@ -192,7 +187,7 @@ class Yodlee
return $response->object();
if($response->failed())
return $response->body();
throw new YodleeApiException($response->body());
}
@ -205,7 +200,7 @@ class Yodlee
return $response->object();
if($response->failed())
return $response->body();
throw new YodleeApiException($response->body());
}

View File

@ -0,0 +1,39 @@
<?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\Http\Requests\Yodlee;
use App\Http\Requests\Request;
class YodleeAdminRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return auth()->user()->isAdmin();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [];
}
}

View File

@ -21,8 +21,8 @@ return new class extends Migration
$table->unsignedInteger('user_id');
$table->text('provider_bank_name'); //providerName ie Chase
$table->bigUnsignedInteger('provider_id'); //id of the bank
$table->bigUnsignedInteger('bank_account_id'); //id
$table->bigInteger('provider_id'); //id of the bank
$table->bigInteger('bank_account_id'); //id
$table->text('bank_account_name')->nullable(); //accountName
$table->text('bank_account_number')->nullable(); //accountNumber
$table->text('bank_account_status')->nullable(); //accountStatus

View File

@ -69,14 +69,10 @@ class YodleeApiTest extends TestCase
$this->assertTrue($hit);
$transaction->contains(function ($value, $key) {
return str_contains($value->description, 'tinker');
});
$invoice = $transaction->first(function ($value, $key) {
return str_contains($value->number, 'tinker');
return str_contains($value->description, 'tinker');
});
@ -102,7 +98,7 @@ class YodleeApiTest extends TestCase
$yodlee = new Yodlee('sbMem62e1e69547bfb1');
$yodlee->setTestMode();
$access_token = $yodlee->getAccessToken(true);
$access_token = $yodlee->getAccessToken();
$this->assertNotNull($access_token);
}
@ -405,7 +401,7 @@ class YodleeApiTest extends TestCase
$yodlee->setTestMode();
$accounts = $yodlee->getAccounts();
nlog($accounts);
$this->assertIsArray($accounts);
}
@ -465,7 +461,6 @@ class YodleeApiTest extends TestCase
$transactions = $yodlee->getTransactions(['categoryId' => 2, 'fromDate' => '2000-01-01']);
$this->assertIsArray($transactions);
//nlog($transactions);
}