Skip to content

Commit

Permalink
Merge pull request #21 from logeecom/release/2.0.1
Browse files Browse the repository at this point in the history
Release/2.0.1
  • Loading branch information
afidalgomoran82 authored Mar 30, 2020
2 parents 19f1659 + 23cacf2 commit 61b75af
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 13 deletions.
21 changes: 11 additions & 10 deletions src/BusinessLogic/Country/CountryService.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
/** @noinspection LongLine */

namespace Packlink\BusinessLogic\Country;

Expand Down Expand Up @@ -40,13 +41,13 @@ class CountryService extends BaseService
'name' => 'Germany',
'code' => 'DE',
'postal_code' => '10115',
'registration_link' => 'https://auth.packlink.com/de-DE/{system_name}/registro?platform=PRO&platform_country=DE',
'registration_link' => 'https://auth.packlink.com/de-DE/{system_name}/registrieren?platform=PRO&platform_country=DE',
),
'FR' => array(
'name' => 'France',
'code' => 'FR',
'postal_code' => '75001',
'registration_link' => 'https://auth.packlink.com/fr-FR/{system_name}/registro?platform=PRO&platform_country=FR',
'registration_link' => 'https://auth.packlink.com/fr-FR/{system_name}/inscription?platform=PRO&platform_country=FR',
),
'IT' => array(
'name' => 'Italy',
Expand All @@ -64,37 +65,37 @@ class CountryService extends BaseService
'name' => 'Netherlands',
'code' => 'NL',
'postal_code' => '1011',
'registration_link' => 'https://auth.packlink.com/nl-NL/{system_name}/registro?platform=PRO&platform_country=UN',
'registration_link' => 'https://auth.packlink.com/nl-NL/{system_name}/registrieren?platform=PRO&platform_country=UN',
),
'BE' => array(
'name' => 'Belgium',
'code' => 'BE',
'postal_code' => '1000',
'registration_link' => 'https://auth.packlink.com/en-GB/{system_name}/registro?platform=PRO&platform_country=UN',
'registration_link' => 'https://auth.packlink.com/nl-NL/{system_name}/registrieren?platform=PRO&platform_country=UN',
),
'PT' => array(
'name' => 'Portugal',
'code' => 'PT',
'postal_code' => '1000-017',
'registration_link' => 'https://auth.packlink.com/pt-PT/{system_name}/registro?platform=PRO&platform_country=UN',
'registration_link' => 'https://auth.packlink.com/pt-PT/{system_name}/registo?platform=PRO&platform_country=UN',
),
'TR' => array(
'name' => 'Turkey',
'code' => 'TR',
'postal_code' => '06010',
'registration_link' => 'https://auth.packlink.com/tr-TR/{system_name}/registro?platform=PRO&platform_country=UN',
'registration_link' => 'https://auth.packlink.com/tr-TR/{system_name}/kayıt-yap?platform=PRO&platform_country=UN',
),
'IE' => array(
'name' => 'Ireland',
'code' => 'IE',
'postal_code' => 'D1',
'registration_link' => 'https://auth.packlink.com/en-GB/{system_name}/registro?platform=PRO&platform_country=UN',
'registration_link' => 'https://auth.packlink.com/en-GB/{system_name}/register?platform=PRO&platform_country=UN',
),
'GB' => array(
'name' => 'United Kingdom',
'code' => 'GB',
'postal_code' => 'E1 6AN',
'registration_link' => 'https://auth.packlink.com/en-GB/{system_name}/registro?platform=PRO&platform_country=UN',
'registration_link' => 'https://auth.packlink.com/en-GB/{system_name}/register?platform=PRO&platform_country=UN',
),
);

Expand All @@ -107,7 +108,7 @@ class CountryService extends BaseService
*/
public function isCountrySupported($isoCode)
{
return array_key_exists($isoCode, self::$supportedCountries);
return array_key_exists($isoCode, static::$supportedCountries);
}

