Skip to content

Commit

Permalink
chore: update SDK from api-definitions (#653)
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 Oct 31, 2023
1 parent 1ba4e2f commit 3a40c8f
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .changeset/three-cows-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

refactor: Flatten schema directory tree Rebilly/api-definitions#1655
4 changes: 2 additions & 2 deletions examples/purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Rebilly\Sdk\Model\OrderItem;
use Rebilly\Sdk\Model\OrderItemPlan;
use Rebilly\Sdk\Model\PaymentCardToken;
use Rebilly\Sdk\Model\PaymentToken;
use Rebilly\Sdk\Model\PaymentInstructionToken;
use Rebilly\Sdk\Model\Plan;
use Rebilly\Sdk\Model\PlanFormulaFlatRate;
use Rebilly\Sdk\Model\PostTransactionRequest;
Expand Down Expand Up @@ -165,7 +165,7 @@ function printEntity(mixed $entity): void
->setIsMerchantInitiated(true)
->setIsProcessedOutside(true)
->setPaymentInstruction(
PaymentToken::from()
PaymentInstructionToken::from()
->setToken($token->getId()),
)
->setInvoiceIds([(string) $invoice->getId()]);
Expand Down
8 changes: 4 additions & 4 deletions src/Api/ReportsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Utils;
use Rebilly\Sdk\Collection;
use Rebilly\Sdk\Model\APILogSummary;
use Rebilly\Sdk\Model\ApiLogSummary;
use Rebilly\Sdk\Model\CumulativeSubscriptions;
use Rebilly\Sdk\Model\DashboardResponse;
use Rebilly\Sdk\Model\DccMarkup;
Expand Down Expand Up @@ -51,14 +51,14 @@ public function __construct(protected ?ClientInterface $client)
}

/**
* @return APILogSummary
* @return ApiLogSummary
*/
public function getApiLogSummary(
DateTimeImmutable $periodStart,
DateTimeImmutable $periodEnd,
?int $limit = null,
?int $offset = null,
): APILogSummary {
): ApiLogSummary {
$queryParams = [
'periodStart' => $periodStart->format('Y-m-d\TH:i:s\Z'),
'periodEnd' => $periodEnd->format('Y-m-d\TH:i:s\Z'),
Expand All @@ -71,7 +71,7 @@ public function getApiLogSummary(
$response = $this->client->send($request);
$data = Utils::jsonDecode((string) $response->getBody(), true);

return APILogSummary::from($data);
return ApiLogSummary::from($data);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Model/APILogSummary.php → src/Model/ApiLogSummary.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use JsonSerializable;

class APILogSummary implements JsonSerializable
class ApiLogSummary implements JsonSerializable
{
private array $fields = [];

Expand All @@ -32,20 +32,20 @@ public static function from(array $data = []): self
}

/**
* @return null|APILogSummaryData[]
* @return null|ApiLogSummaryData[]
*/
public function getData(): ?array
{
return $this->fields['data'] ?? null;
}

/**
* @param null|APILogSummaryData[]|array[] $data
* @param null|ApiLogSummaryData[]|array[] $data
*/
public function setData(null|array $data): static
{
$data = $data !== null ? array_map(
fn ($value) => $value !== null ? ($value instanceof APILogSummaryData ? $value : APILogSummaryData::from($value)) : null,
fn ($value) => $value !== null ? ($value instanceof ApiLogSummaryData ? $value : ApiLogSummaryData::from($value)) : null,
$data,
) : null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use JsonSerializable;

class APILogSummaryData implements JsonSerializable
class ApiLogSummaryData implements JsonSerializable
{
private array $fields = [];

Expand Down
2 changes: 1 addition & 1 deletion src/Model/FeeFormulaFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static function from(array $data = []): FeeFormula
{
return match ($data['type']) {
'fixed-fee' => FixedFeeFormula::from($data),
'percentage' => PercentageFormula::from($data),
'percentage' => PercentageFeeFormula::from($data),
default => throw new UnknownDiscriminatorValueException(),
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Manual.php → src/Model/ManualTax.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use JsonSerializable;

class Manual implements Taxes, JsonSerializable
class ManualTax implements Taxes, JsonSerializable
{
private array $fields = [];

Expand Down
4 changes: 2 additions & 2 deletions src/Model/PaymentInstructionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class PaymentInstructionFactory
public static function from(array $data = []): PaymentInstruction
{
if (isset($data['token'])) {
return PaymentToken::from($data);
return PaymentInstructionToken::from($data);
}
if (isset($data['paymentInstrumentId'])) {
return PaymentInstructionInstrument::from($data);
}
if (isset($data['methods'])) {
return PaymentMethods::from($data);
return PaymentInstructionMethods::from($data);
}

return match ($data['method']) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use JsonSerializable;

class PaymentMethods implements PaymentInstruction, JsonSerializable
class PaymentInstructionMethods implements PaymentInstruction, JsonSerializable
{
public const METHOD_PAYMENT_CARD = 'payment-card';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use JsonSerializable;

class PaymentToken implements PaymentInstruction, JsonSerializable
class PaymentInstructionToken implements PaymentInstruction, JsonSerializable
{
public const METHOD_PAYMENT_CARD = 'payment-card';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use JsonSerializable;

class PercentageFormula implements FeeFormula, JsonSerializable
class PercentageFeeFormula implements FeeFormula, JsonSerializable
{
private array $fields = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use JsonSerializable;

class RebillyAvalara implements Taxes, JsonSerializable
class RebillyAvalaraTax implements Taxes, JsonSerializable
{
private array $fields = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use JsonSerializable;

class RebillyTaxjar implements Taxes, JsonSerializable
class RebillyTaxJarTax implements Taxes, JsonSerializable
{
private array $fields = [];

Expand Down
6 changes: 3 additions & 3 deletions src/Model/TaxesFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class TaxesFactory
public static function from(array $data = []): Taxes
{
return match ($data['calculator']) {
'manual' => Manual::from($data),
'rebilly-avalara' => RebillyAvalara::from($data),
'rebilly-taxjar' => RebillyTaxjar::from($data),
'manual' => ManualTax::from($data),
'rebilly-avalara' => RebillyAvalaraTax::from($data),
'rebilly-taxjar' => RebillyTaxJarTax::from($data),
default => throw new UnknownDiscriminatorValueException(),
};
}
Expand Down

0 comments on commit 3a40c8f

Please sign in to comment.