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 Nov 27, 2023
1 parent 06e0981 commit 53e338a
Show file tree
Hide file tree
Showing 12 changed files with 507 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-hotels-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

feat(experimental): Add declined transactions report Rebilly/api-definitions#1570
5 changes: 5 additions & 0 deletions .changeset/healthy-ants-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Add usage limits events Rebilly/api-definitions#1701
5 changes: 5 additions & 0 deletions .changeset/plenty-weeks-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Add usage limits configuration to the change items operation Rebilly/api-definitions#1706
5 changes: 5 additions & 0 deletions .changeset/spotty-emus-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Add usage limit configuration Rebilly/api-definitions#1650
29 changes: 29 additions & 0 deletions src/Api/ReportsApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Rebilly\Sdk\Model\FutureRenewals;
use Rebilly\Sdk\Model\GetKycAcceptanceSummaryResponse;
use Rebilly\Sdk\Model\RenewalSales;
use Rebilly\Sdk\Model\ReportDeclinedTransactions;
use Rebilly\Sdk\Model\ReportDisputeDelays;
use Rebilly\Sdk\Model\ReportDisputes;
use Rebilly\Sdk\Model\ReportEventsTriggeredSummary;
Expand Down Expand Up @@ -154,6 +155,34 @@ public function getDccMarkup(
return DccMarkup::from($data);
}

/**
* @return ReportDeclinedTransactions
*/
public function getDeclinedTransactions(
string $aggregationField,
DateTimeImmutable $periodStart,
DateTimeImmutable $periodEnd,
?int $limit = null,
?int $offset = null,
?string $filter = null,
): ReportDeclinedTransactions {
$queryParams = [
'aggregationField' => $aggregationField,
'periodStart' => $periodStart->format('Y-m-d\TH:i:s\Z'),
'periodEnd' => $periodEnd->format('Y-m-d\TH:i:s\Z'),
'limit' => $limit,
'offset' => $offset,
'filter' => $filter,
];
$uri = '/experimental/reports/declined-transactions?' . http_build_query($queryParams);

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

return ReportDeclinedTransactions::from($data);
}

/**
* @return ReportDisputes
*/
Expand Down
22 changes: 22 additions & 0 deletions src/Model/OrderItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public function __construct(array $data = [])
if (array_key_exists('plan', $data)) {
$this->setPlan($data['plan']);
}
if (array_key_exists('usageLimits', $data)) {
$this->setUsageLimits($data['usageLimits']);
}
if (array_key_exists('revision', $data)) {
$this->setRevision($data['revision']);
}
Expand Down Expand Up @@ -97,6 +100,22 @@ public function setPlan(OrderItemPlan|array $plan): static
return $this;
}

public function getUsageLimits(): ?OrderItemUsageLimits
{
return $this->fields['usageLimits'] ?? null;
}

public function setUsageLimits(null|OrderItemUsageLimits|array $usageLimits): static
{
if ($usageLimits !== null && !($usageLimits instanceof OrderItemUsageLimits)) {
$usageLimits = OrderItemUsageLimits::from($usageLimits);
}

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

return $this;
}

