Skip to content

Commit

Permalink
update SDK from api-definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
rebilly-machine-user authored Mar 27, 2024
1 parent eafe237 commit 257e95a
Show file tree
Hide file tree
Showing 37 changed files with 320 additions and 795 deletions.
5 changes: 5 additions & 0 deletions .changeset/brave-needles-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Fix GatewayAccount PUT SDK operation name Rebilly/api-definitions#1845
5 changes: 5 additions & 0 deletions .changeset/brave-pandas-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Add subscription billingPortalToken Rebilly/api-definitions#1834
5 changes: 5 additions & 0 deletions .changeset/breezy-rats-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Add paypal-claim dispute type Rebilly/api-definitions#1825
5 changes: 5 additions & 0 deletions .changeset/cold-cows-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Add interimOnly for ChangeQuote Rebilly/api-definitions#1819
5 changes: 5 additions & 0 deletions .changeset/curvy-ligers-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Bump @redocly/cli from 1.10.5 to 1.10.6 Rebilly/api-definitions#1847
5 changes: 5 additions & 0 deletions .changeset/dirty-jeans-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Add StorefrontPostSubscriptionReactivation Rebilly/api-definitions#1830
5 changes: 5 additions & 0 deletions .changeset/friendly-gifts-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Make WebhookCredential type readonly Rebilly/api-definitions#1832
5 changes: 5 additions & 0 deletions .changeset/khaki-news-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Adjust SubscriptionChange items-quantity Rebilly/api-definitions#1829
5 changes: 5 additions & 0 deletions .changeset/odd-singers-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Flatten plan related schemas Rebilly/api-definitions#1838
5 changes: 5 additions & 0 deletions .changeset/popular-trains-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Simplify service credential Rebilly/api-definitions#1831
5 changes: 5 additions & 0 deletions .changeset/purple-plums-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Add method to payout request allocation Rebilly/api-definitions#1833
5 changes: 5 additions & 0 deletions .changeset/quiet-carpets-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

add parameters to GetEventCollection Rebilly/api-definitions#1835
5 changes: 5 additions & 0 deletions .changeset/rich-badgers-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Add query collection parameter to GetEventCollection Rebilly/api-definitions#1837
5 changes: 5 additions & 0 deletions .changeset/rotten-feet-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

bump deps and remove extra deps Rebilly/api-definitions#1842
5 changes: 5 additions & 0 deletions .changeset/ten-avocados-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Rename Subscription endTime to churnTime Rebilly/api-definitions#1836
5 changes: 5 additions & 0 deletions .changeset/tidy-poets-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

feat: Allow clearing sticky gateway from payment instrument by sending value Rebilly/api-definitions#1786
44 changes: 39 additions & 5 deletions src/Api/EventsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,51 @@ public function get(
}

