Skip to content

Commit

Permalink
fix return types
Browse files Browse the repository at this point in the history
  • Loading branch information
xHeaven committed Oct 11, 2023
1 parent 33a37a9 commit b9f7bcc
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions src/Ugyfelkartya.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
namespace HelixdigitalIo\NetlientUgyfelkartya;

use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use HelixdigitalIo\NetlientUgyfelkartya\DataTransferObjects\Card as CardDto;
use HelixdigitalIo\NetlientUgyfelkartya\DataTransferObjects\Client\ClientDelete as ClientDeleteDto;
use HelixdigitalIo\NetlientUgyfelkartya\DataTransferObjects\ClientInfo as ClientInfoDto;
use HelixdigitalIo\NetlientUgyfelkartya\DataTransferObjects\Registration as RegistrationDto;
use HelixdigitalIo\NetlientUgyfelkartya\Traits\IsSuccessfulResponse;
use HelixdigitalIo\NetlientUgyfelkartya\Traits\SetErrorData;
use JsonException;

class Ugyfelkartya
{
Expand All @@ -34,14 +36,19 @@ public function __construct() {
]);
}

/**
* @return $this|RegistrationDto
* @throws GuzzleException
* @throws JsonException
*/
public function register(
int $storeId,
string $email,
string $firstName,
string $lastName,
?string $birthDate,
?string $zipCode
): ?RegistrationDto
)
{
$body = [
'store_id' => $storeId,
Expand All @@ -67,39 +74,54 @@ public function register(
$response = $this->parseResponse($jsonResponse);

if ($response === null) {
return null;
return $this;
}

return new RegistrationDto($response);
}

public function getClientInfo(string $email): ?ClientInfoDto
/**
* @return $this|ClientInfoDto
* @throws GuzzleException
* @throws JsonException
*/
public function getClientInfo(string $email)
{
$jsonResponse = (string)($this->client->get("clientinfo?email={$email}")->getBody());

$response = $this->parseResponse($jsonResponse);

if ($response === null) {
return null;
return $this;
}

return new ClientInfoDto($response);
}

public function getCard(string $cardNumber): ?CardDto
/**
* @return $this|CardDto
* @throws GuzzleException
* @throws JsonException
*/
public function getCard(string $cardNumber)
{
$jsonResponse = (string)($this->client->get("card/{$cardNumber}")->getBody());

$response = $this->parseResponse($jsonResponse);

if ($response === null) {
return null;
return $this;
}

return new CardDto($response);
}

public function deleteClient(int $clientId, int $storeId): ?ClientDeleteDto
/**
* @return $this|ClientDeleteDto
* @throws GuzzleException
* @throws JsonException
*/
public function deleteClient(int $clientId, int $storeId)
{
$jsonResponse = (string)($this->client->post('client/delete', [
'json' => [
Expand All @@ -111,7 +133,7 @@ public function deleteClient(int $clientId, int $storeId): ?ClientDeleteDto
$response = $this->parseResponse($jsonResponse);

if ($response === null) {
return null;
return $this;
}

return new ClientDeleteDto($response);
Expand Down

0 comments on commit b9f7bcc

Please sign in to comment.