Skip to content

Commit

Permalink
implemented other methods
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed May 14, 2019
1 parent bd33058 commit 5fcd50e
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 17 deletions.
75 changes: 66 additions & 9 deletions src/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Setono\GLS\Webservice\Response\Response;
use SoapClient;
use SoapFault;
use RuntimeException;

final class Client implements ClientInterface
{
Expand All @@ -23,9 +22,27 @@ public function __construct(SoapClient $soapClient)
$this->soapClient = $soapClient;
}

public function getAllParcelShops(string $countryIso): array
public function getAllParcelShops(string $countryCode): array
{
throw new RuntimeException('Method not implemented. Please do so in a pull request on GitHub ;)');
$response = $this->sendRequest('GetAllParcelShops', [
'countryIso3166A2' => $countryCode,
]);

$parcelShops = [];

if (200 !== $response->getStatusCode()) {
return $parcelShops;
}

if (null === $response->getResult()) {
return $parcelShops;
}

foreach ($response->getResult()->GetAllParcelShopsResult->PakkeshopData as $parcelShop) {
$parcelShops[] = ParcelShop::createFromStdClass($parcelShop);
}

return $parcelShops;
}

public function getOneParcelShop(string $parcelShopNumber): ParcelShop
Expand All @@ -42,22 +59,62 @@ public function getOneParcelShop(string $parcelShopNumber): ParcelShop
return ParcelShop::createFromStdClass($response->getResult()->GetOneParcelShopResult);
}

public function getParcelShopDropPoint(string $street, string $zipCode, string $countryIso, int $amount): array
public function getParcelShopDropPoint(string $street, string $zipCode, string $countryCode, int $amount): array
{
throw new RuntimeException('Method not implemented. Please do so in a pull request on GitHub ;)');
$response = $this->sendRequest('GetParcelShopDropPoint', [
'street' => $street,
'zipcode' => $zipCode,
'countryIso3166A2' => $countryCode,
'Amount' => $amount,
]);

$parcelShops = [];

if (200 !== $response->getStatusCode()) {
return $parcelShops;
}

if (null === $response->getResult()) {
return $parcelShops;
}

foreach ($response->getResult()->GetParcelShopDropPointResult->parcelshops->PakkeshopData as $parcelShop) {
$parcelShops[] = ParcelShop::createFromStdClass($parcelShop);
}

return $parcelShops;
}

public function getParcelShopsInZipCode(string $zipCode, string $countryIso): array
public function getParcelShopsInZipCode(string $zipCode, string $countryCode): array
{
throw new RuntimeException('Method not implemented. Please do so in a pull request on GitHub ;)');
$response = $this->sendRequest('GetParcelShopsInZipCode', [
'zipcode' => $zipCode,
'countryIso3166A2' => $countryCode,
]);

$parcelShops = [];

if (200 !== $response->getStatusCode()) {
return $parcelShops;
}

if (null === $response->getResult()) {
return $parcelShops;
}

foreach ($response->getResult()->GetParcelShopsInZipcodeResult->PakkeshopData as $parcelShop) {
$parcelShops[] = ParcelShop::createFromStdClass($parcelShop);
}

return $parcelShops;
}

public function searchNearestParcelShops(string $street, string $zipCode, string $countryIso, int $amount = 10): array
public function searchNearestParcelShops(string $street, string $zipCode, string $countryCode, int $amount = 10): array
{
$response = $this->sendRequest('SearchNearestParcelShops', [
'street' => $street,
'zipcode' => $zipCode,
'countryIso3166A2' => $countryIso,
'countryIso3166A2' => $countryCode,
'Amount' => $amount,
]);

Expand Down
16 changes: 8 additions & 8 deletions src/Client/ClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ interface ClientInterface
/**
* Returns all ParcelShops in a given country.
*
* @param string $countryIso The alpha 2 country code (https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)
* @param string $countryCode The alpha 2 country code (https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)
*
* @return ParcelShop[]
*/
public function getAllParcelShops(string $countryIso): array;
public function getAllParcelShops(string $countryCode): array;

/**
* Get one ParcelShop.
Expand All @@ -37,22 +37,22 @@ public function getOneParcelShop(string $parcelShopNumber): ParcelShop;
*
* @param string $street
* @param string $zipCode
* @param string $countryIso The alpha 2 country code (https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)
* @param string $countryCode The alpha 2 country code (https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)
* @param int $amount
*
* @return ParcelShop[]
*/
public function getParcelShopDropPoint(string $street, string $zipCode, string $countryIso, int $amount): array;
public function getParcelShopDropPoint(string $street, string $zipCode, string $countryCode, int $amount): array;

/**
* Returns all ParcelShops in a zip code - or the 3 nearest in other zip codes.
*
* @param string $zipCode
* @param string $countryIso The alpha 2 country code (https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)
* @param string $countryCode The alpha 2 country code (https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)
*
* @return ParcelShop[]
*/
public function getParcelShopsInZipCode(string $zipCode, string $countryIso): array;
public function getParcelShopsInZipCode(string $zipCode, string $countryCode): array;

/**
* Search for nearest ParcelShops to an address.
Expand All @@ -62,10 +62,10 @@ public function getParcelShopsInZipCode(string $zipCode, string $countryIso): ar
*
* @param string $street
* @param string $zipCode
* @param string $countryIso
* @param string $countryCode
* @param int $amount
*
* @return ParcelShop[]
*/
public function searchNearestParcelShops(string $street, string $zipCode, string $countryIso, int $amount): array;
public function searchNearestParcelShops(string $street, string $zipCode, string $countryCode, int $amount): array;
}

0 comments on commit 5fcd50e

Please sign in to comment.