mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Refresh accounts
This commit is contained in:
parent
5a2a2cce4a
commit
f7eb506e0d
@ -70,6 +70,9 @@ class AccountTransformer implements AccountTransformerInterface
|
|||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
|
if(!property_exists($yodlee_account, 'account'))
|
||||||
|
return [];
|
||||||
|
|
||||||
foreach($yodlee_account->account as $account)
|
foreach($yodlee_account->account as $account)
|
||||||
{
|
{
|
||||||
$data[] = $this->transformAccount($account);
|
$data[] = $this->transformAccount($account);
|
||||||
|
@ -119,6 +119,9 @@ class IncomeTransformer implements BankRevenueInterface
|
|||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
|
if(!property_exists($transaction, 'transaction'))
|
||||||
|
return [];
|
||||||
|
|
||||||
foreach($transaction->transaction as $transaction)
|
foreach($transaction->transaction as $transaction)
|
||||||
{
|
{
|
||||||
$data[] = $this->transformTransaction($transaction);
|
$data[] = $this->transformTransaction($transaction);
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Helpers\Bank\Yodlee;
|
namespace App\Helpers\Bank\Yodlee;
|
||||||
|
|
||||||
|
use App\Exceptions\YodleeApiException;
|
||||||
use App\Helpers\Bank\Yodlee\Transformer\AccountTransformer;
|
use App\Helpers\Bank\Yodlee\Transformer\AccountTransformer;
|
||||||
use App\Helpers\Bank\Yodlee\Transformer\IncomeTransformer;
|
use App\Helpers\Bank\Yodlee\Transformer\IncomeTransformer;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
@ -83,8 +84,7 @@ class Yodlee
|
|||||||
$user = $this->bank_account_id ?: $this->admin_name;
|
$user = $this->bank_account_id ?: $this->admin_name;
|
||||||
|
|
||||||
$response = $this->bankFormRequest('/auth/token', 'post', [], ['loginName' => $user]);
|
$response = $this->bankFormRequest('/auth/token', 'post', [], ['loginName' => $user]);
|
||||||
//catch failures here
|
|
||||||
nlog($response);
|
|
||||||
return $response->token->accessToken;
|
return $response->token->accessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,10 +135,7 @@ class Yodlee
|
|||||||
return $response->object();
|
return $response->object();
|
||||||
|
|
||||||
if($response->failed())
|
if($response->failed())
|
||||||
return $response->body();
|
throw new YodleeApiException($response->body());
|
||||||
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,15 +149,13 @@ class Yodlee
|
|||||||
if($response->successful()){
|
if($response->successful()){
|
||||||
|
|
||||||
$at = new AccountTransformer();
|
$at = new AccountTransformer();
|
||||||
nlog($response->object());
|
|
||||||
return $at->transform($response->object());
|
return $at->transform($response->object());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($response->failed())
|
if($response->failed())
|
||||||
return $response->body();
|
throw new YodleeApiException($response->body());
|
||||||
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +173,7 @@ class Yodlee
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($response->failed())
|
if($response->failed())
|
||||||
return $response->body();
|
throw new YodleeApiException($response->body());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +187,7 @@ class Yodlee
|
|||||||
return $response->object();
|
return $response->object();
|
||||||
|
|
||||||
if($response->failed())
|
if($response->failed())
|
||||||
return $response->body();
|
throw new YodleeApiException($response->body());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +200,7 @@ class Yodlee
|
|||||||
return $response->object();
|
return $response->object();
|
||||||
|
|
||||||
if($response->failed())
|
if($response->failed())
|
||||||
return $response->body();
|
throw new YodleeApiException($response->body());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
39
app/Http/Requests/Yodlee/YodleeAdminRequest.php
Normal file
39
app/Http/Requests/Yodlee/YodleeAdminRequest.php
Normal 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 [];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -21,8 +21,8 @@ return new class extends Migration
|
|||||||
$table->unsignedInteger('user_id');
|
$table->unsignedInteger('user_id');
|
||||||
|
|
||||||
$table->text('provider_bank_name'); //providerName ie Chase
|
$table->text('provider_bank_name'); //providerName ie Chase
|
||||||
$table->bigUnsignedInteger('provider_id'); //id of the bank
|
$table->bigInteger('provider_id'); //id of the bank
|
||||||
$table->bigUnsignedInteger('bank_account_id'); //id
|
$table->bigInteger('bank_account_id'); //id
|
||||||
$table->text('bank_account_name')->nullable(); //accountName
|
$table->text('bank_account_name')->nullable(); //accountName
|
||||||
$table->text('bank_account_number')->nullable(); //accountNumber
|
$table->text('bank_account_number')->nullable(); //accountNumber
|
||||||
$table->text('bank_account_status')->nullable(); //accountStatus
|
$table->text('bank_account_status')->nullable(); //accountStatus
|
||||||
|
@ -69,14 +69,10 @@ class YodleeApiTest extends TestCase
|
|||||||
|
|
||||||
$this->assertTrue($hit);
|
$this->assertTrue($hit);
|
||||||
|
|
||||||
$transaction->contains(function ($value, $key) {
|
|
||||||
return str_contains($value->description, 'tinker');
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
$invoice = $transaction->first(function ($value, $key) {
|
$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 = new Yodlee('sbMem62e1e69547bfb1');
|
||||||
$yodlee->setTestMode();
|
$yodlee->setTestMode();
|
||||||
|
|
||||||
$access_token = $yodlee->getAccessToken(true);
|
$access_token = $yodlee->getAccessToken();
|
||||||
|
|
||||||
$this->assertNotNull($access_token);
|
$this->assertNotNull($access_token);
|
||||||
}
|
}
|
||||||
@ -405,7 +401,7 @@ class YodleeApiTest extends TestCase
|
|||||||
$yodlee->setTestMode();
|
$yodlee->setTestMode();
|
||||||
|
|
||||||
$accounts = $yodlee->getAccounts();
|
$accounts = $yodlee->getAccounts();
|
||||||
|
nlog($accounts);
|
||||||
$this->assertIsArray($accounts);
|
$this->assertIsArray($accounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,7 +461,6 @@ class YodleeApiTest extends TestCase
|
|||||||
$transactions = $yodlee->getTransactions(['categoryId' => 2, 'fromDate' => '2000-01-01']);
|
$transactions = $yodlee->getTransactions(['categoryId' => 2, 'fromDate' => '2000-01-01']);
|
||||||
|
|
||||||
$this->assertIsArray($transactions);
|
$this->assertIsArray($transactions);
|
||||||
//nlog($transactions);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user