Skip to content

Commit

Permalink
edit data request json
Browse files Browse the repository at this point in the history
  • Loading branch information
turahe committed Apr 29, 2019
1 parent f7e7b4c commit 46173d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -623,15 +623,10 @@ public function getResponse()
*
* @return bool|\O2System\Curl\Response
*/
public function post(array $fields = [], $format = 'QUERY')
public function post(array $fields = [])
{
$this->curlOptions[ CURLOPT_POST ] = true;

if ($format === 'QUERY') {
$this->curlOptions[ CURLOPT_POSTFIELDS ] = http_build_query($fields, null, '&', PHP_QUERY_RFC3986);
} elseif ($format === 'JSON') {
$this->curlOptions[ CURLOPT_POSTFIELDS ] = json_encode($fields);
}
$this->curlOptions[ CURLOPT_POSTFIELDS ] = http_build_query($fields, null, '&', PHP_QUERY_RFC3986);

return $this->getResponse();
}
Expand Down
7 changes: 7 additions & 0 deletions src/Response/SimpleJSONElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ class SimpleJSONElement extends SplArrayObject
*/
public function __construct(array $elements = [])
{
foreach ($elements as $key => $value) {
if (strpos($key, '_') !== false) {
$elements[ camelcase($key) ] = $value;
unset($elements[ $key ]);
}
}

parent::__construct($elements);
}
}

0 comments on commit 46173d5

Please sign in to comment.