Skip to content

Commit df2fc8b

Browse files
authored
fix: Prevents invalid stream for null payloads (#4)
fix: Prevents invalid stream for null payloads docs(release): 0.1.1 Resolves: #3
1 parent 5938cb1 commit df2fc8b

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88
99
Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx&utm_medium=paddle-php-sdk) for information about changes to the Paddle Billing platform, the Paddle API, and other developer tools.
1010

11+
## 0.1.1 - 2024-01-15
12+
13+
### Fixed
14+
15+
- Resolved invalid streams being created for null payloads
16+
1117
## dev - 2024-01-10
1218

1319
### Added

src/Client.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
class Client
5353
{
54-
private const SDK_VERSION = '0.1.0';
54+
private const SDK_VERSION = '0.1.1';
5555

5656
public readonly LoggerInterface $logger;
5757
public readonly Options $options;
@@ -176,12 +176,14 @@ private function requestRaw(string $method, string|UriInterface $uri, array|\Jso
176176
[new JsonEncoder()],
177177
);
178178

179-
$body = $serializer->serialize($payload, 'json');
179+
if ($payload !== null) {
180+
$body = $serializer->serialize($payload, 'json');
180181

181-
$request = $request->withBody(
182-
// Satisfies empty body requests.
183-
$this->streamFactory->createStream($body === '[]' ? '{}' : $body),
184-
);
182+
$request = $request->withBody(
183+
// Satisfies empty body requests.
184+
$this->streamFactory->createStream($body === '[]' ? '{}' : $body),
185+
);
186+
}
185187

186188
$request = $request->withAddedHeader('X-Transaction-ID', $this->transactionId ?? (string) new Ulid());
187189

0 commit comments

Comments
 (0)