Skip to content

Commit

Permalink
Make user agent configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
jlevers committed Jun 21, 2024
1 parent 62a7a8a commit f594596
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/SellingPartnerApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ abstract class SellingPartnerApi extends Connector

protected TokensV20210301\Api $tokensApi;

protected string $userAgent;

public function __construct(
public readonly string $clientId,
public readonly string $clientSecret,
Expand Down Expand Up @@ -188,9 +190,21 @@ function () use ($method, $path, $dataElements, $delegatee, $tokensApi): AccessT

public function getUserAgent(): string
{
if (isset($this->userAgent)) {
return $this->userAgent;
}

$version = Package::version();
$this->userAgent = "jlevers/selling-partner-api/v$version/php";

return $this->userAgent;
}

public function setUserAgent(string $userAgent): static
{
$this->userAgent = $userAgent;

return "jlevers/selling-partner-api/v$version/php";
return $this;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Traits/Deserializes.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ trait Deserializes
use HasComplexArrayTypes;

protected static string $datetimeFormat = 'Y-m-d\TH:i:s\Z';

protected static string $dateFormat = 'Y-m-d';

protected static array $validDatetimeFormats = [
'Y-m-d\TH:i:s\Z',
DATE_ATOM,
'Y-m-d'
'Y-m-d',
];

public static function deserialize(mixed $data): mixed
Expand Down

0 comments on commit f594596

Please sign in to comment.