Skip to content

Commit

Permalink
fix: Prevents invalid stream for null payloads (#4)
Browse files Browse the repository at this point in the history
fix: Prevents invalid stream for null payloads
docs(release): 0.1.1

Resolves: #3
  • Loading branch information
mikeymike committed Jan 15, 2024
1 parent 5938cb1 commit df2fc8b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
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.

## 0.1.1 - 2024-01-15

### Fixed

- Resolved invalid streams being created for null payloads

## dev - 2024-01-10

### Added
Expand Down
14 changes: 8 additions & 6 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

class Client
{
private const SDK_VERSION = '0.1.0';
private const SDK_VERSION = '0.1.1';

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

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

$request = $request->withBody(
// Satisfies empty body requests.
$this->streamFactory->createStream($body === '[]' ? '{}' : $body),
);
$request = $request->withBody(
// Satisfies empty body requests.
$this->streamFactory->createStream($body === '[]' ? '{}' : $body),
);
}

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

Expand Down

0 comments on commit df2fc8b

Please sign in to comment.