public function getRevision(): ?int
{
return $this->fields['revision'] ?? null;
Expand Down Expand Up @@ -143,6 +162,9 @@ public function jsonSerialize(): array
if (array_key_exists('plan', $this->fields)) {
$data['plan'] = $this->fields['plan']?->jsonSerialize();
}
if (array_key_exists('usageLimits', $this->fields)) {
$data['usageLimits'] = $this->fields['usageLimits']?->jsonSerialize();
}
if (array_key_exists('revision', $this->fields)) {
$data['revision'] = $this->fields['revision'];
}
Expand Down
81 changes: 81 additions & 0 deletions src/Model/OrderItemUsageLimits.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
/**
* This source file is proprietary and part of Rebilly.
*
* (c) Rebilly SRL
* Rebilly Ltd.
* Rebilly Inc.
*
* @see https://www.rebilly.com
*/

declare(strict_types=1);

namespace Rebilly\Sdk\Model;

use JsonSerializable;

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

public function __construct(array $data = [])
{
if (array_key_exists('softLimit', $data)) {
$this->setSoftLimit($data['softLimit']);
}
if (array_key_exists('hardLimit', $data)) {
$this->setHardLimit($data['hardLimit']);
}
}

public static function from(array $data = []): self
{
return new self($data);
}

public function getSoftLimit(): ?OrderItemUsageLimitsSoftLimit
{
return $this->fields['softLimit'] ?? null;
}

public function setSoftLimit(null|OrderItemUsageLimitsSoftLimit|array $softLimit): static
{
if ($softLimit !== null && !($softLimit instanceof OrderItemUsageLimitsSoftLimit)) {
$softLimit = OrderItemUsageLimitsSoftLimit::from($softLimit);
}

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

return $this;
}

public function getHardLimit(): ?OrderItemUsageLimitsHardLimit
{
return $this->fields['hardLimit'] ?? null;
}

public function setHardLimit(null|OrderItemUsageLimitsHardLimit|array $hardLimit): static
{
if ($hardLimit !== null && !($hardLimit instanceof OrderItemUsageLimitsHardLimit)) {
$hardLimit = OrderItemUsageLimitsHardLimit::from($hardLimit);
}

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

return $this;
}

public function jsonSerialize(): array
{
$data = [];
if (array_key_exists('softLimit', $this->fields)) {
$data['softLimit'] = $this->fields['softLimit']?->jsonSerialize();
}
if (array_key_exists('hardLimit', $this->fields)) {
$data['hardLimit'] = $this->fields['hardLimit']?->jsonSerialize();
}

return $data;
}
}
77 changes: 77 additions & 0 deletions src/Model/OrderItemUsageLimitsHardLimit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/**
* This source file is proprietary and part of Rebilly.
*
* (c) Rebilly SRL
* Rebilly Ltd.
* Rebilly Inc.
*
* @see https://www.rebilly.com
*/

declare(strict_types=1);

namespace Rebilly\Sdk\Model;

use JsonSerializable;

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

public function __construct(array $data = [])
{
if (array_key_exists('quantity', $data)) {
$this->setQuantity($data['quantity']);
}
if (array_key_exists('amount', $data)) {
$this->setAmount($data['amount']);
}
}

public static function from(array $data = []): self
{
return new self($data);
}

public function getQuantity(): ?int
{
return $this->fields['quantity'] ?? null;
}

public function setQuantity(null|int $quantity): static
{
$this->fields['quantity'] = $quantity;

return $this;
}

public function getAmount(): ?float
{
return $this->fields['amount'] ?? null;
}

public function setAmount(null|float|string $amount): static
{
if (is_string($amount)) {
$amount = (float) $amount;
}

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

return $this;
}

public function jsonSerialize(): array
{
$data = [];
if (array_key_exists('quantity', $this->fields)) {
$data['quantity'] = $this->fields['quantity'];
}
if (array_key_exists('amount', $this->fields)) {
$data['amount'] = $this->fields['amount'];
}

return $data;
}
}
77 changes: 77 additions & 0 deletions src/Model/OrderItemUsageLimitsSoftLimit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php
/**
* This source file is proprietary and part of Rebilly.
*
* (c) Rebilly SRL
* Rebilly Ltd.
* Rebilly Inc.
*
* @see https://www.rebilly.com
*/

declare(strict_types=1);

namespace Rebilly\Sdk\Model;

use JsonSerializable;

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

public function __construct(array $data = [])
{
if (array_key_exists('quantity', $data)) {
$this->setQuantity($data['quantity']);
}
if (array_key_exists('amount', $data)) {
$this->setAmount($data['amount']);
}
}

public static function from(array $data = []): self
{
return new self($data);
}

public function getQuantity(): ?int
{
return $this->fields['quantity'] ?? null;
}

public function setQuantity(null|int $quantity): static
{
$this->fields['quantity'] = $quantity;

return $this;
}

public function getAmount(): ?float
{
return $this->fields['amount'] ?? null;
}

public function setAmount(null|float|string $amount): static
{
if (is_string($amount)) {
$amount = (float) $amount;
}

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

return $this;
}

public function jsonSerialize(): array
{
$data = [];
if (array_key_exists('quantity', $this->fields)) {
$data['quantity'] = $this->fields['quantity'];
}
if (array_key_exists('amount', $this->fields)) {
$data['amount'] = $this->fields['amount'];
}

return $data;
}
}
Loading

0 comments on commit 53e338a

Please sign in to comment.