Skip to content

Commit

Permalink
chore: update SDK from api-definitions (#684)
Browse files Browse the repository at this point in the history
Co-authored-by: rebilly-machine-user <[email protected]>
Co-authored-by: Arif Kurkchi <[email protected]>
  • Loading branch information
3 people authored Apr 12, 2024
1 parent 7c2ecb7 commit e5d1a58
Show file tree
Hide file tree
Showing 614 changed files with 2,595 additions and 1,103 deletions.
5 changes: 5 additions & 0 deletions .changeset/late-vans-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Move JsonSerializable down to interfaces
5 changes: 5 additions & 0 deletions .changeset/odd-rabbits-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Add isAdBlockEnabled to RiskMetadata.browserData Rebilly/api-definitions#1848
5 changes: 5 additions & 0 deletions .changeset/slow-bulldogs-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Add jsonSerialization for non-scalar collections Rebilly/rebilly-php#675
2 changes: 0 additions & 2 deletions .changeset/sour-snails-arrive.md

This file was deleted.

12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ Create a Rebilly Client

```php
use Rebilly\Sdk\Client;
use Rebilly\Sdk\CoreService;
use Rebilly\Sdk\Service;

// Instantiate Rebilly client.
$client = new Client([
'base_uri' => Client::SANDBOX_HOST,
'organizationId' => '{organizationId}',
'apiKey' => '{secretKey}',
]);
$coreService = new CoreService(client: $client);
$service = new Service(client: $client);
```

Create a Customer
Expand All @@ -71,7 +71,7 @@ $customer = Customer::from([])
);

try {
$customer = $coreService->customers()->create($form);
$customer = $service->customers()->create($form);
} catch (DataValidationException $e) {
var_dump($e->getValidationErrors());
}
Expand All @@ -87,9 +87,9 @@ Read [Rebilly REST APIs documentation][link-api-doc] for more details.

This new major version brings several new helper classes to communicate with Rebilly REST APIs and some incompatibilities that should be tested before switching SDK versions.

- Now, a service class can be explicitly created to make the API calls instead of using only the `Client`. The service is a helper class that encapsulates the API calls for a specific context. It means that `CoreService` is responsible for the API calls related to the [core API][link-api-doc], `UsersService` for the [users API][link-api-doc-user], and `ReportsService` for the [reports API][link-api-doc-reports]. `CombinedService` can be used to make calls to any of the contexts.
- Now, a `Service` class can be explicitly instantiated to make the API calls instead of using only the `Client`, as it encapsulates the API calls.

- To simplify the migration from the previous version, the `Client` object can be used to make calls to any API context directly. For example, instead of instantiating a service class, one can use:
- To simplify the migration from the previous version, the `Client` object can be used to make calls to any API directly. For example, instead of instantiating a service class, one can use:
```php
$client->customers()->create($form);
```
Expand All @@ -103,8 +103,6 @@ This new major version brings several new helper classes to communicate with Reb
[ico-downloads]: https://img.shields.io/packagist/dt/rebilly/client-php.svg

