Skip to content

Commit

Permalink
Merge pull request #23 from achmadhadikurnia/main
Browse files Browse the repository at this point in the history
refactor: config file
achmadhadikurnia authored Feb 25, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 95c43dd + 34528fd commit 158af10
Showing 5 changed files with 14 additions and 14 deletions.
18 changes: 9 additions & 9 deletions config/siasn-api.php
Original file line number Diff line number Diff line change
@@ -4,10 +4,6 @@

'mode' => env('SIASN_MODE', 'training'),

'http_verify' => (bool) env('SIASN_HTTP_VERIFY', true),

'debug' => (bool) env('SIASN_DEBUG', env('APP_DEBUG')),

'apim' => [
'production' => [
'url' => 'https://apimws.bkn.go.id/oauth2/token',
@@ -48,14 +44,18 @@
],

'token_age' => [
'apim' => env('SIASN_APIM_TOKEN_AGE', 3600 - 60),
'sso' => env('SIASN_SSO_TOKEN_AGE', 43200 - 60),
'apim' => (int) env('SIASN_APIM_TOKEN_AGE', 3600 - 60),
'sso' => (int) env('SIASN_SSO_TOKEN_AGE', 43200 - 60),
],

'max_request_attempts' => env('SIASN_REQUEST_ATTEMPTS', 3),
'debug' => (bool) env('SIASN_DEBUG', env('APP_DEBUG')),

'enable_ssl_verification' => (bool) env('SIASN_ENABLE_SSL_VERIFICATION', true),

'max_request_attempts' => (int) env('SIASN_REQUEST_ATTEMPTS', 3),

'max_request_wait_attempts' => env('SIASN_REQUEST_WAIT_ATTEMPTS', 3),
'max_request_wait_attempts' => (int) env('SIASN_REQUEST_WAIT_ATTEMPTS', 30),

'request_timeout' => env('SIASN_REQUEST_TIMEOUT', 60),
'request_timeout' => (int) env('SIASN_REQUEST_TIMEOUT', 60),

];
2 changes: 1 addition & 1 deletion src/Credentials/Apim.php
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ public static function getToken(): Response
->retry(config('siasn-api.max_request_attempts'), config('siasn-api.max_request_wait_attempts'))
->withOptions([
'debug' => Config::getDebug(),
'verify' => Config::getHttpVerify(),
'verify' => Config::getEnableSslVerification(),
])->withBasicAuth(
$credential->username,
$credential->password
2 changes: 1 addition & 1 deletion src/Credentials/Sso.php
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ public static function getToken(): Response
->retry(config('siasn-api.max_request_attempts'), config('siasn-api.max_request_wait_attempts'))
->withOptions([
'debug' => Config::getDebug(),
'verify' => Config::getHttpVerify(),
'verify' => Config::getEnableSslVerification(),
])
->post($credential->url, [
'grant_type' => $credential->grant_type,
4 changes: 2 additions & 2 deletions src/Helpers/Config.php
Original file line number Diff line number Diff line change
@@ -39,9 +39,9 @@ public static function getDebug(): bool
/**
* Get http verify.
*/
public static function getHttpVerify(): bool
public static function getEnableSslVerification(): bool
{
return config('siasn-api.http_verify');
return config('siasn-api.enable_ssl_verification');
}

/**
2 changes: 1 addition & 1 deletion src/Siasn.php
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ public function __construct()
})
->withOptions([
'debug' => Config::getDebug(),
'verify' => Config::getHttpVerify(),
'verify' => Config::getEnableSslVerification(),
])
->withToken(Token::getApimToken()->access_token);
}

0 comments on commit 158af10

Please sign in to comment.