Skip to content

Commit

Permalink
chore: update SDK from api-definitions (#695)
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 Jun 6, 2024
1 parent 028c113 commit 0c3fadb
Show file tree
Hide file tree
Showing 21 changed files with 1,228 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/calm-pugs-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Fix api errors in risk-score-simualtion-jobs Rebilly/rebilly#5709
5 changes: 5 additions & 0 deletions .changeset/hip-geckos-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Add "release" version attribute to Status API response Rebilly/rebilly#1883
5 changes: 5 additions & 0 deletions .changeset/pretty-jeans-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Risk score simulation configuration Rebilly/rebilly#5613
5 changes: 5 additions & 0 deletions .changeset/spotty-zoos-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Add autopay to trial only conversion quote Rebilly/rebilly#5685
5 changes: 5 additions & 0 deletions .changeset/tame-swans-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Add PayU gateway account Rebilly/rebilly#5250
184 changes: 184 additions & 0 deletions src/Api/RiskScoreSimulationJobsApi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
<?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\Api;

use GuzzleHttp\ClientInterface;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Utils;
use Rebilly\Sdk\Collection;
use Rebilly\Sdk\Model\RiskScoreSimulationJob;
use Rebilly\Sdk\Model\RiskScoreSimulationTransaction;
use Rebilly\Sdk\Paginator;

class RiskScoreSimulationJobsApi
{
public function __construct(protected ?ClientInterface $client)
{
}

public function create(
RiskScoreSimulationJob $riskScoreSimulationJob,
): RiskScoreSimulationJob {
$uri = '/risk-score-simulation-jobs';

$request = new Request('POST', $uri, headers: [
'Accept' => 'application/json',
], body: Utils::jsonEncode($riskScoreSimulationJob));
$response = $this->client->send($request);
$data = Utils::jsonDecode((string) $response->getBody(), true);

return RiskScoreSimulationJob::from($data);
}

public function get(
string $id,
): RiskScoreSimulationJob {
$pathParams = [
'{id}' => $id,
];

$uri = str_replace(array_keys($pathParams), array_values($pathParams), '/risk-score-simulation-jobs/{id}');

$request = new Request('GET', $uri, headers: [
'Accept' => 'application/json',
]);
$response = $this->client->send($request);
$data = Utils::jsonDecode((string) $response->getBody(), true);

return RiskScoreSimulationJob::from($data);
}

/**
* @return Collection<RiskScoreSimulationJob>
*/
public function getAll(
?string $filter = null,
?array $sort = null,
?int $limit = null,
?int $offset = null,
): Collection {
$queryParams = [
'filter' => $filter,
'sort' => $sort ? implode(',', $sort) : null,
'limit' => $limit,
'offset' => $offset,
];
$uri = '/risk-score-simulation-jobs?' . http_build_query($queryParams);

$request = new Request('GET', $uri, headers: [
'Accept' => 'application/json',
]);
$response = $this->client->send($request);
$data = Utils::jsonDecode((string) $response->getBody(), true);

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

/**
* @return Paginator<RiskScoreSimulationJob>
*/
public function getAllPaginator(
?string $filter = null,
?array $sort = null,
?int $limit = null,
?int $offset = null,
): Paginator {
$closure = fn (?int $limit, ?int $offset): Collection => $this->getAll(
filter: $filter,
sort: $sort,
limit: $limit,
offset: $offset,
);

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

/**
* @return Collection<RiskScoreSimulationTransaction>
*/
public function getTransactions(
string $id,
?int $limit = null,
?int $offset = null,
): Collection {
$pathParams = [
'{id}' => $id,
];

$queryParams = [
'limit' => $limit,
'offset' => $offset,
];
$uri = str_replace(array_keys($pathParams), array_values($pathParams), '/risk-score-simulation-jobs/{id}/transactions?') . http_build_query($queryParams);

$request = new Request('GET', $uri, headers: [
'Accept' => 'application/json',
]);
$response = $this->client->send($request);
$data = Utils::jsonDecode((string) $response->getBody(), true);

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

/**
* @return Paginator<RiskScoreSimulationTransaction>
*/
public function getTransactionsPaginator(
string $id,
?int $limit = null,
?int $offset = null,
): Paginator {
$closure = fn (?int $limit, ?int $offset): Collection => $this->getTransactions(
id: $id,
limit: $limit,
offset: $offset,
);

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

public function stop(
string $id,
): RiskScoreSimulationJob {
$pathParams = [
'{id}' => $id,
];

$uri = str_replace(array_keys($pathParams), array_values($pathParams), '/risk-score-simulation-jobs/{id}/stop');

$request = new Request('POST', $uri, headers: [
'Accept' => 'application/json',
]);
$response = $this->client->send($request);
$data = Utils::jsonDecode((string) $response->getBody(), true);

return RiskScoreSimulationJob::from($data);
}
}
36 changes: 36 additions & 0 deletions src/Model/Directa24Credentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ public function __construct(array $data = [])
if (array_key_exists('cashout_password', $data)) {
$this->setCashoutPassword($data['cashout_password']);
}
if (array_key_exists('chargebackAccessKey', $data)) {
$this->setChargebackAccessKey($data['chargebackAccessKey']);
}
if (array_key_exists('chargebackSecretKey', $data)) {
$this->setChargebackSecretKey($data['chargebackSecretKey']);
}
}

public static function from(array $data = []): self
Expand Down Expand Up @@ -133,6 +139,30 @@ public function setCashoutPassword(null|string $cashoutPassword): static
return $this;
}

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

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

return $this;
}

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

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

return $this;
}

public function jsonSerialize(): array
{
$data = [];
Expand All @@ -157,6 +187,12 @@ public function jsonSerialize(): array
if (array_key_exists('cashout_password', $this->fields)) {
$data['cashout_password'] = $this->fields['cashout_password'];
}
if (array_key_exists('chargebackAccessKey', $this->fields)) {
$data['chargebackAccessKey'] = $this->fields['chargebackAccessKey'];
}
if (array_key_exists('chargebackSecretKey', $this->fields)) {
$data['chargebackSecretKey'] = $this->fields['chargebackSecretKey'];
}

return $data;
}
Expand Down
6 changes: 6 additions & 0 deletions src/Model/GatewayAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ abstract class GatewayAccount implements JsonSerializable

public const GATEWAY_NAME_PAY_TABS = 'PayTabs';

public const GATEWAY_NAME_PAY_U = 'PayU';

public const GATEWAY_NAME_PAY_U_LATAM = 'PayULatam';

public const GATEWAY_NAME_PAYVISION = 'Payvision';
Expand Down Expand Up @@ -706,6 +708,8 @@ abstract class GatewayAccount implements JsonSerializable

public const ACQUIRER_NAME_PAY_TABS = 'PayTabs';

public const ACQUIRER_NAME_PAY_U = 'PayU';

public const ACQUIRER_NAME_PAY_U_LATAM = 'PayULatam';

public const ACQUIRER_NAME_PAYVISION = 'Payvision';
Expand Down Expand Up @@ -1632,6 +1636,8 @@ public static function from(array $data = []): self
return Paysafecash::from($data);
case 'PayTabs':
return PayTabs::from($data);
case 'PayU':
return PayU::from($data);
case 'PayULatam':
return PayULatam::from($data);
case 'Payvision':
Expand Down
2 changes: 2 additions & 0 deletions src/Model/GetPayoutRequestPaymentInstrumentsResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ class GetPayoutRequestPaymentInstrumentsResponse implements JsonSerializable

public const GATEWAY_NAME_PAY_TABS = 'PayTabs';

public const GATEWAY_NAME_PAY_U = 'PayU';

public const GATEWAY_NAME_PAY_U_LATAM = 'PayULatam';

public const GATEWAY_NAME_PAYVISION = 'Payvision';
Expand Down
83 changes: 83 additions & 0 deletions src/Model/PayU.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?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;

class PayU extends GatewayAccount
{
private array $fields = [];

public function __construct(array $data = [])
{
parent::__construct([
'gatewayName' => 'PayU',
] + $data);

if (array_key_exists('credentials', $data)) {
$this->setCredentials($data['credentials']);
}
if (array_key_exists('threeDSecureServer', $data)) {
$this->setThreeDSecureServer($data['threeDSecureServer']);
}
}

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

public function getCredentials(): PayUCredentials
{
return $this->fields['credentials'];
}

public function setCredentials(PayUCredentials|array $credentials): static
{
if (!($credentials instanceof PayUCredentials)) {
$credentials = PayUCredentials::from($credentials);
}

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

return $this;
}

public function getThreeDSecureServer(): ?ThreeDSecureIO3dsServer
{
return $this->fields['threeDSecureServer'] ?? null;
}

public function setThreeDSecureServer(null|ThreeDSecureIO3dsServer|array $threeDSecureServer): static
{
if ($threeDSecureServer !== null && !($threeDSecureServer instanceof ThreeDSecureIO3dsServer)) {
$threeDSecureServer = ThreeDSecureIO3dsServer::from($threeDSecureServer);
}

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

return $this;
}

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

return parent::jsonSerialize() + $data;
}
}
Loading

0 comments on commit 0c3fadb

Please sign in to comment.