[link-api-doc]: https://api-reference.rebilly.com/
[link-api-doc-user]: https://user-api-docs.rebilly.com/
[link-api-doc-reports]: https://reports-api-docs.rebilly.com/
[link-github]: https://github.com/Rebilly/rebilly-php
[link-packagist]: https://packagist.org/packages/rebilly/client-php
[link-downloads]: https://packagist.org/packages/rebilly/client-php
Expand Down
2 changes: 1 addition & 1 deletion src/Model/A1Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function jsonSerialize(): array
{
$data = [];
if (array_key_exists('credentials', $this->fields)) {
$data['credentials'] = $this->fields['credentials']?->jsonSerialize();
$data['credentials'] = $this->fields['credentials']->jsonSerialize();
}

return parent::jsonSerialize() + $data;
Expand Down
2 changes: 1 addition & 1 deletion src/Model/ACI.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function jsonSerialize(): array
{
$data = [];
if (array_key_exists('credentials', $this->fields)) {
$data['credentials'] = $this->fields['credentials']?->jsonSerialize();
$data['credentials'] = $this->fields['credentials']->jsonSerialize();
}
if (array_key_exists('settings', $this->fields)) {
$data['settings'] = $this->fields['settings']?->jsonSerialize();
Expand Down
35 changes: 30 additions & 5 deletions src/Model/AML.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,22 +248,47 @@ public function jsonSerialize(): array
$data['nationality'] = $this->fields['nationality'];
}
if (array_key_exists('address', $this->fields)) {
$data['address'] = $this->fields['address'];
$data['address'] = $this->fields['address'] !== null
? array_map(
static fn (AMLAddress $aMLAddress) => $aMLAddress->jsonSerialize(),
$this->fields['address'],
)
: null;
}
if (array_key_exists('dob', $this->fields)) {
$data['dob'] = $this->fields['dob'];
$data['dob'] = $this->fields['dob'] !== null
? array_map(
static fn (DateTimeImmutable $item) => $item->format('Y-m-d'),
$this->fields['dob'],
)
: null;
}
if (array_key_exists('aliases', $this->fields)) {
$data['aliases'] = $this->fields['aliases'];
$data['aliases'] = $this->fields['aliases'] !== null
? array_map(
static fn (AMLAliases $aMLAliases) => $aMLAliases->jsonSerialize(),
$this->fields['aliases'],
)
: null;
}
if (array_key_exists('passport', $this->fields)) {
$data['passport'] = $this->fields['passport'];
$data['passport'] = $this->fields['passport'] !== null
? array_map(
static fn (AMLPassport $aMLPassport) => $aMLPassport->jsonSerialize(),
$this->fields['passport'],
)
: null;
}
if (array_key_exists('comments', $this->fields)) {
$data['comments'] = $this->fields['comments'];
}
if (array_key_exists('_links', $this->fields)) {
$data['_links'] = $this->fields['_links'];
$data['_links'] = $this->fields['_links'] !== null
? array_map(
static fn (ResourceLink $resourceLink) => $resourceLink->jsonSerialize(),
$this->fields['_links'],
)
: null;
}

return $data;
Expand Down
5 changes: 2 additions & 3 deletions src/Model/AchPlaidFeature.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@

use DateTimeImmutable;
use DateTimeInterface;
use JsonSerializable;

class AchPlaidFeature implements ReadyToPayAchMethodFeature, JsonSerializable
class AchPlaidFeature implements ReadyToPayAchMethodFeature
{
private array $fields = [];

Expand Down Expand Up @@ -78,7 +77,7 @@ public function jsonSerialize(): array
$data['linkToken'] = $this->fields['linkToken'];
}
if (array_key_exists('expirationTime', $this->fields)) {
$data['expirationTime'] = $this->fields['expirationTime']?->format(DateTimeInterface::RFC3339);
$data['expirationTime'] = $this->fields['expirationTime']->format(DateTimeInterface::RFC3339);
}

return $data;
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function jsonSerialize(): array
{
$data = [];
if (array_key_exists('scope', $this->fields)) {
$data['scope'] = $this->fields['scope']?->jsonSerialize();
$data['scope'] = $this->fields['scope']->jsonSerialize();
}
if (array_key_exists('permissions', $this->fields)) {
$data['permissions'] = $this->fields['permissions'];
Expand Down
4 changes: 3 additions & 1 deletion src/Model/AdjustPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

namespace Rebilly\Sdk\Model;

interface AdjustPaymentMethod
use JsonSerializable;

interface AdjustPaymentMethod extends JsonSerializable
{
public function getPaymentMethod(): string;
}
4 changes: 1 addition & 3 deletions src/Model/AdjustReadyToPayAch.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

namespace Rebilly\Sdk\Model;

use JsonSerializable;

class AdjustReadyToPayAch implements AdjustPaymentMethod, JsonSerializable
class AdjustReadyToPayAch implements AdjustPaymentMethod
{
public const FEATURE_PLAID = 'Plaid';

Expand Down
4 changes: 1 addition & 3 deletions src/Model/AdjustReadyToPayGeneric.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

namespace Rebilly\Sdk\Model;

use JsonSerializable;

class AdjustReadyToPayGeneric implements AdjustPaymentMethod, JsonSerializable
class AdjustReadyToPayGeneric implements AdjustPaymentMethod
{
public const PAYMENT_METHOD_CASH = 'cash';

Expand Down
4 changes: 1 addition & 3 deletions src/Model/AdjustReadyToPayPaymentCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

namespace Rebilly\Sdk\Model;

use JsonSerializable;

class AdjustReadyToPayPaymentCard implements AdjustPaymentMethod, JsonSerializable
class AdjustReadyToPayPaymentCard implements AdjustPaymentMethod
{
public const FEATURE_APPLE_PAY = 'Apple Pay';

Expand Down
4 changes: 1 addition & 3 deletions src/Model/AdjustReadyToPayPaypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

namespace Rebilly\Sdk\Model;

use JsonSerializable;

class AdjustReadyToPayPaypal implements AdjustPaymentMethod, JsonSerializable
class AdjustReadyToPayPaypal implements AdjustPaymentMethod
{
public const FEATURE_PAY_PAL_BILLING_AGREEMENT = 'PayPal billing agreement';

Expand Down
4 changes: 1 addition & 3 deletions src/Model/AdjustReadyToPayoutGeneric.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

namespace Rebilly\Sdk\Model;

use JsonSerializable;

class AdjustReadyToPayoutGeneric implements AdjustReadyToPayoutPaymentMethod, JsonSerializable
class AdjustReadyToPayoutGeneric implements AdjustReadyToPayoutPaymentMethod
{
public const PAYMENT_METHOD_CASH = 'cash';

Expand Down
4 changes: 3 additions & 1 deletion src/Model/AdjustReadyToPayoutPaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

namespace Rebilly\Sdk\Model;

interface AdjustReadyToPayoutPaymentMethod
use JsonSerializable;

interface AdjustReadyToPayoutPaymentMethod extends JsonSerializable
{
public function getPaymentMethod(): string;
}
4 changes: 2 additions & 2 deletions src/Model/Adyen.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ public function jsonSerialize(): array
{
$data = [];
if (array_key_exists('credentials', $this->fields)) {
$data['credentials'] = $this->fields['credentials']?->jsonSerialize();
$data['credentials'] = $this->fields['credentials']->jsonSerialize();
}
if (array_key_exists('settings', $this->fields)) {
$data['settings'] = $this->fields['settings']?->jsonSerialize();
$data['settings'] = $this->fields['settings']->jsonSerialize();
}
if (array_key_exists('threeDSecureServer', $this->fields)) {
$data['threeDSecureServer'] = $this->fields['threeDSecureServer']?->jsonSerialize();
Expand Down
7 changes: 6 additions & 1 deletion src/Model/AdyenSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ public function jsonSerialize(): array
$data['url'] = $this->fields['url'];
}
if (array_key_exists('splitPayments', $this->fields)) {
$data['splitPayments'] = $this->fields['splitPayments'];
$data['splitPayments'] = $this->fields['splitPayments'] !== null
? array_map(
static fn (AdyenSettingsSplitPayments $adyenSettingsSplitPayments) => $adyenSettingsSplitPayments->jsonSerialize(),
$this->fields['splitPayments'],
)
: null;
}
if (array_key_exists('totalTaxRate', $this->fields)) {
$data['totalTaxRate'] = $this->fields['totalTaxRate'];
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Aircash.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function jsonSerialize(): array
{
$data = [];
if (array_key_exists('credentials', $this->fields)) {
$data['credentials'] = $this->fields['credentials']?->jsonSerialize();
$data['credentials'] = $this->fields['credentials']->jsonSerialize();
}

return parent::jsonSerialize() + $data;
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Airpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function jsonSerialize(): array
{
$data = [];
if (array_key_exists('credentials', $this->fields)) {
$data['credentials'] = $this->fields['credentials']?->jsonSerialize();
$data['credentials'] = $this->fields['credentials']->jsonSerialize();
}

return parent::jsonSerialize() + $data;
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Airwallex.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function jsonSerialize(): array
{
$data = [];
if (array_key_exists('credentials', $this->fields)) {
$data['credentials'] = $this->fields['credentials']?->jsonSerialize();
$data['credentials'] = $this->fields['credentials']->jsonSerialize();
}
if (array_key_exists('threeDSecureServer', $this->fields)) {
$data['threeDSecureServer'] = $this->fields['threeDSecureServer']?->jsonSerialize();
Expand Down
12 changes: 8 additions & 4 deletions src/Model/AlternativeInstrument.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@

use DateTimeImmutable;
use DateTimeInterface;
use JsonSerializable;

class AlternativeInstrument implements PaymentInstrument, PostPaymentInstrumentRequest, JsonSerializable
class AlternativeInstrument implements PaymentInstrument, PostPaymentInstrumentRequest
{
public const METHOD_CASH = 'cash';

Expand Down Expand Up @@ -546,7 +545,7 @@ public function jsonSerialize(): array
$data['method'] = $this->fields['method'];
}
if (array_key_exists('billingAddress', $this->fields)) {
$data['billingAddress'] = $this->fields['billingAddress']?->jsonSerialize();
$data['billingAddress'] = $this->fields['billingAddress']->jsonSerialize();
}
if (array_key_exists('status', $this->fields)) {
$data['status'] = $this->fields['status'];
Expand Down Expand Up @@ -576,7 +575,12 @@ public function jsonSerialize(): array
$data['revision'] = $this->fields['revision'];
}
if (array_key_exists('_links', $this->fields)) {
$data['_links'] = $this->fields['_links'];
$data['_links'] = $this->fields['_links'] !== null
? array_map(
static fn (ResourceLink $resourceLink) => $resourceLink->jsonSerialize(),
$this->fields['_links'],
)
: null;
}
if (array_key_exists('_embedded', $this->fields)) {
$data['_embedded'] = $this->fields['_embedded']?->jsonSerialize();
Expand Down
4 changes: 1 addition & 3 deletions src/Model/AlternativePaymentInstrument.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

namespace Rebilly\Sdk\Model;

use JsonSerializable;

class AlternativePaymentInstrument implements CustomerDefaultPaymentInstrument, TransactionPaymentInstrument, JsonSerializable
class AlternativePaymentInstrument implements CustomerDefaultPaymentInstrument, TransactionPaymentInstrument
{
public const METHOD_PAYMENT_CARD = 'payment-card';

Expand Down
12 changes: 8 additions & 4 deletions src/Model/AlternativePaymentToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@

use DateTimeImmutable;
use DateTimeInterface;
use JsonSerializable;

class AlternativePaymentToken implements CompositeToken, JsonSerializable
class AlternativePaymentToken implements CompositeToken
{
public const METHOD_CASH = 'cash';

Expand Down Expand Up @@ -466,7 +465,7 @@ public function jsonSerialize(): array
$data['method'] = $this->fields['method'];
}
if (array_key_exists('billingAddress', $this->fields)) {
$data['billingAddress'] = $this->fields['billingAddress']?->jsonSerialize();
$data['billingAddress'] = $this->fields['billingAddress']->jsonSerialize();
}
if (array_key_exists('id', $this->fields)) {
$data['id'] = $this->fields['id'];
Expand All @@ -493,7 +492,12 @@ public function jsonSerialize(): array
$data['expirationTime'] = $this->fields['expirationTime']?->format(DateTimeInterface::RFC3339);
}
if (array_key_exists('_links', $this->fields)) {
$data['_links'] = $this->fields['_links'];
$data['_links'] = $this->fields['_links'] !== null
? array_map(
static fn (ResourceLink $resourceLink) => $resourceLink->jsonSerialize(),
$this->fields['_links'],
)
: null;
}

return $data;
Expand Down
2 changes: 1 addition & 1 deletion src/Model/AmazonPay.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function jsonSerialize(): array
{
$data = [];
if (array_key_exists('credentials', $this->fields)) {
$data['credentials'] = $this->fields['credentials']?->jsonSerialize();
$data['credentials'] = $this->fields['credentials']->jsonSerialize();
}

return parent::jsonSerialize() + $data;
Expand Down
Loading

0 comments on commit e5d1a58

Please sign in to comment.