Skip to content

Commit

Permalink
Merge pull request #2 from wedevBr/fix/FixSettingsAndEndpointsCalls
Browse files Browse the repository at this point in the history
Fix/fix settings and endpoints calls
  • Loading branch information
adeildo-jr authored Jul 22, 2020
2 parents 4bff4b9 + b2e19ac commit 1ab27dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions config/config.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

return [
'api_url' => env('BANKLY_LOGIN_URL', 'https://api.acessobank.com.br/baas'), // Default value set to Production
'login_url' => env('BANKLY_API_URL', 'https://login.acessobank.com.br'), // Defaults value set to Production
'login_url' => env('BANKLY_LOGIN_URL', 'https://api.acessobank.com.br/baas'), // Default value set to Production
'api_url' => env('BANKLY_API_URL', 'https://login.acessobank.com.br/connect/token'), // Defaults value set to Production
'client_secret' => env('BANKLY_CLIENT_SECRET', null), // Your client secret provided by bankly staff
'client_id' => env('BANKLY_CLIENT_ID', null) // Your client ID provided by bankly staff
];
26 changes: 12 additions & 14 deletions src/Bankly.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ public function __construct($client_secret = null, $client_id = null)

public function setClientCredentials(array $credentials = null)
{
if (count($credentials) > 0) {
$this->client_secret = $credentials['client_secret'] ?? config('bankly')['client_secret'];
$this->client_id = $credentials['client_id'] ?? config('bankly')['client_id'];
}
$this->client_secret = $credentials['client_secret'] ?? config('bankly')['client_secret'];
$this->client_id = $credentials['client_id'] ?? config('bankly')['client_id'];
}

/**
Expand Down Expand Up @@ -69,12 +67,12 @@ public function getBalance(string $branch, string $account)
* @param $account
* @param int $offset
* @param int $limit
* @param bool $details
* @param bool $detailsLevelBasic
* @param string $details
* @param string $detailsLevelBasic
* @return array|mixed
* @throws RequestException
*/
public function getStatement($branch, $account, $offset = 1, $limit = 20, $details = true, $detailsLevelBasic = true) {
public function getStatement($branch, $account, $offset = 1, $limit = 20, $details = 'true', $detailsLevelBasic = 'true') {
return $this->get('/account/statement', array(
'branch' => $branch,
'account' => $account,
Expand All @@ -86,15 +84,15 @@ public function getStatement($branch, $account, $offset = 1, $limit = 20, $detai
}

/**
* @param $branch
* @param $account
* @param string $branch
* @param string $account
* @param int $page
* @param int $pagesize
* @param bool $include_details
* @param string $include_details
* @return array|mixed
* @throws RequestException
*/
public function getEvents(string $branch, string $account, int $page = 1, int $pagesize = 20, $include_details = true)
public function getEvents(string $branch, string $account, int $page = 1, int $pagesize = 20, $include_details = 'true')
{
return $this->get('/events',
[
Expand Down Expand Up @@ -156,12 +154,12 @@ public function getTransferStatus($branch, $account, $authentication_id) {
*/
private function get($endpoint, array $query = null, $correlation_id = null)
{
if (now()->unix() > $this->token_expiry) {
if (now()->unix() > $this->token_expiry || !$this->token) {
$this->auth();
}

if(is_null($correlation_id) && $this->requireCorrelationId($endpoint)) {
$correlation_id = Uuid::uuid4();
$correlation_id = Uuid::uuid4()->toString();
}

return Http::withToken($this->token)
Expand All @@ -182,7 +180,7 @@ private function get($endpoint, array $query = null, $correlation_id = null)
*/
private function post($endpoint, array $body = null, $correlation_id = null, $asJson = false)
{
if (now()->unix() > $this->token_expiry) {
if (now()->unix() > $this->token_expiry || !$this->token) {
$this->auth();
}

Expand Down

0 comments on commit 1ab27dd

Please sign in to comment.