Skip to content

Commit

Permalink
Merge pull request #2 from TechTailor/analysis-Vr4YbD
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
Moinuddin S. Khaja authored Nov 27, 2021
2 parents 7a4159a + 527aaa1 commit 95abf4d
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 115 deletions.
6 changes: 3 additions & 3 deletions config/wazirx-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

'auth' => [
'key' => env('WAZIRX_KEY', ''),
'secret' => env('WAZIRX_SECRET', '')
'secret' => env('WAZIRX_SECRET', ''),
],

/*
Expand All @@ -26,7 +26,7 @@
*/

'urls' => [
'api' => 'https://api.wazirx.com',
'api' => 'https://api.wazirx.com',
'sapi' => 'https://api.wazirx.com/sapi/',
],

Expand All @@ -40,7 +40,7 @@
*/

'settings' => [
'timing' => env('WAZIRX_TIMING', 5000)
'timing' => env('WAZIRX_TIMING', 5000),
],

];
62 changes: 28 additions & 34 deletions src/Traits/HandlesResponseErrors.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,63 +8,57 @@ private function handleError($response)
{
// Set a default error.
$error = [
"code" => "1000",
"error" => "Invalid",
"message" => "Unable to identify the type of error."
'code' => '1000',
'error' => 'Invalid',
'message' => 'Unable to identify the type of error.',
];

// Return server related errors (500 range).
if($response->serverError())
{
if ($response->serverError()) {
// TBA
}
// Return client related errors.
elseif($response->clientError())
{
elseif ($response->clientError()) {
// If client error has a response code.
if(isset($response['code']))
{
if (isset($response['code'])) {
// Switch between known Wazirx error codes.
switch($response['code'])
{
case('1999') :
switch ($response['code']) {
case '1999':
$error = [
"code" => "1999",
"error" => "Api Error",
"message" => "Symbol does not have a valid value."
'code' => '1999',
'error' => 'Api Error',
'message' => 'Symbol does not have a valid value.',
];
break;
case('2000') :
case '2000':
$error = [
"code" => "2000",
"error" => "Api Connection Error",
"message" => "Something went wrong. Please contact support."
'code' => '2000',
'error' => 'Api Connection Error',
'message' => 'Something went wrong. Please contact support.',
];
break;
case('2005') :
case '2005':
$error = [
"code" => "2005",
"error" => "Api Connection Error",
"message" => "API Signature/Secret is Invalid."
'code' => '2005',
'error' => 'Api Connection Error',
'message' => 'API Signature/Secret is Invalid.',
];
break;
case('2112') :
case '2112':
$error = [
"code" => "2112",
"error" => "Api Connection Error",
"message" => "API Key is missing / Invalid API Key."
'code' => '2112',
'error' => 'Api Connection Error',
'message' => 'API Key is missing / Invalid API Key.',
];
break;
}
}
else {
} else {
// If client error a response status.
if($response->status() === 403)
{
if ($response->status() === 403) {
$error = [
"code" => "403",
"error" => "Forbidden",
"message" => "You don't have permission to access this resouce."
'code' => '403',
'error' => 'Forbidden',
'message' => "You don't have permission to access this resouce.",
];
}
}
Expand Down
Loading

0 comments on commit 95abf4d

Please sign in to comment.