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 24, 2023
1 parent 06e0981 commit 112d537
Show file tree
Hide file tree
Showing 4 changed files with 213 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
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
84 changes: 84 additions & 0 deletions src/Model/ReportDeclinedTransactions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?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 ReportDeclinedTransactions implements JsonSerializable
{
private array $fields = [];

public function __construct(array $data = [])
{
if (array_key_exists('totalCount', $data)) {
$this->setTotalCount($data['totalCount']);
}
if (array_key_exists('data', $data)) {
$this->setData($data['data']);
}
}

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

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

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

return $this;
}

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

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

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

return $this;
}

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

return $data;
}
}
95 changes: 95 additions & 0 deletions src/Model/ReportDeclinedTransactionsData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?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 ReportDeclinedTransactionsData implements JsonSerializable
{
private array $fields = [];

public function __construct(array $data = [])
{
if (array_key_exists('message', $data)) {
$this->setMessage($data['message']);
}
if (array_key_exists('count', $data)) {
$this->setCount($data['count']);
}
if (array_key_exists('percentage', $data)) {
$this->setPercentage($data['percentage']);
}
}

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

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

public function setMessage(null|string $message): static
{
$this->fields['message'] = $message;

return $this;
}

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

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

return $this;
}

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

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

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

return $this;
}

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

return $data;
}
}

0 comments on commit 112d537

Please sign in to comment.