Skip to content

Commit 67d7573

Browse files
committed
Merge branch 'hotfix/0.10.1'
* hotfix/0.10.1: Add boolean value transformations before send request
2 parents a95471e + 6c65bff commit 67d7573

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "inakiabt/etsy-php",
3-
"version": "0.10.0",
3+
"version": "0.10.1",
44
"description": "Simple PHP wrapper for Etsy API",
55
"license": "MIT",
66
"authors": [

src/Etsy/EtsyApi.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ private function request($arguments)
3737
$method = $this->methods[$arguments['method']];
3838
$args = $arguments['args'];
3939
$params = $this->prepareParameters($args['params']);
40+
$data = @$this->prepareData($args['data']);
4041

4142
$uri = preg_replace_callback('@:(.+?)(\/|$)@', function($matches) use ($args) {
4243
return $args["params"][$matches[1]].$matches[2];
@@ -56,7 +57,7 @@ private function request($arguments)
5657
$uri .= "?" . http_build_query($params);
5758
}
5859

59-
return $this->validateResponse( $args, $this->client->request($uri, @$args['data'], $method['http_method'], $this->returnJson) );
60+
return $this->validateResponse( $args, $this->client->request($uri, $data, $method['http_method'], $this->returnJson) );
6061
}
6162

6263
protected function validateResponse($request_args, $response)
@@ -92,6 +93,21 @@ protected function validateResponse($request_args, $response)
9293
return $response;
9394
}
9495

96+
private function prepareData($data) {
97+
$result = array();
98+
foreach ($data as $key => $value) {
99+
$type = gettype($value);
100+
if ($type !== 'boolean') {
101+
$result[$key] = $value;
102+
continue;
103+
}
104+
105+
$result[$key] = $value ? 1 : 0;
106+
}
107+
108+
return $result;
109+
}
110+
95111
private function prepareParameters($params) {
96112
$query_pairs = array();
97113
$allowed = array("limit", "offset", "page", "sort_on", "sort_order", "include_private", "language");

0 commit comments

Comments
 (0)