Skip to content

Commit e4989ca

Browse files
committed
#1175984683988670 Add more logs
1 parent c4f35fb commit e4989ca

2 files changed

Lines changed: 22 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# CHANGELOG
2+
## 0.1.24
3+
- Adding logs in json mapping, so we can figure out if something is wrong with data.
4+
25
## 0.1.23
36
- Added form_params support.
47
- Update circle ci config to test with laravel 6.

src/ApiBuilder.php

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,17 @@ public function __call($name, $arguments)
139139
case 'POST':
140140
case 'PUT':
141141
// JSON or Form_params mappings
142-
143-
if($requestType == 'form_data'){
142+
143+
if ($requestType == 'form_data') {
144144

145145
$json = $this->processFormParamsMappings($arguments, $api);
146146

147-
$object = $this->call($method,$uri,['form_params' => $json]);
148-
}
149-
else {
147+
$object = $this->call($method, $uri, ['form_params' => $json]);
148+
} else {
150149

151-
$json = $this->processJsonMappings($arguments, $api);
152-
// Call the API
153-
$object = $this->call($method, $uri, ['json' => $json]);
150+
$json = $this->processJsonMappings($arguments, $api);
151+
// Call the API
152+
$object = $this->call($method, $uri, ['json' => $json]);
154153
}
155154

156155
break;
@@ -160,7 +159,7 @@ public function __call($name, $arguments)
160159
// Call the API
161160
$object = $this->call($method, $uri);
162161
}
163-
162+
164163
// check for success
165164
if ($object->success == true) {
166165
// Decode JSON body
@@ -186,7 +185,7 @@ public function __call($name, $arguments)
186185

187186
}
188187

189-
break;
188+
break;
190189
case 'xml':
191190

192191
switch ($method) {
@@ -506,7 +505,15 @@ protected function processJsonMappings($arguments, $api): array
506505
$json = str_ireplace('{' . $key . '}', array_get($arguments[0], $value, null), $json);
507506
}
508507
}
509-
return json_decode($json, true);
508+
$mapping = json_decode($json, true);
509+
if ($mapping == null) {
510+
Log::error("ApiBuilder->processJsonMappings() - Error while decoding string", [
511+
'json' => $json,
512+
'arguments' => $arguments,
513+
'api' => $api,
514+
]);
515+
}
516+
return $mapping;
510517
}
511518

512519
/**
@@ -545,7 +552,7 @@ protected function processFormParamsMappings($arguments, $api): array
545552
$json = str_ireplace('{' . $key . '}', array_get($arguments[0], $value, null), $json);
546553
}
547554
}
548-
return json_decode($json,true);
555+
return json_decode($json, true);
549556
}
550557

551558
/**

0 commit comments

Comments
 (0)