Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ging-dev committed Jul 4, 2024
1 parent 74b2329 commit f301d4f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
11 changes: 3 additions & 8 deletions src/Api/AbstractApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ abstract class AbstractApi
* @param T $session
*/
public function __construct(
private IPayClient $client,
private SessionInterface $session,
protected IPayClient $iPayClient,
protected SessionInterface $session,
) {
$this->objectMapper = new ObjectMapperUsingReflection(
new ReflectionDefinitionProvider(
Expand All @@ -37,7 +37,7 @@ public function __construct(
*/
protected function post(string $uri, array $data = []): array
{
$response = $this->client->getClient()->post(
$response = $this->iPayClient->getClient()->post(
$uri,
[],
BodyBuilder::from($data)
Expand All @@ -54,11 +54,6 @@ public function getObjectMapper(): ObjectMapper
return $this->objectMapper;
}

public function getClient(): IPayClient
{
return $this->client;
}

/**
* @return T
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Api/UnauthenticatedApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function login(
$result = $this->post('/signIn', get_defined_vars());

return new AuthenticatedApi(
$this->getClient(),
$this->iPayClient,
new AuthenticatedSession($result['sessionId'])
);
}
Expand Down
10 changes: 4 additions & 6 deletions src/Encryption/Encrypter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ public static function encrypt(string $message): string
$mlen = strlen($message);

$result = '';
foreach (
str_split(
$message,
(int) ceil($mlen / ceil($mlen / 86))
) as $part
) {
foreach (str_split(
$message,
(int) ceil($mlen / ceil($mlen / 86))
) as $part) {
openssl_public_encrypt(
$part,
$part,
Expand Down
9 changes: 8 additions & 1 deletion src/IPayClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use Http\Client\Common\PluginClient;
use Http\Discovery\Psr17FactoryDiscovery;
use Http\Discovery\Psr18ClientDiscovery;
use IPay\Api\AuthenticatedApi;
use IPay\Api\AuthenticatedSession;
use IPay\Api\UnauthenticatedApi;
use IPay\Api\UnauthenticatedSession;
use IPay\Http\Plugin\ExceptionThrower;
Expand Down Expand Up @@ -42,8 +44,13 @@ public function getClient(): HttpMethodsClientInterface
return $this->client;
}

public function unauthenticated(): UnauthenticatedApi
public function guest(): UnauthenticatedApi
{
return new UnauthenticatedApi($this, new UnauthenticatedSession());
}

public function session(string $id): AuthenticatedApi
{
return new AuthenticatedApi($this, new AuthenticatedSession($id));
}
}

0 comments on commit f301d4f

Please sign in to comment.