/**
* @return SystemEvent[]
* @return Collection<SystemEvent>
*/
public function getAll(): array
{
$uri = '/events';
public function getAll(
?int $limit = null,
?int $offset = null,
?string $filter = null,
?string $q = null,
): Collection {
$queryParams = [
'limit' => $limit,
'offset' => $offset,
'filter' => $filter,
'q' => $q,
];
$uri = '/events?' . http_build_query($queryParams);

$request = new Request('GET', $uri);
$response = $this->client->send($request);
$data = Utils::jsonDecode((string) $response->getBody(), true);

return array_map(fn (array $item): SystemEvent => SystemEvent::from($item), $data);
return new Collection(
array_map(fn (array $item): SystemEvent => SystemEvent::from($item), $data),
(int) $response->getHeaderLine(Collection::HEADER_LIMIT),
(int) $response->getHeaderLine(Collection::HEADER_OFFSET),
(int) $response->getHeaderLine(Collection::HEADER_TOTAL),
);
}

public function getAllPaginator(
?int $limit = null,
?int $offset = null,
?string $filter = null,
?string $q = null,
): Paginator {
$closure = fn (?int $limit, ?int $offset): Collection => $this->getAll(
limit: $limit,
offset: $offset,
filter: $filter,
q: $q,
);

return new Paginator(
$limit !== null || $offset !== null ? $closure(limit: $limit, offset: $offset) : null,
$closure,
);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Api/GatewayAccountsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ public function update(

$uri = str_replace(array_keys($pathParams), array_values($pathParams), '/gateway-accounts/{id}');

$request = new Request('PUT', $uri, body: Utils::jsonEncode($gatewayAccount));
$request = new Request('PATCH', $uri, body: Utils::jsonEncode($gatewayAccount));
$response = $this->client->send($request);
$data = Utils::jsonDecode((string) $response->getBody(), true);

Expand Down Expand Up @@ -590,7 +590,7 @@ public function updateVolumeLimit(
/**
* @return GatewayAccount
*/
public function update_0(
public function upsert(
string $id,
GatewayAccount $gatewayAccount,
): GatewayAccount {
Expand All @@ -600,7 +600,7 @@ public function update_0(

$uri = str_replace(array_keys($pathParams), array_values($pathParams), '/gateway-accounts/{id}');

$request = new Request('PATCH', $uri, body: Utils::jsonEncode($gatewayAccount));
$request = new Request('PUT', $uri, body: Utils::jsonEncode($gatewayAccount));
$response = $this->client->send($request);
$data = Utils::jsonDecode((string) $response->getBody(), true);

Expand Down
5 changes: 2 additions & 3 deletions src/Api/ServiceCredentialsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Rebilly\Sdk\Collection;
use Rebilly\Sdk\Model\GoogleSpreadsheet;
use Rebilly\Sdk\Model\PatchServiceCredentialRequest;
use Rebilly\Sdk\Model\PostServiceCredentialRequest;
use Rebilly\Sdk\Model\ServiceCredential;
use Rebilly\Sdk\Model\ServiceCredentialFactory;
use Rebilly\Sdk\Paginator;
Expand All @@ -35,15 +34,15 @@ public function __construct(protected ?ClientInterface $client)
*/
public function create(
string $type,
PostServiceCredentialRequest $postServiceCredentialRequest,
ServiceCredential $serviceCredential,
): ServiceCredential {
$pathParams = [
'{type}' => $type,
];

$uri = str_replace(array_keys($pathParams), array_values($pathParams), '/service-credentials/{type}');

$request = new Request('POST', $uri, body: Utils::jsonEncode($postServiceCredentialRequest));
$request = new Request('POST', $uri, body: Utils::jsonEncode($serviceCredential));
$response = $this->client->send($request);
$data = Utils::jsonDecode((string) $response->getBody(), true);

Expand Down
2 changes: 2 additions & 0 deletions src/Model/Dispute.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class Dispute implements JsonSerializable

public const TYPE_BANK_RETURN = 'bank-return';

public const TYPE_PAYPAL_CLAIM = 'paypal-claim';

public const STATUS_RESPONSE_NEEDED = 'response-needed';

public const STATUS_UNDER_REVIEW = 'under-review';
Expand Down
16 changes: 8 additions & 8 deletions src/Model/FlexiblePlan.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,15 @@ public function setPricing(PlanPriceFormula|array $pricing): static
return $this;
}

public function getSetup(): ?OneTimeSalePlanSetup
public function getSetup(): ?PlanSetup
{
return $this->fields['setup'] ?? null;
}

public function setSetup(null|OneTimeSalePlanSetup|array $setup): static
public function setSetup(null|PlanSetup|array $setup): static
{
if ($setup !== null && !($setup instanceof OneTimeSalePlanSetup)) {
$setup = OneTimeSalePlanSetup::from($setup);
if ($setup !== null && !($setup instanceof PlanSetup)) {
$setup = PlanSetup::from($setup);
}

$this->fields['setup'] = $setup;
Expand Down Expand Up @@ -288,15 +288,15 @@ public function setRecurringInterval(SubscriptionPlanRecurringInterval|array $re
return $this;
}

public function getTrial(): TrialOnlyPlanTrial
public function getTrial(): PlanTrial
{
return $this->fields['trial'];
}

public function setTrial(TrialOnlyPlanTrial|array $trial): static
public function setTrial(PlanTrial|array $trial): static
{
if (!($trial instanceof TrialOnlyPlanTrial)) {
$trial = TrialOnlyPlanTrial::from($trial);
if (!($trial instanceof PlanTrial)) {
$trial = PlanTrial::from($trial);
}

$this->fields['trial'] = $trial;
Expand Down
62 changes: 40 additions & 22 deletions src/Model/OneTimeSale.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ public function __construct(array $data = [])
if (array_key_exists('trialReminderNumber', $data)) {
$this->setTrialReminderNumber($data['trialReminderNumber']);
}
if (array_key_exists('churnTime', $data)) {
$this->setChurnTime($data['churnTime']);
}
if (array_key_exists('lineItemSubtotal', $data)) {
$this->setLineItemSubtotal($data['lineItemSubtotal']);
}
Expand Down Expand Up @@ -223,15 +226,15 @@ public function __construct(array $data = [])
if (array_key_exists('renewalReminderNumber', $data)) {
$this->setRenewalReminderNumber($data['renewalReminderNumber']);
}
if (array_key_exists('billingPortalToken', $data)) {
$this->setBillingPortalToken($data['billingPortalToken']);
}
if (array_key_exists('abandonReminderTime', $data)) {
$this->setAbandonReminderTime($data['abandonReminderTime']);
}
if (array_key_exists('isTrialConverted', $data)) {
$this->setIsTrialConverted($data['isTrialConverted']);
}
if (array_key_exists('endTime', $data)) {
$this->setEndTime($data['endTime']);
}
if (array_key_exists('cancelCategory', $data)) {
$this->setCancelCategory($data['cancelCategory']);
}
Expand Down Expand Up @@ -589,6 +592,11 @@ public function getTrialReminderNumber(): ?int
return $this->fields['trialReminderNumber'] ?? null;
}

public function getChurnTime(): ?DateTimeImmutable
{
return $this->fields['churnTime'] ?? null;
}

public function getLineItemSubtotal(): ?SubscriptionLineItemSubtotal
{
return $this->fields['lineItemSubtotal'] ?? null;
Expand Down Expand Up @@ -723,6 +731,11 @@ public function getRenewalReminderNumber(): ?int
return $this->fields['renewalReminderNumber'] ?? null;
}

public function getBillingPortalToken(): ?string
{
return $this->fields['billingPortalToken'] ?? null;
}

public function getAbandonReminderTime(): ?DateTimeImmutable
{
return $this->fields['abandonReminderTime'] ?? null;
Expand All @@ -733,11 +746,6 @@ public function getIsTrialConverted(): ?bool
return $this->fields['isTrialConverted'] ?? null;
}

public function getEndTime(): ?DateTimeImmutable
{
return $this->fields['endTime'] ?? null;
}

public function getCancelCategory(): ?string
{
return $this->fields['cancelCategory'] ?? null;
Expand Down Expand Up @@ -847,6 +855,9 @@ public function jsonSerialize(): array
if (array_key_exists('trialReminderNumber', $this->fields)) {
$data['trialReminderNumber'] = $this->fields['trialReminderNumber'];
}
if (array_key_exists('churnTime', $this->fields)) {
$data['churnTime'] = $this->fields['churnTime']?->format(DateTimeInterface::RFC3339);
}
if (array_key_exists('lineItemSubtotal', $this->fields)) {
$data['lineItemSubtotal'] = $this->fields['lineItemSubtotal']?->jsonSerialize();
}
Expand Down Expand Up @@ -886,15 +897,15 @@ public function jsonSerialize(): array
if (array_key_exists('renewalReminderNumber', $this->fields)) {
$data['renewalReminderNumber'] = $this->fields['renewalReminderNumber'];
}
if (array_key_exists('billingPortalToken', $this->fields)) {
$data['billingPortalToken'] = $this->fields['billingPortalToken'];
}
if (array_key_exists('abandonReminderTime', $this->fields)) {
$data['abandonReminderTime'] = $this->fields['abandonReminderTime']?->format(DateTimeInterface::RFC3339);
}
if (array_key_exists('isTrialConverted', $this->fields)) {
$data['isTrialConverted'] = $this->fields['isTrialConverted'];
}
if (array_key_exists('endTime', $this->fields)) {
$data['endTime'] = $this->fields['endTime']?->format(DateTimeInterface::RFC3339);
}
if (array_key_exists('cancelCategory', $this->fields)) {
$data['cancelCategory'] = $this->fields['cancelCategory'];
}
Expand Down Expand Up @@ -1039,6 +1050,17 @@ private function setTrialReminderNumber(null|int $trialReminderNumber): static
return $this;
}

private function setChurnTime(null|DateTimeImmutable|string $churnTime): static
{
if ($churnTime !== null && !($churnTime instanceof DateTimeImmutable)) {
$churnTime = new DateTimeImmutable($churnTime);
}

$this->fields['churnTime'] = $churnTime;

return $this;
}

private function setTrialReminderTime(null|DateTimeImmutable|string $trialReminderTime): static
{
if ($trialReminderTime !== null && !($trialReminderTime instanceof DateTimeImmutable)) {
Expand Down Expand Up @@ -1089,6 +1111,13 @@ private function setRenewalReminderNumber(null|int $renewalReminderNumber): stat
return $this;
}

private function setBillingPortalToken(null|string $billingPortalToken): static
{
$this->fields['billingPortalToken'] = $billingPortalToken;

return $this;
}

private function setAbandonReminderTime(null|DateTimeImmutable|string $abandonReminderTime): static
{
if ($abandonReminderTime !== null && !($abandonReminderTime instanceof DateTimeImmutable)) {
Expand All @@ -1107,17 +1136,6 @@ private function setIsTrialConverted(null|bool $isTrialConverted): static
return $this;
}

private function setEndTime(null|DateTimeImmutable|string $endTime): static
{
if ($endTime !== null && !($endTime instanceof DateTimeImmutable)) {
$endTime = new DateTimeImmutable($endTime);
}

$this->fields['endTime'] = $endTime;

return $this;
}

private function setCancelCategory(null|string $cancelCategory): static
{
$this->fields['cancelCategory'] = $cancelCategory;
Expand Down
Loading

0 comments on commit 257e95a

Please sign in to comment.