Skip to content

Commit a6c0731

Browse files
committed
fixing encoding issues
1 parent 3420b5c commit a6c0731

File tree

2 files changed

+6
-32
lines changed

2 files changed

+6
-32
lines changed

src/AbstractClient.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ protected function _buildGuzzleRequestOptions(Request $r): array
7878
// todo: per-request content and accept value setting.
7979
$body = $r->getBody();
8080
if (null !== $body) {
81-
$opts[GuzzleRequestOptions::JSON] = $body;
81+
if (\is_scalar($body)) {
82+
$opts[GuzzleRequestOptions::BODY] = $body;
83+
} else {
84+
$opts[GuzzleRequestOptions::JSON] = $body;
85+
}
8286
}
8387

8488
return $opts;

src/Request.php

+1-31
Original file line numberDiff line numberDiff line change
@@ -82,36 +82,6 @@ public function __construct(string $method, string $path, Config $config, $body)
8282
}
8383

8484
$this->body = $body;
85-
86-
// if (null !== $body) {
87-
// switch (\gettype($body)) {
88-
// case Hydration::OBJECT:
89-
// case Hydration::ARRAY:
90-
// $this->body = \json_encode($body, $config->JSONEncodeOpts);
91-
// if (\JSON_ERROR_NONE !== \json_last_error()) {
92-
// throw new \RuntimeException(
93-
// \sprintf(
94-
// 'Error encoding request body as json: %s',
95-
// \json_last_error_msg()
96-
// )
97-
// );
98-
// }
99-
// break;
100-
//
101-
// case Hydration::INTEGER:
102-
// case Hydration::DOUBLE:
103-
// $this->body = (string)$body;
104-
// break;
105-
//
106-
// case Hydration::STRING:
107-
// $this->body = $body;
108-
// break;
109-
//
110-
// case Hydration::BOOLEAN:
111-
// $this->body = $body ? Hydration::TRUE : Hydration::FALSE;
112-
// break;
113-
// }
114-
// }
11585
}
11686

11787
/**
@@ -147,7 +117,7 @@ public function getMethod(): string
147117
}
148118

149119
/**
150-
* @return string
120+
* @return mixed
151121
*/
152122
public function getBody()
153123
{

0 commit comments

Comments
 (0)