Skip to content

Commit

Permalink
chore: update SDK from api-definitions (#709)
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 Aug 16, 2024
1 parent 8686836 commit ff8d621
Show file tree
Hide file tree
Showing 19 changed files with 267 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-mayflies-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

feat(be): Add Monolo payment integration Rebilly/rebilly#6870
5 changes: 5 additions & 0 deletions .changeset/blue-keys-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

fix(be): Mark Worldpay dispute as representment Rebilly/rebilly#7022
5 changes: 5 additions & 0 deletions .changeset/lazy-stingrays-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

Fix handling redirect responses Rebilly/rebilly-php#708
5 changes: 5 additions & 0 deletions .changeset/rich-seahorses-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

feat(api-definitions): Add quote-accepted event to order timeline Rebilly/rebilly#7076
5 changes: 5 additions & 0 deletions .changeset/sixty-planes-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rebilly/client-php": patch
---

feat(api-definitions): Add hasCompletedFaceLiveness property to KycIdentityMatches schema Rebilly/rebilly#6777
5 changes: 2 additions & 3 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;

$header = <<<'EOF'
This source file is proprietary and part of Rebilly.
Expand Down Expand Up @@ -63,7 +64,6 @@
'no_mixed_echo_print' => true,
'no_multiline_whitespace_around_double_arrow' => true,
'no_null_property_initialization' => true,
// 'no_short_echo_tag' => true,
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_around_offset' => true,
Expand All @@ -82,14 +82,12 @@
'ordered_class_elements' => true,
'ordered_imports' => true,
'php_unit_strict' => true,
// 'php_unit_test_class_requires_covers' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'phpdoc_types_order' => true,
'protected_to_private' => true,
'return_type_declaration' => true,
'self_accessor' => true,
// 'semicolon_after_instruction' => false,
'semicolon_after_instruction' => true,
'short_scalar_cast' => true,
'single_line_comment_style' => true,
Expand Down Expand Up @@ -120,6 +118,7 @@
->in(__DIR__);

return (new Config())
->setParallelConfig(ParallelConfigFactory::detect())
->setFinder($finder)
->setRules($rules)
->setRiskyAllowed(true)
Expand Down
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function __construct(array $config = [])
$stack = new HandlerStack(Utils::chooseHandler());

$stack->push(new ErrorHandler(), 'http_errors');
$stack->push(Middleware::redirect(), 'allow_redirects');
$stack->push(Middleware::prepareBody(), 'prepare_body');

if (isset($config['apiKey'])) {
Expand All @@ -78,7 +79,6 @@ public function __construct(array $config = [])
$config['baseUrl'] = self::BASE_HOST;
}

$stack->push(Middleware::redirect(), 'allow_redirects');
$stack->push(
new BaseUri(
$this->createUri($config['baseUrl']),
Expand Down
62 changes: 43 additions & 19 deletions src/Middleware/BaseUri.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Closure;
use GuzzleHttp\Psr7\Uri;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Rebilly\Sdk\Client;

final class BaseUri
Expand All @@ -27,27 +28,50 @@ public function __construct(private ?Uri $uri = null, private ?string $organizat
public function __invoke(callable $next): Closure
{
return function (RequestInterface $request, array $options) use ($next) {
if ($request->getHeaderLine('Host') === '') {
$uri = $this->uri;
$basePath = $uri->getPath();
$requestPath = $request->getUri()->getPath();
if (
str_starts_with($requestPath, Client::EXPERIMENTAL_BASE)
&& !str_ends_with(rtrim($basePath, '/'), ltrim(Client::EXPERIMENTAL_BASE, '/'))
) {
$basePath .= Client::EXPERIMENTAL_BASE;
$requestPath = mb_substr($requestPath, mb_strlen(Client::EXPERIMENTAL_BASE));
}
$basePath .= '/';
if ($this->organizationId) {
$basePath .= 'organizations/' . $this->organizationId . '/';
}
$uri = $uri->withPath($basePath . ltrim($requestPath, '/'));
$uri = $uri->withQuery($request->getUri()->getQuery());
$request = $request->withUri($uri);
if ($request->getHeaderLine('Host') !== '') {
return $next($request, $options);
}
$newPath = $this->adjustUriPath($request->getUri()->getPath());
$request = $request->withUri(
$this->uri->withPath($newPath)
->withQuery($request->getUri()->getQuery()),
);

return $next($request, $options);
return $next($request, $options)->then(
function (ResponseInterface $response) {
if ($response->getHeaderLine('Location') === '') {
return $response;
}
$locationUri = new Uri($response->getHeaderLine('Location'));
$newPath = $this->adjustUriPath($locationUri->getPath());

return $response->withHeader(
'Location',
$this->uri->withPath($newPath)
->withQuery($locationUri->getQuery())
->__toString(),
);
},
);
};
}

private function adjustUriPath(string $requestPath): string
{
$basePath = $this->uri->getPath();

if (
str_starts_with($requestPath, Client::EXPERIMENTAL_BASE)
&& !str_ends_with(rtrim($basePath, '/'), ltrim(Client::EXPERIMENTAL_BASE, '/'))
) {
$basePath .= Client::EXPERIMENTAL_BASE;
$requestPath = mb_substr($requestPath, mb_strlen(Client::EXPERIMENTAL_BASE));
}
$basePath .= '/';
if ($this->organizationId) {
$basePath .= 'organizations/' . $this->organizationId . '/';
}

return $basePath . ltrim($requestPath, '/');
}
}
2 changes: 2 additions & 0 deletions src/Model/Dispute.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class Dispute implements JsonSerializable

public const TYPE_PAYPAL_CLAIM = 'paypal-claim';

public const TYPE_REPRESENTMENT = 'representment';

public const STATUS_RESPONSE_NEEDED = 'response-needed';

public const STATUS_UNDER_REVIEW = 'under-review';
Expand Down
6 changes: 6 additions & 0 deletions src/Model/GatewayAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ abstract class GatewayAccount implements JsonSerializable

public const GATEWAY_NAME_MONERIS = 'Moneris';

public const GATEWAY_NAME_MONOLO = 'Monolo';

public const GATEWAY_NAME_MTA_PAY = 'MtaPay';

public const GATEWAY_NAME_MUCH_BETTER = 'MuchBetter';
Expand Down Expand Up @@ -630,6 +632,8 @@ abstract class GatewayAccount implements JsonSerializable

public const ACQUIRER_NAME_MONERIS = 'Moneris';

public const ACQUIRER_NAME_MONOLO = 'Monolo';

public const ACQUIRER_NAME_MUCH_BETTER = 'MuchBetter';

public const ACQUIRER_NAME_MUCH_BETTER_GATEWAY = 'MuchBetterGateway';
Expand Down Expand Up @@ -1548,6 +1552,8 @@ public static function from(array $data = []): self
return MobilePay::from($data);
case 'Moneris':
return Moneris::from($data);
case 'Monolo':
return Monolo::from($data);
case 'MtaPay':
return MtaPay::from($data);
case 'MuchBetter':
Expand Down
2 changes: 2 additions & 0 deletions src/Model/GetPayoutRequestPaymentInstrumentsResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ class GetPayoutRequestPaymentInstrumentsResponse implements JsonSerializable

public const GATEWAY_NAME_MONERIS = 'Moneris';

public const GATEWAY_NAME_MONOLO = 'Monolo';

public const GATEWAY_NAME_MTA_PAY = 'MtaPay';

public const GATEWAY_NAME_MUCH_BETTER = 'MuchBetter';
Expand Down
18 changes: 18 additions & 0 deletions src/Model/KycIdentityMatches.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ public function __construct(array $data = [])
if (array_key_exists('isTampered', $data)) {
$this->setIsTampered($data['isTampered']);
}
if (array_key_exists('hasCompletedFaceLiveness', $data)) {
$this->setHasCompletedFaceLiveness($data['hasCompletedFaceLiveness']);
}
if (array_key_exists('expiryDate', $data)) {
$this->setExpiryDate($data['expiryDate']);
}
Expand Down Expand Up @@ -342,6 +345,11 @@ public function setIsTampered(null|bool $isTampered): static
return $this;
}

public function getHasCompletedFaceLiveness(): ?bool
{
return $this->fields['hasCompletedFaceLiveness'] ?? null;
}

public function getExpiryDate(): ?DateTimeImmutable
{
return $this->fields['expiryDate'] ?? null;
Expand Down Expand Up @@ -412,6 +420,9 @@ public function jsonSerialize(): array
if (array_key_exists('isTampered', $this->fields)) {
$data['isTampered'] = $this->fields['isTampered'];
}
if (array_key_exists('hasCompletedFaceLiveness', $this->fields)) {
$data['hasCompletedFaceLiveness'] = $this->fields['hasCompletedFaceLiveness'];
}
if (array_key_exists('expiryDate', $this->fields)) {
$data['expiryDate'] = $this->fields['expiryDate']?->format(DateTimeInterface::RFC3339);
}
Expand All @@ -435,4 +446,11 @@ private function setHasMinimalAge(null|bool $hasMinimalAge): static

return $this;
}

private function setHasCompletedFaceLiveness(null|bool $hasCompletedFaceLiveness): static
{
$this->fields['hasCompletedFaceLiveness'] = $hasCompletedFaceLiveness;

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

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

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

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

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

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

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

return $this;
}

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

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

0 comments on commit ff8d621

Please sign in to comment.