/**
Expand All @@ -123,7 +124,7 @@ public function getSupportedCountries()
$countries = array();
$configuration = ServiceRegister::getService(Configuration::CLASS_NAME);

foreach (self::$supportedCountries as $country) {
foreach (static::$supportedCountries as $country) {
$integration = strtolower($configuration->getIntegrationName());
$country['registration_link'] = str_replace(
'{system_name}',
Expand Down
7 changes: 7 additions & 0 deletions src/BusinessLogic/Tasks/SendDraftTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public function unserialize($serialized)
* @throws \Logeecom\Infrastructure\Http\Exceptions\HttpRequestException
* @throws \Packlink\BusinessLogic\Http\Exceptions\DraftNotCreatedException
* @throws \Packlink\BusinessLogic\Order\Exceptions\OrderNotFound
* @throws \Packlink\BusinessLogic\OrderShipmentDetails\Exceptions\OrderShipmentDetailsNotFound
*/
public function execute()
{
Expand All @@ -134,6 +135,12 @@ public function execute()
$this->reportProgress(85);

$this->getOrderService()->setReference($this->orderId, $reference);
$shipment = $this->getProxy()->getShipment($reference);

if ($shipment) {
$this->getOrderService()->updateShipmentData($shipment);
}

$this->reportProgress(100);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/BusinessLogic/Common/ApiResponses/draftResponse.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"reference": "DE00019732CF"
"reference": "test"
}
4 changes: 4 additions & 0 deletions tests/BusinessLogic/Order/ShipmentDraftServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ private function getMockResponses()
new HttpResponse(
200, array(), '{}'
),
// send shipment response
new HttpResponse(
200, array(), file_get_contents(__DIR__ . '/../Common/ApiResponses/shipment.json')
),
);
}
}
12 changes: 10 additions & 2 deletions tests/BusinessLogic/Tasks/SendDraftTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Packlink\BusinessLogic\ShippingMethod\Models\ShippingMethod;
use Packlink\BusinessLogic\ShippingMethod\PackageTransformer;
use Packlink\BusinessLogic\ShippingMethod\ShippingMethodService;
use Packlink\BusinessLogic\ShippingMethod\Utility\ShipmentStatus;
use Packlink\BusinessLogic\Tasks\SendDraftTask;

/**
Expand Down Expand Up @@ -134,6 +135,7 @@ protected function tearDown()
* @throws \Logeecom\Infrastructure\Http\Exceptions\HttpRequestException
* @throws \Packlink\BusinessLogic\Order\Exceptions\OrderNotFound
* @throws \Packlink\BusinessLogic\Http\Exceptions\DraftNotCreatedException
* @throws \Packlink\BusinessLogic\OrderShipmentDetails\Exceptions\OrderShipmentDetailsNotFound
*/
public function testExecute()
{
Expand All @@ -144,9 +146,11 @@ public function testExecute()
$shopOrderService = TestServiceRegister::getService(OrderShipmentDetailsService::CLASS_NAME);
$shipmentDetails = $shopOrderService->getDetailsByOrderId('test');

$this->assertEquals('DE00019732CF', $shipmentDetails->getReference());
$this->assertEquals('test', $shipmentDetails->getReference());
$this->assertEquals(15.85, $shipmentDetails->getShippingCost());
$this->assertEquals(ShipmentStatus::STATUS_PENDING, ShipmentStatus::getStatus($shipmentDetails->getStatus()));
// there should be an info message that draft is created.
$this->assertCount(1, $this->shopLogger->loggedMessages);
$this->assertCount(2, $this->shopLogger->loggedMessages);

/** @var OrderSendDraftTaskMapService $taskMapService */
$taskMapService = ServiceRegister::getService(OrderSendDraftTaskMapService::CLASS_NAME);
Expand Down Expand Up @@ -209,6 +213,10 @@ private function getMockResponses()
new HttpResponse(
200, array(), '{}'
),
// send shipment response
new HttpResponse(
200, array(), file_get_contents(__DIR__ . '/../Common/ApiResponses/shipment.json')
),
);
}
}

0 comments on commit 61b75af

Please sign in to comment.