first commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Exception;
|
||||
|
||||
class AccessForbiddenException extends ShipXException
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Exception;
|
||||
|
||||
class ResourceNotFoundException extends ShipXException
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Exception;
|
||||
|
||||
use Exception;
|
||||
|
||||
class ShipXException extends Exception
|
||||
{
|
||||
protected $details;
|
||||
|
||||
public function __construct($responseContents, Exception $previous = null)
|
||||
{
|
||||
parent::__construct($responseContents['message'], 0, $previous);
|
||||
|
||||
$this->details = $responseContents['details'];
|
||||
}
|
||||
|
||||
public function getDetails()
|
||||
{
|
||||
return $this->details;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Exception;
|
||||
|
||||
class TokenInvalidException extends ShipXException
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Exception;
|
||||
|
||||
use Exception;
|
||||
|
||||
class ValidationFailedException extends ShipXException
|
||||
{
|
||||
protected $validationErrors = [];
|
||||
|
||||
public function __construct($responseContents, Exception $previous = null)
|
||||
{
|
||||
parent::__construct($responseContents, $previous);
|
||||
|
||||
if (is_array($errors = $this->getDetails())) {
|
||||
$this->walkErrors($errors);
|
||||
}
|
||||
}
|
||||
|
||||
protected function walkErrors($errors, $fieldName = '')
|
||||
{
|
||||
foreach ($errors as $key => $error) {
|
||||
if (is_int($key)) {
|
||||
if (is_array($error)) {
|
||||
$this->walkErrors($error, $fieldName);
|
||||
} else {
|
||||
$this->validationErrors[$fieldName][] = $error;
|
||||
}
|
||||
} else {
|
||||
$newName = $fieldName ? "{$fieldName}->{$key}" : $key;
|
||||
|
||||
if (is_array($error)) {
|
||||
$this->walkErrors($error, $newName);
|
||||
} else {
|
||||
$this->validationErrors[$newName][] = $error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getValidationErrors()
|
||||
{
|
||||
return $this->validationErrors;
|
||||
}
|
||||
}
|
||||
32
modules/inpostshipping/src/ShipX/Exception/index.php
Normal file
32
modules/inpostshipping/src/ShipX/Exception/index.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\RequestFactory;
|
||||
|
||||
class AuthorizedRequestFactory extends ShipXRequestFactory
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createRequest($method, $path, array $options = [])
|
||||
{
|
||||
return parent::createRequest($method, $path, $options)
|
||||
->setHeaders([
|
||||
'Authorization' => 'Bearer ' . $this->configuration->getApiToken(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\RequestFactory;
|
||||
|
||||
class OrganizationRequestFactory extends AuthorizedRequestFactory
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createRequest($method, $path, array $options = [])
|
||||
{
|
||||
return parent::createRequest($method, $path, $options)
|
||||
->setPathParams([
|
||||
'organization_id' => $this->configuration->getOrganizationId(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\RequestFactory;
|
||||
|
||||
use Context;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Query;
|
||||
use InPost\Shipping\Api\RequestFactoryInterface;
|
||||
use InPost\Shipping\Configuration\ShipXConfiguration;
|
||||
use InPost\Shipping\ShipX\ShipXRequest;
|
||||
use Tools;
|
||||
|
||||
class ShipXRequestFactory implements RequestFactoryInterface
|
||||
{
|
||||
const LIVE_URL = 'https://api-shipx-pl.easypack24.net';
|
||||
const SANDBOX_URL = 'https://sandbox-api-shipx-pl.easypack24.net';
|
||||
|
||||
const ALLOWED_LANGUAGES = [
|
||||
'pl_PL',
|
||||
'en_GB',
|
||||
'keys',
|
||||
];
|
||||
|
||||
protected $configuration;
|
||||
|
||||
protected $language;
|
||||
|
||||
public function __construct(ShipXConfiguration $configuration)
|
||||
{
|
||||
$this->configuration = $configuration;
|
||||
|
||||
$language = Tools::strtolower(Context::getContext()->language->iso_code) === 'pl'
|
||||
? 'pl_PL'
|
||||
: 'en_GB';
|
||||
|
||||
$this->setLanguage($language);
|
||||
}
|
||||
|
||||
protected function getBaseUrl()
|
||||
{
|
||||
return $this->configuration->useSandboxMode()
|
||||
? self::SANDBOX_URL
|
||||
: self::LIVE_URL;
|
||||
}
|
||||
|
||||
public function setLanguage($language)
|
||||
{
|
||||
if (in_array($language, self::ALLOWED_LANGUAGES)) {
|
||||
$this->language = $language;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createRequest($method, $path, array $options = [])
|
||||
{
|
||||
$client = new Client([
|
||||
'base_url' => $this->getBaseUrl(),
|
||||
]);
|
||||
|
||||
return (new ShipXRequest($client))
|
||||
->setOptions($options)
|
||||
->setMethod($method)
|
||||
->setPath($path)
|
||||
->setQueryAggregator(Query::phpAggregator(false))
|
||||
->setHeaders([
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept-Language' => $this->language,
|
||||
]);
|
||||
}
|
||||
}
|
||||
32
modules/inpostshipping/src/ShipX/RequestFactory/index.php
Normal file
32
modules/inpostshipping/src/ShipX/RequestFactory/index.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
39
modules/inpostshipping/src/ShipX/Resource/Address.php
Normal file
39
modules/inpostshipping/src/ShipX/Resource/Address.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Resource;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $line1
|
||||
* @property string $line2
|
||||
* @property string $street
|
||||
* @property string $building_number
|
||||
* @property string $city
|
||||
* @property string $post_code
|
||||
* @property string $country_code
|
||||
*/
|
||||
class Address extends ShipXResource
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Resource;
|
||||
|
||||
use InPostShipping;
|
||||
use Module;
|
||||
|
||||
abstract class AuthorizedResource extends ShipXResource
|
||||
{
|
||||
public function getRequestFactory()
|
||||
{
|
||||
/** @var InPostShipping $module */
|
||||
$module = Module::getInstanceByName('inpostshipping');
|
||||
|
||||
return $module->getService('inpost.shipping.shipx.factory.authorized_request');
|
||||
}
|
||||
}
|
||||
54
modules/inpostshipping/src/ShipX/Resource/Organization.php
Normal file
54
modules/inpostshipping/src/ShipX/Resource/Organization.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Resource;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use InPost\Shipping\Api\Resource\Traits\GetTrait;
|
||||
use InPost\Shipping\ShipX\Resource\Traits\GetCollectionTrait;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property int $owner_id
|
||||
* @property string $name
|
||||
* @property string $tax_id
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
* @property string[] $services
|
||||
* @property string $bank_account_number
|
||||
* @property Address $address
|
||||
*/
|
||||
class Organization extends AuthorizedResource
|
||||
{
|
||||
use GetCollectionTrait;
|
||||
use GetTrait;
|
||||
|
||||
const BASE_PATH = '/v1/organizations';
|
||||
|
||||
protected static $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'address' => Address::class,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Resource\Organization;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use InPost\Shipping\Api\Resource\Traits\CreateTrait;
|
||||
use InPost\Shipping\Api\Resource\Traits\DeleteTrait;
|
||||
use InPost\Shipping\Api\Resource\Traits\GetTrait;
|
||||
use InPost\Shipping\Api\Resource\Traits\UpdateTrait;
|
||||
use InPost\Shipping\ShipX\Resource\Address;
|
||||
use InPost\Shipping\ShipX\Resource\Traits\GetCollectionTrait;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $status
|
||||
* @property Carbon $created_at
|
||||
* @property Address $address
|
||||
* @property array $shipments
|
||||
* @property string $comment
|
||||
* @property float|null $price
|
||||
* @property int $external_id
|
||||
*/
|
||||
class DispatchOrder extends OrganizationResource
|
||||
{
|
||||
use GetCollectionTrait;
|
||||
use GetTrait;
|
||||
use CreateTrait;
|
||||
use UpdateTrait;
|
||||
use DeleteTrait;
|
||||
|
||||
const BASE_PATH = '/v1/organizations/{organization_id}/dispatch_orders';
|
||||
|
||||
protected static $casts = [
|
||||
'created_at' => 'datetime',
|
||||
'address' => Address::class,
|
||||
];
|
||||
|
||||
public static function getPrintout($id, array $options = [])
|
||||
{
|
||||
$query = [
|
||||
'dispatch_order_id' => $id,
|
||||
];
|
||||
|
||||
return self::getPrintouts($query, $options);
|
||||
}
|
||||
|
||||
public static function getPrintoutsByShipmentIds(array $shipmentIds, array $options = [])
|
||||
{
|
||||
$query = [
|
||||
'shipment_ids' => $shipmentIds,
|
||||
];
|
||||
|
||||
return self::getPrintouts($query, $options);
|
||||
}
|
||||
|
||||
protected static function getPrintouts(array $queryParams, array $options)
|
||||
{
|
||||
$path = self::BASE_PATH . '/printouts';
|
||||
|
||||
return self::cast([])
|
||||
->getRequestFactory()
|
||||
->createRequest('GET', $path, $options)
|
||||
->setQueryParams($queryParams)
|
||||
->send();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Resource\Organization;
|
||||
|
||||
use InPost\Shipping\Api\Resource\Traits\GetTrait;
|
||||
use InPost\Shipping\ShipX\Resource\Address;
|
||||
use InPost\Shipping\ShipX\Resource\Traits\GetCollectionTrait;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $office_hours
|
||||
* @property string $phone
|
||||
* @property string $email
|
||||
* @property string $comments
|
||||
* @property Address $address
|
||||
* @property string $status
|
||||
*/
|
||||
class DispatchPoint extends OrganizationResource
|
||||
{
|
||||
use GetCollectionTrait;
|
||||
use GetTrait;
|
||||
|
||||
const BASE_PATH = '/v1/organizations/{organization_id}/dispatch_points';
|
||||
|
||||
protected static $casts = [
|
||||
'address' => Address::class,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Resource\Organization;
|
||||
|
||||
use InPost\Shipping\ShipX\Resource\ShipXResource;
|
||||
use InPostShipping;
|
||||
use Module;
|
||||
|
||||
abstract class OrganizationResource extends ShipXResource
|
||||
{
|
||||
public function getRequestFactory()
|
||||
{
|
||||
/** @var InPostShipping $module */
|
||||
$module = Module::getInstanceByName('inpostshipping');
|
||||
|
||||
return $module->getService('inpost.shipping.shipx.factory.organization_request');
|
||||
}
|
||||
|
||||
public static function getResourcePath()
|
||||
{
|
||||
$basePath = str_replace('organizations/{organization_id}/', '', static::BASE_PATH);
|
||||
|
||||
return rtrim($basePath, '/') . '/{' . static::getIdField() . '}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Resource\Organization;
|
||||
|
||||
use InPost\Shipping\Api\Resource\Traits\CreateTrait;
|
||||
use InPost\Shipping\Api\Resource\Traits\DeleteTrait;
|
||||
use InPost\Shipping\Api\Resource\Traits\GetTrait;
|
||||
use InPost\Shipping\ShipX\Resource\Traits\GetCollectionTrait;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $status
|
||||
* @property array $custom_attributes
|
||||
* @property array $parcels
|
||||
* @property array $sender
|
||||
* @property array $receiver
|
||||
* @property array $cod
|
||||
* @property array $insurance
|
||||
* @property string $reference
|
||||
* @property string $comments
|
||||
* @property bool $is_return
|
||||
* @property string $service
|
||||
* @property string $tracking_number
|
||||
* @property string $sending_method
|
||||
* @property string $external_customer_id
|
||||
* @property array $offers
|
||||
* @property array $selected_offer
|
||||
* @property array $transactions
|
||||
* @property bool $end_of_week_collection
|
||||
*/
|
||||
class Shipment extends OrganizationResource
|
||||
{
|
||||
use GetCollectionTrait;
|
||||
use GetTrait;
|
||||
use CreateTrait;
|
||||
use DeleteTrait;
|
||||
|
||||
const BASE_PATH = '/v1/organizations/{organization_id}/shipments';
|
||||
|
||||
const TYPE_NORMAL = 'normal';
|
||||
const TYPE_A6 = 'A6';
|
||||
|
||||
const FORMAT_PDF = 'pdf';
|
||||
const FORMAT_EPL = 'epl';
|
||||
const FORMAT_ZPL = 'zpl';
|
||||
|
||||
const TEMPLATE_SMALL = 'small';
|
||||
const TEMPLATE_MEDIUM = 'medium';
|
||||
const TEMPLATE_LARGE = 'large';
|
||||
const TEMPLATE_EXTRA_LARGE = 'xlarge';
|
||||
const TEMPLATE_PARCEL = 'parcel';
|
||||
const TEMPLATE_PALETTE = 'palette';
|
||||
|
||||
const LABEL_FORMATS = [
|
||||
self::FORMAT_PDF,
|
||||
self::FORMAT_EPL,
|
||||
self::FORMAT_ZPL,
|
||||
];
|
||||
|
||||
const LABEL_TYPES = [
|
||||
self::TYPE_A6,
|
||||
self::TYPE_NORMAL,
|
||||
];
|
||||
|
||||
const DIMENSION_TEMPLATES = [
|
||||
self::TEMPLATE_SMALL,
|
||||
self::TEMPLATE_MEDIUM,
|
||||
self::TEMPLATE_LARGE,
|
||||
self::TEMPLATE_EXTRA_LARGE,
|
||||
self::TEMPLATE_PARCEL,
|
||||
self::TEMPLATE_PALETTE,
|
||||
];
|
||||
|
||||
public static function getLabel($id, array $options = [])
|
||||
{
|
||||
$path = self::getResourcePath() . '/label';
|
||||
|
||||
return self::cast([])
|
||||
->getRequestFactory()
|
||||
->createRequest('GET', $path, $options)
|
||||
->setPathParams([self::getIdField() => $id])
|
||||
->send();
|
||||
}
|
||||
|
||||
public static function getReturnLabel($id, array $options = [])
|
||||
{
|
||||
return self::getMultipleReturnLabels([$id], $options);
|
||||
}
|
||||
|
||||
public static function getMultipleLabels(array $ids, array $options = [])
|
||||
{
|
||||
$path = self::BASE_PATH . '/labels';
|
||||
|
||||
return self::cast([])
|
||||
->getRequestFactory()
|
||||
->createRequest('GET', $path, $options)
|
||||
->setQueryParams(['shipment_ids' => $ids])
|
||||
->send();
|
||||
}
|
||||
|
||||
public static function getMultipleReturnLabels(array $ids, array $options = [])
|
||||
{
|
||||
$path = self::BASE_PATH . '/return_labels';
|
||||
|
||||
return self::cast([])
|
||||
->getRequestFactory()
|
||||
->createRequest('GET', $path, $options)
|
||||
->setQueryParams(['shipment_ids' => $ids])
|
||||
->send();
|
||||
}
|
||||
|
||||
public static function calculatePrices(array $shipments)
|
||||
{
|
||||
$path = self::BASE_PATH . '/calculate';
|
||||
|
||||
return self::cast([])
|
||||
->getRequestFactory()
|
||||
->createRequest('POST', $path)
|
||||
->setJson(['shipments' => $shipments])
|
||||
->send()
|
||||
->json();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
84
modules/inpostshipping/src/ShipX/Resource/Point.php
Normal file
84
modules/inpostshipping/src/ShipX/Resource/Point.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Resource;
|
||||
|
||||
use InPost\Shipping\Api\Resource\Traits\GetTrait;
|
||||
use InPost\Shipping\ShipX\Resource\Traits\GetCollectionTrait;
|
||||
|
||||
/**
|
||||
* @property string $name
|
||||
* @property array $type
|
||||
* @property string $status
|
||||
* @property array $location
|
||||
* @property string $location_type
|
||||
* @property string $location_description
|
||||
* @property string $location_description_1
|
||||
* @property string $location_description_2
|
||||
* @property int|null $distance
|
||||
* @property string $opening_hours
|
||||
* @property array $address
|
||||
* @property array $address_details
|
||||
* @property string $phone_number
|
||||
* @property string $payment_point_descr
|
||||
* @property array $functions
|
||||
* @property int $partner_id
|
||||
* @property bool $is_next
|
||||
* @property bool $payment_available
|
||||
* @property array $payment_type
|
||||
* @property int $virtual
|
||||
* @property array $recommended_low_interest_box_machines_list
|
||||
* @property bool $location_247
|
||||
*/
|
||||
class Point extends ShipXResource
|
||||
{
|
||||
use GetCollectionTrait;
|
||||
use GetTrait;
|
||||
|
||||
const BASE_PATH = '/v1/points';
|
||||
|
||||
const TYPE_PARCEL_LOCKER = 'parcel_locker';
|
||||
const TYPE_POP = 'pop';
|
||||
const TYPE_PARCEL_LOCKER_ONLY = 'parcel_locker_only';
|
||||
const TYPE_PARCEL_LOCKER_SUPERPOP = 'parcel_locker_superpop';
|
||||
|
||||
const FUNCTION_PARCEL = 'parcel';
|
||||
const FUNCTION_PARCEL_COLLECT = 'parcel_collect';
|
||||
const FUNCTION_PARCEL_SEND = 'parcel_send';
|
||||
|
||||
const FUNCTIONS_SEND = [
|
||||
self::FUNCTION_PARCEL,
|
||||
self::FUNCTION_PARCEL_SEND,
|
||||
];
|
||||
|
||||
const FUNCTIONS_COLLECT = [
|
||||
self::FUNCTION_PARCEL,
|
||||
self::FUNCTION_PARCEL_COLLECT,
|
||||
];
|
||||
|
||||
public static function getIdField()
|
||||
{
|
||||
return 'name';
|
||||
}
|
||||
}
|
||||
58
modules/inpostshipping/src/ShipX/Resource/SendingMethod.php
Normal file
58
modules/inpostshipping/src/ShipX/Resource/SendingMethod.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Resource;
|
||||
|
||||
use InPost\Shipping\ShipX\Resource\Traits\GetAllTrait;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $description
|
||||
*/
|
||||
class SendingMethod extends ShipXResource
|
||||
{
|
||||
use GetAllTrait;
|
||||
|
||||
const BASE_PATH = '/v1/sending_methods';
|
||||
|
||||
const DISPATCH_ORDER = 'dispatch_order';
|
||||
const PARCEL_LOCKER = 'parcel_locker';
|
||||
const POP = 'pop';
|
||||
|
||||
const SENDING_METHODS = [
|
||||
self::PARCEL_LOCKER,
|
||||
self::DISPATCH_ORDER,
|
||||
self::POP,
|
||||
];
|
||||
|
||||
public static function getAvailable($service)
|
||||
{
|
||||
return self::getAll([
|
||||
'query' => [
|
||||
'service' => $service,
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
71
modules/inpostshipping/src/ShipX/Resource/Service.php
Normal file
71
modules/inpostshipping/src/ShipX/Resource/Service.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Resource;
|
||||
|
||||
use InPost\Shipping\ShipX\Resource\Traits\GetAllTrait;
|
||||
|
||||
/**
|
||||
* @property string $id
|
||||
* @property string $name
|
||||
* @property string $description
|
||||
* @property array $additional_services
|
||||
*/
|
||||
class Service extends ShipXResource
|
||||
{
|
||||
use GetAllTrait;
|
||||
|
||||
const BASE_PATH = '/v1/services';
|
||||
|
||||
const INPOST_LOCKER_STANDARD = 'inpost_locker_standard';
|
||||
const INPOST_COURIER_C2C = 'inpost_courier_c2c';
|
||||
const INPOST_COURIER_STANDARD = 'inpost_courier_standard';
|
||||
const INPOST_COURIER_EXPRESS_1000 = 'inpost_courier_express_1000';
|
||||
const INPOST_COURIER_EXPRESS_1200 = 'inpost_courier_express_1200';
|
||||
const INPOST_COURIER_EXPRESS_1700 = 'inpost_courier_express_1700';
|
||||
const INPOST_COURIER_LOCAL_STANDARD = 'inpost_courier_local_standard';
|
||||
const INPOST_COURIER_LOCAL_EXPRESS = 'inpost_courier_local_express';
|
||||
const INPOST_COURIER_LOCAL_SUPER_EXPRESS = 'inpost_courier_local_super_express';
|
||||
const INPOST_COURIER_PALETTE = 'inpost_courier_palette';
|
||||
|
||||
const INPOST_LOCKER_CUSTOMER_SERVICE_POINT = 'inpost_locker_customer_service_point';
|
||||
|
||||
const SERVICES = [
|
||||
self::INPOST_LOCKER_STANDARD,
|
||||
self::INPOST_COURIER_C2C,
|
||||
self::INPOST_COURIER_STANDARD,
|
||||
self::INPOST_COURIER_EXPRESS_1000,
|
||||
self::INPOST_COURIER_EXPRESS_1200,
|
||||
self::INPOST_COURIER_EXPRESS_1700,
|
||||
self::INPOST_COURIER_LOCAL_STANDARD,
|
||||
self::INPOST_COURIER_LOCAL_EXPRESS,
|
||||
self::INPOST_COURIER_LOCAL_SUPER_EXPRESS,
|
||||
self::INPOST_COURIER_PALETTE,
|
||||
];
|
||||
|
||||
const LOCKER_SERVICES = [
|
||||
self::INPOST_LOCKER_STANDARD,
|
||||
self::INPOST_COURIER_C2C,
|
||||
];
|
||||
}
|
||||
329
modules/inpostshipping/src/ShipX/Resource/ShipXCollection.php
Normal file
329
modules/inpostshipping/src/ShipX/Resource/ShipXCollection.php
Normal file
@@ -0,0 +1,329 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Resource;
|
||||
|
||||
use ArrayAccess;
|
||||
use Countable;
|
||||
use InPost\Shipping\Api\Request;
|
||||
use Iterator;
|
||||
use Validate;
|
||||
|
||||
class ShipXCollection implements Iterator, ArrayAccess, Countable
|
||||
{
|
||||
/**
|
||||
* ShipXResource class name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* Resource collection.
|
||||
*
|
||||
* @var ShipXResource[]
|
||||
*/
|
||||
protected $items = [];
|
||||
|
||||
/**
|
||||
* Collection iterator.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $iterator = 0;
|
||||
|
||||
/**
|
||||
* Number of items per page.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $itemsPerPage;
|
||||
|
||||
/**
|
||||
* Resource count.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $count;
|
||||
|
||||
/**
|
||||
* API Request object.
|
||||
*
|
||||
* @var Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* ShipXCollection constructor.
|
||||
*
|
||||
* @param string $type ShipXResource class name
|
||||
* @param array $filters collection search params
|
||||
* @param string $sortBy sort field
|
||||
* @param string $sortOrder sort order
|
||||
* @param int $itemsPerPage number of items per page
|
||||
*/
|
||||
public function __construct($type, array $filters = [], $sortBy = '', $sortOrder = '', $itemsPerPage = 0)
|
||||
{
|
||||
if (class_exists($type) && is_subclass_of($type, ShipXResource::class)) {
|
||||
$this->type = $type;
|
||||
|
||||
unset($filters['page'], $filters['per_page'], $filters['sort_by'], $filters['sort_order']);
|
||||
$queryParams = $filters;
|
||||
|
||||
$itemsPerPage = (int) $itemsPerPage;
|
||||
if ($itemsPerPage > 0) {
|
||||
$this->itemsPerPage = $itemsPerPage;
|
||||
}
|
||||
|
||||
if (!empty($sortBy)) {
|
||||
$queryParams['sort_by'] = $sortBy;
|
||||
}
|
||||
|
||||
if (Validate::isSortDirection($sortOrder)) {
|
||||
$queryParams['sort_order'] = $sortOrder;
|
||||
}
|
||||
|
||||
$this->request = $type::cast([])
|
||||
->getRequestFactory()
|
||||
->createRequest('GET', $type::getBasePath())
|
||||
->setQueryAggregator(self::commaAggregator())
|
||||
->setQueryParams($queryParams);
|
||||
} else {
|
||||
$this->count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current element.
|
||||
*
|
||||
* @see Iterator::current()
|
||||
*
|
||||
* @return ShipXResource|null
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
return isset($this[$this->iterator]) ? $this[$this->iterator] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Go to the next item.
|
||||
*
|
||||
* @see Iterator::next()
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
++$this->iterator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current item index.
|
||||
*
|
||||
* @see Iterator::key()
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
return $this->iterator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current position is valid.
|
||||
*
|
||||
* @see Iterator::valid()
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return $this->iterator < $this->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewind the iterator to the first element.
|
||||
*
|
||||
* @see Iterator::rewind()
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
$this->iterator = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a collection item with a given offset exists.
|
||||
*
|
||||
* @see ArrayAccess::offsetExists()
|
||||
*
|
||||
* @param int $offset
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return $offset >= 0 && $offset < $this->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a collection item with a given offset.
|
||||
*
|
||||
* @see ArrayAccess::offsetGet()
|
||||
*
|
||||
* @param int $offset
|
||||
*
|
||||
* @return ShipXResource|null
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
if (isset($this[$offset]) && !isset($this->items[$offset])) {
|
||||
$this->getPage($this->calculatePageNumber($offset));
|
||||
}
|
||||
|
||||
return isset($this->items[$offset]) ? $this->items[$offset] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This operation is not supported.
|
||||
*
|
||||
* @see ArrayAccess::offsetSet()
|
||||
*
|
||||
* @param int $offset
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This operation is not supported.
|
||||
*
|
||||
* @see ArrayAccess::offsetUnset()
|
||||
*
|
||||
* @param int $offset
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of items in the collection.
|
||||
*
|
||||
* @see Countable::count()
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
if (!isset($this->count)) {
|
||||
$this->getPage();
|
||||
}
|
||||
|
||||
return $this->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the page number for a given offset.
|
||||
*
|
||||
* @param int $offset
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function calculatePageNumber($offset)
|
||||
{
|
||||
if (!isset($this->itemsPerPage)) {
|
||||
$this->getPage();
|
||||
}
|
||||
|
||||
return (int) ceil(++$offset / $this->itemsPerPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a page from the API.
|
||||
*
|
||||
* @param int $pageNumber
|
||||
*/
|
||||
protected function getPage($pageNumber = 1)
|
||||
{
|
||||
$queryParams = [
|
||||
'page' => (int) $pageNumber,
|
||||
];
|
||||
|
||||
if (isset($this->itemsPerPage)) {
|
||||
$queryParams['per_page'] = $this->itemsPerPage;
|
||||
}
|
||||
|
||||
$page = $this->request
|
||||
->setQueryParams($queryParams)
|
||||
->send()
|
||||
->json();
|
||||
|
||||
if (!isset($this->itemsPerPage) || $page['per_page'] < $this->itemsPerPage) {
|
||||
$this->itemsPerPage = (int) $page['per_page'];
|
||||
}
|
||||
|
||||
if (!isset($this->count)) {
|
||||
$this->count = (int) $page['count'];
|
||||
}
|
||||
|
||||
$class = $this->type;
|
||||
$index = (int) (($pageNumber - 1) * $this->itemsPerPage);
|
||||
|
||||
foreach ($class::castMany($page['items']) as $item) {
|
||||
$this->items[$index++] = $item;
|
||||
}
|
||||
|
||||
/* ShipX sometimes returns fewer items than the declared count... */
|
||||
if (0 > $difference = $page['per_page'] - count($page['items'])) {
|
||||
$this->count -= $difference;
|
||||
}
|
||||
}
|
||||
|
||||
protected static function commaAggregator()
|
||||
{
|
||||
return function ($data) {
|
||||
return self::walkQuery($data, '', function ($key, $prefix) {
|
||||
return is_int($key) ? $prefix : "{$prefix}[{$key}]";
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
protected static function walkQuery($data, $keyPrefix, callable $prefixer)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if ($keyPrefix) {
|
||||
$key = $prefixer($key, $keyPrefix);
|
||||
}
|
||||
if (is_array($value)) {
|
||||
$result += self::walkQuery($value, $key, $prefixer);
|
||||
} elseif (isset($result[$key])) {
|
||||
$result[$key][0] .= ',' . $value;
|
||||
} else {
|
||||
$result[$key] = [$value];
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
40
modules/inpostshipping/src/ShipX/Resource/ShipXResource.php
Normal file
40
modules/inpostshipping/src/ShipX/Resource/ShipXResource.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Resource;
|
||||
|
||||
use InPost\Shipping\Api\Resource\ApiResource;
|
||||
use InPostShipping;
|
||||
use Module;
|
||||
|
||||
abstract class ShipXResource extends ApiResource
|
||||
{
|
||||
public function getRequestFactory()
|
||||
{
|
||||
/** @var InPostShipping $module */
|
||||
$module = Module::getInstanceByName('inpostshipping');
|
||||
|
||||
return $module->getService('inpost.shipping.shipx.factory.request');
|
||||
}
|
||||
}
|
||||
55
modules/inpostshipping/src/ShipX/Resource/Status.php
Normal file
55
modules/inpostshipping/src/ShipX/Resource/Status.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Resource;
|
||||
|
||||
use InPost\Shipping\ShipX\Resource\Traits\GetAllTrait;
|
||||
|
||||
/**
|
||||
* @property string $name
|
||||
* @property string $title
|
||||
* @property string $description
|
||||
*/
|
||||
class Status extends ShipXResource
|
||||
{
|
||||
use GetAllTrait;
|
||||
|
||||
const BASE_PATH = '/v1/statuses';
|
||||
|
||||
const STATUS_CONFIRMED = 'confirmed';
|
||||
const STATUS_DELIVERED = 'delivered';
|
||||
|
||||
const NOT_SENT_STATUSES = [
|
||||
'created',
|
||||
'offers_prepared',
|
||||
'offer_selected',
|
||||
self::STATUS_CONFIRMED,
|
||||
];
|
||||
|
||||
const FINAL_STATUSES = [
|
||||
'canceled',
|
||||
self::STATUS_DELIVERED,
|
||||
'not_found',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Resource\Traits;
|
||||
|
||||
use InPost\Shipping\ShipX\Resource\ShipXResource;
|
||||
|
||||
/**
|
||||
* @mixin ShipXResource
|
||||
*/
|
||||
trait GetAllTrait
|
||||
{
|
||||
/** @return static[] */
|
||||
public static function getAll(array $options = [])
|
||||
{
|
||||
$response = static::cast([])
|
||||
->getRequestFactory()
|
||||
->createRequest('GET', static::getBasePath(), $options)
|
||||
->send()
|
||||
->json();
|
||||
|
||||
$items = isset($response['items']) ? $response['items'] : $response;
|
||||
|
||||
return static::castMany($items);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX\Resource\Traits;
|
||||
|
||||
use InPost\Shipping\ShipX\Resource\ShipXCollection;
|
||||
use InPost\Shipping\ShipX\Resource\ShipXResource;
|
||||
|
||||
/**
|
||||
* @mixin ShipXResource
|
||||
*/
|
||||
trait GetCollectionTrait
|
||||
{
|
||||
/**
|
||||
* Get a paginated resource collection.
|
||||
*
|
||||
* @param array $filters collection search parameters
|
||||
* @param string $sortBy sort field
|
||||
* @param string $sortOrder sort order
|
||||
* @param int $itemsPerPage number of items per page
|
||||
*
|
||||
* @return ShipXCollection
|
||||
*/
|
||||
public static function getCollection(array $filters = [], $sortBy = '', $sortOrder = '', $itemsPerPage = 0)
|
||||
{
|
||||
return new ShipXCollection(static::class, $filters, $sortBy, $sortOrder, $itemsPerPage);
|
||||
}
|
||||
}
|
||||
32
modules/inpostshipping/src/ShipX/Resource/Traits/index.php
Normal file
32
modules/inpostshipping/src/ShipX/Resource/Traits/index.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
32
modules/inpostshipping/src/ShipX/Resource/index.php
Normal file
32
modules/inpostshipping/src/ShipX/Resource/index.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
78
modules/inpostshipping/src/ShipX/ShipXRequest.php
Normal file
78
modules/inpostshipping/src/ShipX/ShipXRequest.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
|
||||
namespace InPost\Shipping\ShipX;
|
||||
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use InPost\Shipping\Api\Request;
|
||||
use InPost\Shipping\Api\Response;
|
||||
use InPost\Shipping\ShipX\Exception\AccessForbiddenException;
|
||||
use InPost\Shipping\ShipX\Exception\ResourceNotFoundException;
|
||||
use InPost\Shipping\ShipX\Exception\ShipXException;
|
||||
use InPost\Shipping\ShipX\Exception\TokenInvalidException;
|
||||
use InPost\Shipping\ShipX\Exception\ValidationFailedException;
|
||||
|
||||
class ShipXRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Send the API Request.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @throws RequestException
|
||||
* @throws ShipXException
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
try {
|
||||
return parent::send();
|
||||
} catch (RequestException $exception) {
|
||||
throw $this->wrapException($exception);
|
||||
}
|
||||
}
|
||||
|
||||
protected function wrapException(RequestException $exception)
|
||||
{
|
||||
if ($exception->hasResponse()) {
|
||||
$exception->getResponse()->getBody()->seek(0);
|
||||
|
||||
$contents = json_decode($exception->getResponse()->getBody()->getContents(), true);
|
||||
|
||||
switch ($contents['error']) {
|
||||
case 'access_forbidden':
|
||||
return new AccessForbiddenException($contents, $exception);
|
||||
case 'resource_not_found':
|
||||
return new ResourceNotFoundException($contents, $exception);
|
||||
case 'token_invalid':
|
||||
return new TokenInvalidException($contents, $exception);
|
||||
case 'validation_failed':
|
||||
return new ValidationFailedException($contents, $exception);
|
||||
default:
|
||||
return new ShipXException($contents, $exception);
|
||||
}
|
||||
}
|
||||
|
||||
return $exception;
|
||||
}
|
||||
}
|
||||
32
modules/inpostshipping/src/ShipX/index.php
Normal file
32
modules/inpostshipping/src/ShipX/index.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2021-2022 InPost S.A.
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* Licensed under the EUPL-1.2 or later.
|
||||
* You may not use this work except in compliance with the Licence.
|
||||
*
|
||||
* You may obtain a copy of the Licence at:
|
||||
* https://joinup.ec.europa.eu/software/page/eupl
|
||||
* It is also bundled with this package in the file LICENSE.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the Licence is distributed on an AS IS basis,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the Licence for the specific language governing permissions
|
||||
* and limitations under the Licence.
|
||||
*
|
||||
* @author InPost S.A.
|
||||
* @copyright 2021-2022 InPost S.A.
|
||||
* @license https://joinup.ec.europa.eu/software/page/eupl
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
Reference in New Issue
Block a user