mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Transform accounts
This commit is contained in:
parent
dc176aa3f8
commit
b7fbfe6531
@ -12,10 +12,8 @@
|
|||||||
namespace App\Helpers\Bank\Yodlee\Transformer;
|
namespace App\Helpers\Bank\Yodlee\Transformer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
[account] => Array
|
[0] => stdClass Object
|
||||||
(
|
(
|
||||||
[0] => stdClass Object
|
|
||||||
(
|
|
||||||
[CONTAINER] => bank
|
[CONTAINER] => bank
|
||||||
[providerAccountId] => 11308693
|
[providerAccountId] => 11308693
|
||||||
[accountName] => My CD - 8878
|
[accountName] => My CD - 8878
|
||||||
@ -57,16 +55,36 @@ namespace App\Helpers\Bank\Yodlee\Transformer;
|
|||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class AccountTransformer
|
class AccountTransformer
|
||||||
{
|
{
|
||||||
|
|
||||||
public static function transform(array $account)
|
public function transform($yodlee_account){
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
|
||||||
|
foreach($yodlee_account->account as $account)
|
||||||
{
|
{
|
||||||
|
$data[] = $this->transformAccount($account);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function transformAccount($account)
|
||||||
|
{
|
||||||
|
nlog($account);
|
||||||
return [
|
return [
|
||||||
|
'id' => $account->id,
|
||||||
|
'account_type' => $account->CONTAINER,
|
||||||
|
'account_name' => $account->accountName,
|
||||||
|
'account_status' => $account->accountStatus,
|
||||||
|
'account_number' => $account->accountNumber,
|
||||||
|
'current_balance' => property_exists($account, 'currentBalance') ? $account->currentBalance->amount : 0,
|
||||||
|
'account_currency' => property_exists($account, 'currency') ? $account->currentBalance->currency : '',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Helpers\Bank\Yodlee;
|
namespace App\Helpers\Bank\Yodlee;
|
||||||
|
|
||||||
|
use App\Helpers\Bank\Yodlee\Transformer\AccountTransformer;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
class Yodlee
|
class Yodlee
|
||||||
@ -137,8 +138,13 @@ class Yodlee
|
|||||||
|
|
||||||
$response = Http::withHeaders($this->getHeaders(["Authorization" => "Bearer {$token}"]))->get($this->getEndpoint(). "/accounts", $params);
|
$response = Http::withHeaders($this->getHeaders(["Authorization" => "Bearer {$token}"]))->get($this->getEndpoint(). "/accounts", $params);
|
||||||
|
|
||||||
if($response->successful())
|
|
||||||
return $response->object();
|
if($response->successful()){
|
||||||
|
|
||||||
|
$at = new AccountTransformer();
|
||||||
|
return $at->transform($response->object());
|
||||||
|
// return $response->object();
|
||||||
|
}
|
||||||
|
|
||||||
if($response->failed())
|
if($response->failed())
|
||||||
return $response->body();
|
return $response->body();
|
||||||
|
@ -350,7 +350,9 @@ class YodleeApiTest extends TestCase
|
|||||||
|
|
||||||
$accounts = $yodlee->getAccounts();
|
$accounts = $yodlee->getAccounts();
|
||||||
|
|
||||||
$this->assertIsArray($accounts->account);
|
nlog($accounts);
|
||||||
|
|
||||||
|
$this->assertIsArray($accounts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user