-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06e0981
commit 112d537
Showing
4 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |