├── .php-cs-fixer.dist.php ├── LICENSE ├── README.md ├── composer.json ├── docs ├── google9960c2e2445781b0.html ├── index.md └── logo.png ├── examples ├── 010_CdekClient.php ├── 020_ResponseErrorHandling.php ├── 030_PvzList.php ├── 040_CalculationRequest.php ├── 045_CalculationWithTariffListRequest.php ├── 046_CalculationInternationalWithTariffListRquest.php ├── 050_RegionsRequest.php ├── 060_CitiesRequest.php ├── 070_DeliveryRequest.php ├── 080_AddDeliveryRequest.php ├── 090_PrintReceiptsRequest.php ├── 100_PrintLabelsRequest.php ├── 110_DeleteRequest.php ├── 120_CallCourierRequest.php ├── 130_ScheduleRequest.php ├── 150_StatusReportRequest.php ├── 160_InfoReportRequest.php ├── 170_UpdateRequest.php └── 180_TypeError.php ├── mkdocs.yml └── src ├── CdekClient.php ├── Common ├── AdditionalService.php ├── Address.php ├── Attempt.php ├── Call.php ├── CallCourier.php ├── CallDelay.php ├── CallFail.php ├── CallGood.php ├── ChangePeriod.php ├── City.php ├── DelayReasonState.php ├── DeliveryRecipientCostAdv.php ├── Dimensions.php ├── Fillable.php ├── Item.php ├── Location.php ├── OfficeImage.php ├── Order.php ├── Package.php ├── Passport.php ├── PhoneDetail.php ├── Pvz.php ├── Reason.php ├── Region.php ├── Seller.php ├── Sender.php ├── State.php ├── Status.php ├── WeightLimit.php └── WorkTime.php ├── Contracts ├── Client.php ├── DateAware.php ├── HasErrorCode.php ├── HasMessage.php ├── JsonRequest.php ├── ParamRequest.php ├── Request.php ├── Response.php ├── ShouldAuthorize.php └── XmlRequest.php ├── LaravelCdekServiceProvider.php ├── Requests ├── AddDeliveryRequest.php ├── CalculationAuthorizedRequest.php ├── CalculationRequest.php ├── CalculationWithTariffListAuthorizedRequest.php ├── CalculationWithTariffListRequest.php ├── CallCourierRequest.php ├── CitiesRequest.php ├── Concerns │ ├── AnonymousJsonRequest.php │ ├── Authorized.php │ ├── MagicSetters.php │ ├── OrdersAware.php │ ├── ParamRequest.php │ └── RequestCore.php ├── DeleteRequest.php ├── DeliveryRequest.php ├── InfoReportRequest.php ├── PreAlertRequest.php ├── PrintLabelsRequest.php ├── PrintReceiptsRequest.php ├── PvzListRequest.php ├── RegionsRequest.php ├── ScheduleRequest.php ├── StatusReportRequest.php ├── Templates │ ├── CalculationAuthorizedRequest.php │ └── PrintRequest.php └── UpdateRequest.php └── Responses ├── CalculationResponse.php ├── CalculationWithTariffListResponse.php ├── CallCourierResponse.php ├── CitiesResponse.php ├── Concerns ├── HasErrors.php ├── WithTraceId.php └── WrapsResult.php ├── DeleteResponse.php ├── DeliveryResponse.php ├── ErrorResponse.php ├── FileResponse.php ├── InfoReportResponse.php ├── JsonErrorResponse.php ├── PreAlertResponse.php ├── PrintErrorResponse.php ├── PvzListResponse.php ├── RegionsResponse.php ├── ScheduleResponse.php ├── StatusReportResponse.php ├── Types ├── AdditionalService.php ├── DeleteRequest.php ├── DeliveryRequest.php ├── Error.php ├── JsonAlert.php ├── Message.php ├── PrintError.php ├── Result.php └── TariffResult.php └── UpdateResponse.php /.php-cs-fixer.dist.php: -------------------------------------------------------------------------------- 1 | setRiskyAllowed(true) 10 | ->setRules([ 11 | '@Symfony' => true, 12 | 'array_syntax' => ['syntax' => 'short'], 13 | 'declare_strict_types' => true, 14 | 'explicit_indirect_variable' => true, 15 | 'no_superfluous_elseif' => true, 16 | 'no_unreachable_default_argument_value' => true, 17 | 'no_useless_else' => true, 18 | 'no_useless_return' => true, 19 | 'ordered_class_elements' => false, 20 | 'non_printable_character' => true, 21 | 'ordered_imports' => true, 22 | 'php_unit_test_class_requires_covers' => true, 23 | 'phpdoc_add_missing_param_annotation' => true, 24 | 'phpdoc_order' => true, 25 | 'visibility_required' => true, 26 | 'header_comment' => ['header' => $header, 'separate' => 'bottom', 'location' => 'after_open', 'comment_type' => 'PHPDoc'], 27 | 'ternary_to_null_coalescing' => true, 28 | 'yoda_style' => false, 29 | 'phpdoc_to_comment' => false, 30 | 'binary_operator_spaces' => ['operators' => ['=>' => BinaryOperatorSpacesFixer::ALIGN]], 31 | 'php_unit_method_casing' => [ 32 | 'case' => 'snake_case', 33 | ], 34 | 'strict_comparison' => true, 35 | 'native_function_invocation' => true, 36 | ]) 37 | ->setFinder( 38 | PhpCsFixer\Finder::create() 39 | ->in(__DIR__) 40 | ) 41 | ; 42 | 43 | return $config; 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2018 Appwilio (http://appwilio.com), greabock (https://github.com/greabock), JhaoDa (https://github.com/jhaoda) 4 | Copyright (c) 2018 Alexey Kopytko and contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sanmai/cdek-sdk", 3 | "type": "library", 4 | "description": "СДЭК PHP SDK, библиотека для работы с API СДЭК", 5 | "keywords": [ 6 | "CDEK", 7 | "sdk", 8 | "delivery", 9 | "СДЭК", 10 | "служба доставки" 11 | ], 12 | "homepage": "https://cdek-sdk.readthedocs.io/", 13 | "license": "MIT", 14 | "authors": [ 15 | { 16 | "name": "Roman Sokharev", 17 | "homepage": "https://github.com/greabock", 18 | "role": "Creator" 19 | }, 20 | { 21 | "name": "JhaoDa", 22 | "homepage": "https://github.com/jhaoda", 23 | "role": "Developer" 24 | }, 25 | { 26 | "name": "Alexey Kopytko", 27 | "email": "alexey@kopytko.com", 28 | "homepage": "https://www.alexeykopytko.com", 29 | "role": "Developer" 30 | } 31 | ], 32 | "require": { 33 | "php": ">=7.4", 34 | "ext-SimpleXML": "*", 35 | "ext-json": "*", 36 | "ext-libxml": "*", 37 | "guzzlehttp/guzzle": "^6.3 || ^7.0", 38 | "psr/log": "^1.0 || ^2.0 || ^3.0", 39 | "sanmai/cdek-sdk-serializer": "^0.2.6", 40 | "sanmai/pipeline": "^5.0" 41 | }, 42 | "conflict": { 43 | "psr/http-message": ">=2" 44 | }, 45 | "require-dev": { 46 | "ergebnis/composer-normalize": "^2.9 <2.10 || ^2.0", 47 | "friendsofphp/php-cs-fixer": ">=2", 48 | "gamez/psr-testlogger": ">=3.0", 49 | "illuminate/support": ">=5.2", 50 | "infection/infection": ">=0.18", 51 | "laravel/framework": ">=5.2 <9", 52 | "orchestra/testbench": ">=3", 53 | "phan/phan": "^1 <1.3 || >1.3.0", 54 | "php-coveralls/php-coveralls": ">=2.1", 55 | "phpstan/phpstan": ">=0.10", 56 | "phpunit/phpunit": "^9.4", 57 | "sanmai/phpunit-legacy-adapter": "^6 || ^8", 58 | "vimeo/psalm": ">=3.0.16", 59 | "vkcom/noverify": "^0.5.2" 60 | }, 61 | "suggest": { 62 | "ext-ctype": "For flexible attribute name handling", 63 | "hughgrigg/php-business-time": "Finds next working day, helps with delivery estimates", 64 | "monolog/monolog": "For advanced logging and debugging", 65 | "sanmai/cdek-info": "For related constant enumerations and references", 66 | "sanmai/hoa-protocol": "If you have trouble with a conflicting resolve()", 67 | "sanmai/pindx": "For postal code validation" 68 | }, 69 | "config": { 70 | "sort-packages": true, 71 | "allow-plugins": true 72 | }, 73 | "extra": { 74 | "branch-alias": { 75 | "dev-master": "v0.7.x-dev" 76 | }, 77 | "laravel": { 78 | "providers": [ 79 | "CdekSDK\\LaravelCdekServiceProvider" 80 | ] 81 | } 82 | }, 83 | "autoload": { 84 | "psr-4": { 85 | "CdekSDK\\": "src/" 86 | } 87 | }, 88 | "autoload-dev": { 89 | "psr-4": { 90 | "Tests\\CdekSDK\\": "tests/" 91 | } 92 | }, 93 | "support": { 94 | "issues": "https://github.com/sanmai/cdek-sdk/issues", 95 | "chat": "https://t.me/phpcdeksdk", 96 | "docs": "https://cdek-sdk.readthedocs.io/" 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /docs/google9960c2e2445781b0.html: -------------------------------------------------------------------------------- 1 | google-site-verification: google9960c2e2445781b0.html -------------------------------------------------------------------------------- /docs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sanmai/cdek-sdk/3dd3f7ad7e7b3b688c803ac7ddceb00927fb2d9a/docs/logo.png -------------------------------------------------------------------------------- /examples/010_CdekClient.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | require_once 'vendor/autoload.php'; 29 | 30 | $account = 'account'; 31 | $password = 'password'; 32 | $baseUri = 'http://'; 33 | 34 | $client = new \CdekSDK\CdekClient($account, $password, new \GuzzleHttp\Client([ 35 | 'base_uri' => $baseUri, 36 | ])); 37 | 38 | return $client; 39 | -------------------------------------------------------------------------------- /examples/020_ResponseErrorHandling.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | $client = new \CdekSDK\CdekClient('account', 'password'); 30 | 31 | $request = new \CdekSDK\Requests\DeliveryRequest(); 32 | /** @var \CdekSDK\Contracts\Request $request */ 33 | /** @var \CdekSDK\Contracts\Response $response */ 34 | $response = $client->sendRequest($request); 35 | 36 | if ($response->hasErrors()) { 37 | // Обрабатываем ошибки 38 | foreach ($response->getMessages() as $message) { 39 | if ($message->getErrorCode() !== '') { 40 | // Это ошибка 41 | $message->getMessage(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /examples/030_PvzList.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | use CdekSDK\Requests; 30 | 31 | $client = new \CdekSDK\CdekClient('account', 'password'); 32 | 33 | $request = new Requests\PvzListRequest(); 34 | $request->setCityId(250); 35 | $request->setType(Requests\PvzListRequest::TYPE_ALL); 36 | $request->setCashless(true); 37 | $request->setCash(true); 38 | $request->setCodAllowed(true); 39 | $request->setDressingRoom(true); 40 | 41 | $response = $client->sendPvzListRequest($request); 42 | 43 | if ($response->hasErrors()) { 44 | // обработка ошибок 45 | } 46 | 47 | foreach ($response as $item) { 48 | /** @var \CdekSDK\Common\Pvz $item */ 49 | 50 | // всевозможные параметры соответствуют полям из API СДЭК 51 | $item->Code; 52 | $item->Name; 53 | $item->Address; 54 | 55 | foreach ($item->OfficeImages as $image) { 56 | $image->getUrl(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /examples/040_CalculationRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | use CdekSDK\Requests; 29 | 30 | $client = new \CdekSDK\CdekClient('account', 'password'); 31 | 32 | // для выполнения запроса без авторизации используется 33 | // $request = new Requests\CalculationRequest(); 34 | // $request->set...() и так далее 35 | 36 | $request = new Requests\CalculationAuthorizedRequest(); 37 | $request->setSenderCityPostCode('295000') 38 | ->setReceiverCityPostCode('652632') 39 | ->setTariffId(1) 40 | ->addPackage([ 41 | 'weight' => 0.2, 42 | 'length' => 25, 43 | 'width' => 15, 44 | 'height' => 10, 45 | ]); 46 | 47 | $response = $client->sendCalculationRequest($request); 48 | /** @var \CdekSDK\Responses\CalculationResponse $response */ 49 | if ($response->hasErrors()) { 50 | // обработка ошибок 51 | } 52 | 53 | $response->getPrice(); 54 | // double(1250) 55 | -------------------------------------------------------------------------------- /examples/045_CalculationWithTariffListRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | use CdekSDK\Requests; 29 | 30 | $client = new \CdekSDK\CdekClient('account', 'password'); 31 | 32 | // для выполнения запроса без авторизации используется 33 | // $request = new Requests\CalculationWithTariffListRequest(); 34 | // $request->set...() и так далее 35 | 36 | $request = new Requests\CalculationWithTariffListAuthorizedRequest(); 37 | $request->setSenderCityPostCode('295000') 38 | ->setReceiverCityPostCode('652632') 39 | ->addTariffToList(1) 40 | ->addTariffToList(8) 41 | ->addPackage([ 42 | 'weight' => 0.2, 43 | 'length' => 25, 44 | 'width' => 15, 45 | 'height' => 10, 46 | ]); 47 | 48 | $response = $client->sendCalculationWithTariffListRequest($request); 49 | 50 | /** @var \CdekSDK\Responses\CalculationWithTariffListResponse $response */ 51 | if ($response->hasErrors()) { 52 | // обработка ошибок 53 | } 54 | 55 | foreach ($response->getResults() as $result) { 56 | if ($result->hasErrors()) { 57 | // обработка ошибок 58 | 59 | continue; 60 | } 61 | 62 | if (!$result->getStatus()) { 63 | continue; 64 | } 65 | 66 | $result->getTariffId(); 67 | // int(1) 68 | 69 | $result->getPrice(); 70 | // double(1570) 71 | 72 | $result->getDeliveryPeriodMin(); 73 | // int(4) 74 | 75 | $result->getDeliveryPeriodMax(); 76 | // int(5) 77 | } 78 | -------------------------------------------------------------------------------- /examples/046_CalculationInternationalWithTariffListRquest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | use CdekSDK\Requests; 29 | 30 | const TARIFF_INTERNATIONAL_EXPRESS_DOOR_DOOR = 8; 31 | 32 | $client = new \CdekSDK\CdekClient('account', 'password'); 33 | 34 | // you can use 35 | // $request = new Requests\CalculationWithTariffListRequest(); 36 | // to send Calculation request without authorization 37 | 38 | $request = new Requests\CalculationWithTariffListAuthorizedRequest(); 39 | $request->setSenderCityPostCode('90248') 40 | ->setSenderCity('Gardena') 41 | ->setSenderCountryCode('US') 42 | ->setReceiverCityPostCode('101000') 43 | ->setCurrency('USD') 44 | ->addTariffToList(TARIFF_INTERNATIONAL_EXPRESS_DOOR_DOOR) 45 | ->addPackage([ 46 | 'weight' => 0.2, 47 | 'length' => 25, 48 | 'width' => 15, 49 | 'height' => 10, 50 | ]); 51 | 52 | $response = $client->sendCalculationWithTariffListRequest($request); 53 | 54 | /** @var \CdekSDK\Responses\CalculationWithTariffListResponse $response */ 55 | if ($response->hasErrors()) { 56 | foreach ($response->getErrors() as $err) { 57 | echo $err->getErrorCode()."\n"; 58 | echo $err->getMessage()."\n"; 59 | } 60 | } 61 | 62 | foreach ($response->getResults() as $result) { 63 | if ($result->hasErrors()) { 64 | // обработка ошибок 65 | 66 | continue; 67 | } 68 | 69 | if (!$result->getStatus()) { 70 | continue; 71 | } 72 | 73 | echo 'Tariff ID: '.$result->getTariffId()."\n"; 74 | // int(1) 75 | 76 | echo 'price: '.$result->getPrice()."\n"; 77 | // double(1570) 78 | 79 | echo 'currency: '.$result->getCurrency()."\n"; 80 | 81 | echo 'Delivery Period Min: '.$result->getDeliveryPeriodMin()."\n"; 82 | // int(4) 83 | 84 | echo 'Delivery Perion Max: '.$result->getDeliveryPeriodMax()."\n"; 85 | // int(5) 86 | } 87 | -------------------------------------------------------------------------------- /examples/050_RegionsRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | use CdekSDK\Requests; 29 | 30 | $client = new \CdekSDK\CdekClient('account', 'password'); 31 | 32 | $request = new Requests\RegionsRequest(); 33 | $request->setPage(0)->setSize(10); 34 | $request->setCountryCode('RU'); 35 | 36 | $response = $client->sendRegionsRequest($request); 37 | 38 | if ($response->hasErrors()) { 39 | // обработка ошибок 40 | } 41 | 42 | foreach ($response as $region) { 43 | /** @var \CdekSDK\Common\Region $region */ 44 | $region->getUuid(); 45 | $region->getName(); 46 | $region->getPrefix(); 47 | try { 48 | $region->getCode(); 49 | } catch (\TypeError $e) { 50 | // У региона нет кода 51 | } 52 | $region->getFiasGuid(); 53 | $region->getCountryName(); 54 | $region->getCountryCodeISO(); 55 | $region->getCountryCodeExt(); 56 | } 57 | -------------------------------------------------------------------------------- /examples/060_CitiesRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | use CdekSDK\Requests; 30 | 31 | $client = new \CdekSDK\CdekClient('account', 'password'); 32 | 33 | $request = new Requests\CitiesRequest(); 34 | $request->setPage(0)->setSize(10)->setRegionCode(50); 35 | 36 | $response = $client->sendCitiesRequest($request); 37 | 38 | if ($response->hasErrors()) { 39 | // обработка ошибок 40 | } 41 | 42 | foreach ($response as $location) { 43 | /** @var \CdekSDK\Common\Location $location */ 44 | $location->getCityName(); 45 | $location->getCityCode(); 46 | $location->getCityUuid(); 47 | $location->getCountry(); 48 | $location->getCountryCodeISO(); 49 | $location->getRegion(); 50 | $location->getRegionCode(); 51 | $location->getRegionCodeExt(); 52 | $location->getSubRegion(); 53 | $location->getPaymentLimit(); 54 | $location->getLatitude(); 55 | $location->getLongitude(); 56 | $location->getKladr(); 57 | $location->getFiasGuid(); 58 | } 59 | -------------------------------------------------------------------------------- /examples/090_PrintReceiptsRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | use CdekSDK\Common; 29 | use CdekSDK\Requests; 30 | 31 | $dispatchNumber = '123'; 32 | $client = new \CdekSDK\CdekClient('account', 'password'); 33 | 34 | $request = new Requests\PrintReceiptsRequest([ 35 | 'CopyCount' => 4, 36 | ]); 37 | $request->addOrder(Common\Order::withDispatchNumber($dispatchNumber)); 38 | 39 | $response = $client->sendPrintReceiptsRequest($request); 40 | 41 | if ($response->hasErrors()) { 42 | // обработка ошибок 43 | } 44 | 45 | // Или возвращаем содержимое PDF файла... 46 | return (string) $response->getBody(); 47 | 48 | $orderFromAnotherResponse = new Common\Order(); 49 | $number = '123'; 50 | $dateString = 'now'; 51 | 52 | $request = new Requests\PrintReceiptsRequest(); 53 | $request->addOrder($orderFromAnotherResponse); 54 | $request->addOrder(Common\Order::withNumberAndDate($number, new \DateTime($dateString))); 55 | -------------------------------------------------------------------------------- /examples/100_PrintLabelsRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | use CdekSDK\Common; 29 | use CdekSDK\Requests; 30 | 31 | $dispatchNumber = '123'; 32 | $client = new \CdekSDK\CdekClient('account', 'password'); 33 | 34 | $request = new Requests\PrintLabelsRequest([ 35 | 'PrintFormat' => Requests\PrintLabelsRequest::PRINT_FORMAT_A5, 36 | ]); 37 | $request->addOrder(Common\Order::withDispatchNumber($dispatchNumber)); 38 | 39 | $response = $client->sendPrintLabelsRequest($request); 40 | 41 | if ($response->hasErrors()) { 42 | // обработка ошибок 43 | } 44 | 45 | // Или возвращаем содержимое PDF файла... 46 | return (string) $response->getBody(); 47 | -------------------------------------------------------------------------------- /examples/110_DeleteRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | use CdekSDK\Common; 29 | use CdekSDK\Requests; 30 | 31 | $client = new \CdekSDK\CdekClient('account', 'password'); 32 | 33 | $request = Requests\DeleteRequest::create([ 34 | 'Number' => 'TESTING123', 35 | ])->addOrder(new Common\Order([ 36 | 'Number' => 'TEST-123456', 37 | ])); 38 | 39 | $response = $client->sendDeleteRequest($request); 40 | 41 | if ($response->hasErrors()) { 42 | // обработка ошибок 43 | } 44 | 45 | /** @var \CdekSDK\Common\Order $order */ 46 | foreach ($response->getOrders() as $order) { 47 | // проверяем номера удалённых заказов 48 | $order->getNumber(); // должно быть 'TEST-123456' 49 | } 50 | -------------------------------------------------------------------------------- /examples/120_CallCourierRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | use CdekSDK\Common; 29 | use CdekSDK\Requests; 30 | 31 | $client = new \CdekSDK\CdekClient('account', 'password'); 32 | $dispatchNumber = ''; 33 | 34 | $request = Requests\CallCourierRequest::create()->addCall(Common\CallCourier::create([ 35 | 'Date' => new \DateTime('tomorrow'), 36 | 'DispatchNumber' => $dispatchNumber, 37 | 'TimeBeg' => new \DateTime('10:00'), 38 | 'TimeEnd' => new \DateTime('17:00'), 39 | 'SendCityCode' => 44, 40 | 'SenderName' => 'Проверка Тестович', 41 | 'SendPhone' => '+78001001010', 42 | ])->setAddress(Common\Address::create([ 43 | 'Street' => 'Тестовая', 44 | 'House' => '8', 45 | 'Flat' => '32', 46 | ]))); 47 | 48 | $response = $client->sendCallCourierRequest($request); 49 | 50 | if ($response->hasErrors()) { 51 | // обработка ошибок 52 | } 53 | 54 | // Получаем номера заявок 55 | foreach ($response->getNumbers() as $number) { 56 | // ... 57 | } 58 | -------------------------------------------------------------------------------- /examples/130_ScheduleRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | use CdekSDK\Common; 29 | use CdekSDK\Requests; 30 | 31 | $client = new \CdekSDK\CdekClient('account', 'password'); 32 | 33 | $request = new Requests\ScheduleRequest(); 34 | $request = $request->addOrder(Common\Order::create([ 35 | 'DispatchNumber' => '123456', 36 | ])->addAttempt(Common\Attempt::create([ 37 | 'ID' => 500, 38 | 'Date' => new \DateTime('next Monday'), 39 | ])->addPackage(Common\Package::create([ 40 | 'Number' => 'TEST-123456', 41 | 'BarCode' => 'TEST-123456', 42 | 'Weight' => 500, 43 | ])->addItem(new Common\Item([ 44 | 'WareKey' => 'NN0001', 45 | 'Cost' => 500, 46 | 'Payment' => 0, 47 | 'Weight' => 120, 48 | 'Amount' => 2, 49 | 'Comment' => 'Test item', 50 | ]))))); 51 | 52 | $response = $client->sendScheduleRequest($request); 53 | 54 | if ($response->hasErrors()) { 55 | // обработка ошибок 56 | } 57 | -------------------------------------------------------------------------------- /examples/150_StatusReportRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | use CdekSDK\Common; 30 | use CdekSDK\Requests; 31 | 32 | $client = new \CdekSDK\CdekClient('account', 'password'); 33 | $dispatchNumber = '123'; 34 | 35 | $request = new Requests\StatusReportRequest(); 36 | // можно указывать или всё сразу, или только диапазоны дат, или только конкретные заказы 37 | $request->setChangePeriod(new Common\ChangePeriod(new \DateTime('-1 day'), new \DateTime('+1 day'))); 38 | $request->addOrder(Common\Order::withDispatchNumber($dispatchNumber)); 39 | 40 | // попросим показать историю изменения статусов заказов 41 | $request->setShowHistory(); 42 | 43 | $response = $client->sendStatusReportRequest($request); 44 | 45 | if ($response->hasErrors()) { 46 | // обработка ошибок 47 | } 48 | 49 | foreach ($response as $order) { 50 | /** @var \CdekSDK\Common\Order $order */ 51 | $order->getActNumber(); 52 | $order->getNumber(); 53 | $order->getDispatchNumber(); 54 | $order->getDeliveryDate(); 55 | $order->getRecipientName(); 56 | 57 | if ($status = $order->getStatus()) { 58 | $status->getDescription(); 59 | $status->getDate(); 60 | $status->getCode(); 61 | $status->getCityCode(); 62 | $status->getCityName(); 63 | 64 | foreach ($status->getStates() as $state) { 65 | $state->getDescription(); 66 | $state->getDate(); 67 | $state->getCode(); 68 | $state->getCityCode(); 69 | $state->getCityName(); 70 | $state->isFinal(); 71 | } 72 | } 73 | 74 | $order->getReason()->getCode(); 75 | $order->getReason()->getDescription(); 76 | $order->getReason()->getDate(); 77 | 78 | $order->getDelayReason()->getCode(); 79 | $order->getDelayReason()->getDescription(); 80 | $order->getDelayReason()->getDate(); 81 | } 82 | -------------------------------------------------------------------------------- /examples/160_InfoReportRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | use CdekSDK\Common; 30 | use CdekSDK\Requests; 31 | 32 | $client = new \CdekSDK\CdekClient('account', 'password'); 33 | $dispatchNumber = '123'; 34 | 35 | $request = new Requests\InfoReportRequest(); 36 | $request->setChangePeriod(new Common\ChangePeriod(new \DateTime('-1 day'), new \DateTime('+1 day'))); 37 | // можно искать только по номерам, без дат 38 | $request->addOrder(Common\Order::withDispatchNumber($dispatchNumber)); 39 | 40 | $response = $client->sendInfoReportRequest($request); 41 | 42 | if ($response->hasErrors()) { 43 | // обработка ошибок 44 | } 45 | 46 | foreach ($response as $order) { 47 | /** @var \CdekSDK\Common\Order $order */ 48 | $order->getNumber(); 49 | $order->getSenderCity()->getName(); 50 | $order->getRecipientCity()->getName(); 51 | 52 | foreach ($order->getPackages() as $package) { 53 | $package->getBarCode(); 54 | $package->getVolumeWeight(); 55 | } 56 | 57 | foreach ($order->getAdditionalServices() as $service) { 58 | $service->getServiceCode(); 59 | $service->getSum(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /examples/170_UpdateRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | use CdekSDK\Common; 29 | use CdekSDK\Requests; 30 | 31 | $client = new \CdekSDK\CdekClient('account', 'password'); 32 | 33 | $request = Requests\UpdateRequest::create([ 34 | 'Number' => 'TESTING123', 35 | ])->addOrder(new Common\Order([ 36 | 'Number' => 'TEST-123456', 37 | ])); 38 | 39 | $response = $client->sendUpdateRequest($request); 40 | 41 | if ($response->hasErrors()) { 42 | // обработка ошибок 43 | } 44 | 45 | foreach ($response->getOrders() as $order) { 46 | // проверяем номера изменённых заказов 47 | $order->getNumber(); // должно быть 'TEST-123456' 48 | } 49 | -------------------------------------------------------------------------------- /examples/180_TypeError.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | use CdekSDK\Common\Order; 29 | 30 | $order = new Order(); 31 | 32 | /** @var Order $order */ 33 | try { 34 | $returnOrder = $order->getReturnOrder(); 35 | 36 | // Показываем номер возвратного заказа 37 | $returnOrder->getNumber(); 38 | // ... 39 | } catch (\TypeError $e) { 40 | // Возвратного заказа нет, показываем прочерк 41 | // ... 42 | } 43 | 44 | if ($status = $order->getStatus()) { 45 | // Статус заказа есть, можно обратиться к его методам 46 | $status->getDescription(); 47 | } 48 | -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: CdekSDK 2 | theme: readthedocs 3 | lang: ru 4 | 5 | nav: 6 | - PHP SDK для API СДЭК: index.md 7 | 8 | markdown_extensions: 9 | - toc: 10 | permalink: True 11 | - attr_list 12 | 13 | -------------------------------------------------------------------------------- /src/Common/Address.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Common; 30 | 31 | use JMS\Serializer\Annotation as JMS; 32 | 33 | final class Address 34 | { 35 | use Fillable; 36 | 37 | /** 38 | * @JMS\XmlAttribute 39 | * 40 | * @JMS\Type("string") 41 | * 42 | * @var string 43 | */ 44 | protected $Street; 45 | 46 | /** 47 | * @JMS\XmlAttribute 48 | * 49 | * @JMS\Type("string") 50 | * 51 | * @var string 52 | */ 53 | protected $House; 54 | 55 | /** 56 | * @JMS\XmlAttribute 57 | * 58 | * @JMS\Type("string") 59 | * 60 | * @var string 61 | */ 62 | protected $Flat; 63 | 64 | /** 65 | * @JMS\XmlAttribute 66 | * 67 | * @JMS\Type("string") 68 | * 69 | * @var string 70 | */ 71 | protected $PvzCode; 72 | } 73 | -------------------------------------------------------------------------------- /src/Common/Call.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Common; 30 | 31 | use JMS\Serializer\Annotation as JMS; 32 | 33 | /** 34 | * История прозвонов получателя. 35 | */ 36 | final class Call 37 | { 38 | use Fillable; 39 | 40 | /** 41 | * @JMS\XmlList(entry="Good") 42 | * 43 | * @JMS\Type("array") 44 | * 45 | * @var CallGood[] 46 | */ 47 | protected $CallGood = []; 48 | 49 | /** 50 | * @JMS\XmlList(entry="Fail") 51 | * 52 | * @JMS\Type("array") 53 | * 54 | * @var CallFail[] 55 | */ 56 | protected $CallFail = []; 57 | 58 | /** 59 | * @JMS\XmlList(entry="Delay") 60 | * 61 | * @JMS\Type("array") 62 | * 63 | * @var CallDelay[] 64 | */ 65 | protected $CallDelay = []; 66 | 67 | /** 68 | * История удачных прозвонов. 69 | * 70 | * @phan-suppress PhanDeprecatedProperty 71 | * 72 | * @return CallGood[] 73 | */ 74 | public function getCallGood() 75 | { 76 | return $this->CallGood; 77 | } 78 | 79 | /** 80 | * История неудачных прозвонов. 81 | * 82 | * @phan-suppress PhanDeprecatedProperty 83 | * 84 | * @return CallFail[] 85 | */ 86 | public function getCallFail() 87 | { 88 | return $this->CallFail; 89 | } 90 | 91 | /** 92 | * История переносов прозвона. 93 | * 94 | * @phan-suppress PhanDeprecatedProperty 95 | * 96 | * @return CallDelay[] 97 | */ 98 | public function getCallDelay() 99 | { 100 | return $this->CallDelay; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/Common/CallDelay.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Common; 30 | 31 | use JMS\Serializer\Annotation as JMS; 32 | 33 | /** 34 | * Class CallDelay. 35 | */ 36 | final class CallDelay 37 | { 38 | use Fillable; 39 | 40 | /** 41 | * @JMS\XmlAttribute 42 | * 43 | * @JMS\Type("DateTimeImmutable<'Y-m-d\TH:i:sP'>") 44 | * 45 | * @var \DateTimeImmutable 46 | */ 47 | protected $Date; 48 | 49 | /** 50 | * @JMS\XmlAttribute 51 | * 52 | * @JMS\Type("DateTimeImmutable<'Y-m-d\TH:i:sP', '', 'Y-m-d\TH:i:sP', 'Y-m-d'>") 53 | * 54 | * @var \DateTimeImmutable 55 | */ 56 | protected $DateNext; 57 | 58 | public function getDate(): \DateTimeImmutable 59 | { 60 | return $this->Date; 61 | } 62 | 63 | public function getDateNext(): \DateTimeImmutable 64 | { 65 | return $this->DateNext; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Common/CallFail.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Common; 30 | 31 | use JMS\Serializer\Annotation as JMS; 32 | 33 | /** 34 | * Class CallGood. 35 | */ 36 | final class CallFail 37 | { 38 | /** 39 | * @JMS\XmlAttribute 40 | * 41 | * @JMS\Type("DateTimeImmutable<'Y-m-d\TH:i:sP'>") 42 | * 43 | * @var \DateTimeImmutable 44 | */ 45 | private $Date; 46 | 47 | /** 48 | * @JMS\XmlAttribute 49 | * 50 | * @JMS\Type("int") 51 | * 52 | * @var int 53 | */ 54 | private $ReasonCode; 55 | 56 | /** 57 | * @JMS\XmlAttribute 58 | * 59 | * @JMS\Type("string") 60 | * 61 | * @var string 62 | */ 63 | private $ReasonDescription; 64 | 65 | public function getDate(): \DateTimeImmutable 66 | { 67 | return $this->Date; 68 | } 69 | 70 | public function getReasonCode(): int 71 | { 72 | return $this->ReasonCode; 73 | } 74 | 75 | public function getReasonDescription(): string 76 | { 77 | return $this->ReasonDescription; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/Common/CallGood.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Common; 30 | 31 | use JMS\Serializer\Annotation as JMS; 32 | 33 | /** 34 | * Class CallGood. 35 | */ 36 | final class CallGood 37 | { 38 | /** 39 | * @JMS\XmlAttribute 40 | * 41 | * @JMS\Type("DateTimeImmutable<'Y-m-d\TH:i:sP'>") 42 | * 43 | * @var \DateTimeImmutable 44 | */ 45 | private $Date; 46 | 47 | /** 48 | * @JMS\XmlAttribute 49 | * 50 | * @JMS\Type("DateTimeImmutable<'Y-m-d'>") 51 | * 52 | * @var \DateTimeImmutable 53 | */ 54 | private $DateDeliv; 55 | 56 | public function getDate(): \DateTimeImmutable 57 | { 58 | return $this->Date; 59 | } 60 | 61 | public function getDateDeliv(): \DateTimeImmutable 62 | { 63 | return $this->DateDeliv; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Common/City.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Common; 30 | 31 | use JMS\Serializer\Annotation as JMS; 32 | 33 | final class City 34 | { 35 | /** 36 | * @deprecated 37 | */ 38 | use Fillable; 39 | 40 | /** 41 | * @JMS\XmlAttribute 42 | * 43 | * @JMS\Type("int") 44 | * 45 | * @var int 46 | */ 47 | protected $Code; 48 | 49 | /** 50 | * @JMS\XmlAttribute 51 | * 52 | * @JMS\Type("string") 53 | * 54 | * @var string 55 | */ 56 | protected $PostCode; 57 | 58 | /** 59 | * @JMS\XmlAttribute 60 | * 61 | * @JMS\Type("string") 62 | * 63 | * @var string 64 | */ 65 | protected $Name; 66 | 67 | /** 68 | * @return int|null 69 | */ 70 | public function getCode() 71 | { 72 | return $this->Code; 73 | } 74 | 75 | public function getPostCode(): string 76 | { 77 | return (string) $this->PostCode; 78 | } 79 | 80 | public function getName(): string 81 | { 82 | return (string) $this->Name; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/Common/DelayReasonState.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Common; 30 | 31 | use JMS\Serializer\Annotation as JMS; 32 | 33 | /** @phan-suppress PhanDeprecatedInterface */ 34 | final class DelayReasonState implements State 35 | { 36 | /** 37 | * @JMS\XmlAttribute 38 | * 39 | * @JMS\Type("DateTimeImmutable<'Y-m-d\TH:i:sP'>") 40 | * 41 | * @var \DateTimeImmutable 42 | */ 43 | private $Date; 44 | 45 | /** 46 | * @JMS\XmlAttribute 47 | * 48 | * @JMS\Type("int") 49 | * 50 | * @var int 51 | */ 52 | private $Code; 53 | 54 | /** 55 | * @JMS\XmlAttribute 56 | * 57 | * @JMS\Type("string") 58 | * 59 | * @var string 60 | */ 61 | private $Description; 62 | 63 | public function getDate(): \DateTimeImmutable 64 | { 65 | return $this->Date; 66 | } 67 | 68 | public function getCode(): int 69 | { 70 | return (int) $this->Code; 71 | } 72 | 73 | public function getDescription(): string 74 | { 75 | return $this->Description; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/Common/DeliveryRecipientCostAdv.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Common; 30 | 31 | use JMS\Serializer\Annotation as JMS; 32 | 33 | /** 34 | * Доп. сбор за доставку (которую ИМ берет с получателя), в зависимости от суммы заказа. 35 | */ 36 | final class DeliveryRecipientCostAdv 37 | { 38 | use Fillable; 39 | 40 | /** 41 | * Порог стоимости товара (действует по условию меньше или равно), в целых единицах валюты. 42 | * 43 | * @JMS\XmlAttribute 44 | * 45 | * @JMS\Type("int") 46 | * 47 | * @var int 48 | */ 49 | private $Threshold; 50 | 51 | /** 52 | * Доп. сбор за доставку товаров, общая стоимость которых попадает в интервал. 53 | * 54 | * @JMS\XmlAttribute 55 | * 56 | * @JMS\Type("float") 57 | * 58 | * @var float 59 | */ 60 | private $Sum; 61 | 62 | /** 63 | * Ставка НДС включенная в доп. сбор за доставку (подробнее см. приложение 4). Если значение не передано, то берется значение по умолчанию "Без НДС". 64 | * 65 | * @JMS\XmlAttribute 66 | * 67 | * @JMS\Type("string") 68 | * 69 | * @var string 70 | */ 71 | private $VATRate; 72 | 73 | /** 74 | * Сумма НДС включанная в доп. сбор за доставку. 75 | * 76 | * @JMS\XmlAttribute 77 | * 78 | * @JMS\Type("float") 79 | * 80 | * @var float 81 | */ 82 | private $VATSum; 83 | } 84 | -------------------------------------------------------------------------------- /src/Common/Dimensions.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Common; 30 | 31 | use JMS\Serializer\Annotation as JMS; 32 | 33 | /** 34 | * Габариты ячейки постомата. 35 | * 36 | * Пример данных: 37 | * 38 | * 39 | */ 40 | final class Dimensions 41 | { 42 | /** 43 | * @JMS\XmlAttribute 44 | * 45 | * @JMS\Type("float") 46 | * 47 | * @var float 48 | */ 49 | private $depth; 50 | 51 | /** 52 | * @JMS\XmlAttribute 53 | * 54 | * @JMS\Type("float") 55 | * 56 | * @var float 57 | */ 58 | private $height; 59 | 60 | /** 61 | * @JMS\XmlAttribute 62 | * 63 | * @JMS\Type("float") 64 | * 65 | * @var float 66 | */ 67 | private $width; 68 | 69 | public function getDepth(): float 70 | { 71 | return $this->depth; 72 | } 73 | 74 | public function getHeight(): float 75 | { 76 | return $this->height; 77 | } 78 | 79 | public function getWidth(): float 80 | { 81 | return $this->width; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/Common/Fillable.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Common; 30 | 31 | trait Fillable 32 | { 33 | /** 34 | * @psalm-suppress MixedAssignment 35 | * @psalm-suppress MixedArgument 36 | * 37 | * @param array $data 38 | * 39 | * @final 40 | */ 41 | public function __construct(array $data = []) 42 | { 43 | foreach ($data as $key => $value) { 44 | if (!property_exists($this, $key)) { 45 | /** @phan-suppress-next-line PhanTypeInstantiateTraitStaticOrSelf */ 46 | throw new \InvalidArgumentException(sprintf('The class "%s" does not have the property "%s"', static::class, $key)); 47 | } 48 | 49 | $this->{$key} = $value; 50 | } 51 | } 52 | 53 | /** 54 | * @param array $data 55 | * 56 | * @phan-suppress PhanTypeInstantiateTrait 57 | * 58 | * @psalm-suppress MoreSpecificReturnType 59 | * 60 | * @return static 61 | * 62 | * @final 63 | */ 64 | public static function create($data = []) 65 | { 66 | \assert(\is_array($data)); 67 | 68 | /** @phan-suppress-next-line PhanTypeInstantiateTraitStaticOrSelf */ 69 | return new static($data); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Common/OfficeImage.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Common; 30 | 31 | use JMS\Serializer\Annotation as JMS; 32 | 33 | /** 34 | * Фото для ПВЗ. 35 | * 36 | * Пример данных: 37 | * 38 | * 39 | */ 40 | final class OfficeImage 41 | { 42 | use Fillable; 43 | 44 | /** 45 | * @JMS\XmlAttribute 46 | * 47 | * @JMS\Type("int") 48 | * 49 | * @var int 50 | */ 51 | public $number; 52 | 53 | /** 54 | * @JMS\XmlAttribute 55 | * 56 | * @JMS\Type("string") 57 | * 58 | * @var string 59 | */ 60 | private $url; 61 | 62 | public function getUrl() 63 | { 64 | return $this->url; 65 | } 66 | 67 | public function __toString() 68 | { 69 | return (string) $this->url; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Common/Passport.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Common; 30 | 31 | use JMS\Serializer\Annotation as JMS; 32 | 33 | /** 34 | * Данные паспорта получаетля для импортируемых отправлений. 35 | * 36 | * 37 | */ 38 | final class Passport 39 | { 40 | use Fillable; 41 | 42 | /** 43 | * @JMS\XmlAttribute 44 | * 45 | * @JMS\Type("string") 46 | * 47 | * @var string 48 | */ 49 | private $Series; 50 | 51 | /** 52 | * @JMS\XmlAttribute 53 | * 54 | * @JMS\Type("string") 55 | * 56 | * @var string 57 | */ 58 | private $Number; 59 | 60 | /** 61 | * @JMS\XmlAttribute 62 | * 63 | * @JMS\Type("DateTimeImmutable<'Y-m-d'>") 64 | * 65 | * @var \DateTimeInterface 66 | */ 67 | private $IssueDate; 68 | 69 | /** 70 | * @JMS\XmlAttribute 71 | * 72 | * @JMS\Type("string") 73 | * 74 | * @var string 75 | */ 76 | private $IssuedBy; 77 | 78 | /** 79 | * @JMS\XmlAttribute 80 | * 81 | * @JMS\Type("DateTimeImmutable<'Y-m-d'>") 82 | * 83 | * @var \DateTimeInterface 84 | */ 85 | private $DateBirth; 86 | } 87 | -------------------------------------------------------------------------------- /src/Common/PhoneDetail.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Common; 30 | 31 | use JMS\Serializer\Annotation as JMS; 32 | 33 | /** 34 | * Номер телефона для ПВЗ. 35 | * 36 | * Пример данных: 37 | * 38 | * 39 | */ 40 | final class PhoneDetail 41 | { 42 | /** 43 | * @JMS\XmlAttribute 44 | * 45 | * @JMS\Type("string") 46 | * 47 | * @var string 48 | */ 49 | private $number; 50 | 51 | public function getNumber(): string 52 | { 53 | return $this->number; 54 | } 55 | 56 | public function __toString() 57 | { 58 | return (string) $this->number; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/Common/Reason.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Common; 30 | 31 | use JMS\Serializer\Annotation as JMS; 32 | 33 | /** 34 | * Текущий дополнительный статус, текущая причина задержки. 35 | * 36 | * Пример данных: 37 | * 38 | * 39 | * 40 | */ 41 | final class Reason 42 | { 43 | /** 44 | * @JMS\XmlAttribute 45 | * 46 | * @JMS\Type("DateTimeImmutable<'Y-m-d\TH:i:sP'>") 47 | * 48 | * @var \DateTimeImmutable|null 49 | */ 50 | private $Date; 51 | 52 | /** 53 | * @JMS\XmlAttribute 54 | * 55 | * @JMS\Type("int") 56 | * 57 | * @var int 58 | */ 59 | private $Code; 60 | 61 | /** 62 | * @JMS\XmlAttribute 63 | * 64 | * @JMS\Type("string") 65 | * 66 | * @var string 67 | */ 68 | private $Description; 69 | 70 | /** 71 | * @JMS\XmlList(entry="State", inline=true) 72 | * 73 | * @JMS\Type("array") 74 | * 75 | * @var DelayReasonState[] 76 | */ 77 | private $states = []; 78 | 79 | /** 80 | * @return \DateTimeInterface|null 81 | */ 82 | public function getDate() 83 | { 84 | return $this->Date; 85 | } 86 | 87 | public function getCode(): int 88 | { 89 | return (int) $this->Code; 90 | } 91 | 92 | public function getDescription(): string 93 | { 94 | return $this->Description; 95 | } 96 | 97 | /** 98 | * @return DelayReasonState[] 99 | */ 100 | public function getStates() 101 | { 102 | return $this->states; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/Common/Seller.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Common; 30 | 31 | use JMS\Serializer\Annotation as JMS; 32 | 33 | /** 34 | * @JMS\XmlRoot(name="Seller") 35 | */ 36 | final class Seller 37 | { 38 | use Fillable; 39 | 40 | /** 41 | * @JMS\XmlAttribute 42 | * 43 | * @JMS\Type("string") 44 | * 45 | * @var string 46 | */ 47 | protected $Address; 48 | 49 | /** 50 | * @JMS\XmlAttribute 51 | * 52 | * @JMS\Type("string") 53 | * 54 | * @var string 55 | */ 56 | protected $Name; 57 | 58 | /** 59 | * @JMS\XmlAttribute 60 | * 61 | * @JMS\Type("string") 62 | * 63 | * @var string 64 | */ 65 | protected $INN; 66 | 67 | /** 68 | * @JMS\XmlAttribute 69 | * 70 | * @JMS\Type("string") 71 | * 72 | * @var string 73 | */ 74 | protected $Phone; 75 | 76 | /** 77 | * @JMS\XmlAttribute 78 | * 79 | * @JMS\Type("int") 80 | * 81 | * @var int 82 | */ 83 | protected $OwnershipForm; 84 | } 85 | -------------------------------------------------------------------------------- /src/Common/Sender.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Common; 30 | 31 | use JMS\Serializer\Annotation as JMS; 32 | 33 | final class Sender 34 | { 35 | use Fillable; 36 | 37 | /** 38 | * @JMS\XmlAttribute 39 | * 40 | * @JMS\Type("string") 41 | * 42 | * @var string 43 | */ 44 | protected $Name; 45 | 46 | /** 47 | * @JMS\XmlAttribute 48 | * 49 | * @JMS\Type("string") 50 | * 51 | * @var string 52 | */ 53 | protected $Company; 54 | 55 | /** 56 | * @JMS\Type("CdekSDK\Common\Address") 57 | * 58 | * @var Address 59 | */ 60 | protected $Address; 61 | 62 | /** 63 | * @JMS\Type("string") 64 | * 65 | * @var string 66 | */ 67 | protected $Phone; 68 | 69 | /** @return self */ 70 | public function setAddress(Address $address) 71 | { 72 | $this->Address = $address; 73 | 74 | return $this; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/Common/State.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Common; 30 | 31 | /** 32 | * Заглушка для удалённого объекта State. 33 | * 34 | * До версии 0.6.19 был одноимённый объект, у которого были ещё некоторые методы. 35 | * Из этого интерфейса они были удалены, проблемы обратной совместимости это не 36 | * представляет в текущих версиях PHP, так как даже если у нас есть объект какого-то 37 | * интерфейса, PHP даёт вызывать на нём даже методы, которые не объявлены в интерфейсе. 38 | * 39 | * @deprecated заглушка должна будет быть удалена в следующей мажорной версии 40 | * @see Status 41 | * @see DelayReasonState 42 | */ 43 | interface State 44 | { 45 | public function getDate(): \DateTimeImmutable; 46 | 47 | public function getCode(): int; 48 | 49 | public function getDescription(): string; 50 | } 51 | -------------------------------------------------------------------------------- /src/Common/WeightLimit.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Common; 30 | 31 | use JMS\Serializer\Annotation as JMS; 32 | 33 | final class WeightLimit 34 | { 35 | /** 36 | * @JMS\XmlAttribute 37 | * 38 | * @JMS\Type("int") 39 | * 40 | * @var int 41 | */ 42 | private $WeightMin; 43 | 44 | /** 45 | * @JMS\XmlAttribute 46 | * 47 | * @JMS\Type("int") 48 | * 49 | * @var int 50 | */ 51 | private $WeightMax; 52 | 53 | public function getWeightMin(): int 54 | { 55 | return $this->WeightMin; 56 | } 57 | 58 | public function getWeightMax(): int 59 | { 60 | return $this->WeightMax; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Common/WorkTime.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Common; 30 | 31 | use JMS\Serializer\Annotation as JMS; 32 | 33 | /** 34 | * График работы на неделю. 35 | * 36 | * Пример данных: 37 | * 38 | * 39 | */ 40 | final class WorkTime 41 | { 42 | /** 43 | * @JMS\XmlAttribute 44 | * 45 | * @JMS\Type("int") 46 | * 47 | * @var int 48 | */ 49 | private $day; 50 | 51 | /** 52 | * @JMS\XmlAttribute 53 | * 54 | * @JMS\Type("string") 55 | * 56 | * @var string 57 | */ 58 | private $periods; 59 | 60 | /** 61 | * Порядковый номер дня начиная с единицы. Понедельник = 1, воскресенье = 7. 62 | */ 63 | public function getDay(): int 64 | { 65 | return $this->day; 66 | } 67 | 68 | /** 69 | * Период работы в этот день. 70 | */ 71 | public function getPeriods(): string 72 | { 73 | return $this->periods; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/Contracts/Client.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Contracts; 30 | 31 | /** 32 | * @deprecated https://github.com/cdek-it/sdk2.0 33 | */ 34 | interface Client 35 | { 36 | public function sendRequest(Request $request); 37 | } 38 | -------------------------------------------------------------------------------- /src/Contracts/DateAware.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Contracts; 30 | 31 | interface DateAware 32 | { 33 | public function getRequestDate(): \DateTimeInterface; 34 | } 35 | -------------------------------------------------------------------------------- /src/Contracts/HasErrorCode.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Contracts; 30 | 31 | interface HasErrorCode extends HasMessage 32 | { 33 | public function getErrorCode(): string; 34 | } 35 | -------------------------------------------------------------------------------- /src/Contracts/HasMessage.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Contracts; 30 | 31 | interface HasMessage 32 | { 33 | public function getMessage(): string; 34 | } 35 | -------------------------------------------------------------------------------- /src/Contracts/JsonRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Contracts; 30 | 31 | interface JsonRequest extends Request 32 | { 33 | /** @deprecated */ 34 | public function getBody(): array; 35 | } 36 | -------------------------------------------------------------------------------- /src/Contracts/ParamRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Contracts; 30 | 31 | /** 32 | * @see \CdekSDK\Requests\PvzListRequest 33 | */ 34 | interface ParamRequest extends Request 35 | { 36 | public function getParams(): array; 37 | } 38 | -------------------------------------------------------------------------------- /src/Contracts/Request.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Contracts; 30 | 31 | interface Request 32 | { 33 | public const SERIALIZATION_JSON = 'json'; 34 | public const SERIALIZATION_XML = 'xml'; 35 | 36 | public function getMethod(): string; 37 | 38 | public function getAddress(): string; 39 | 40 | public function getResponseClassName(): string; 41 | 42 | public function getSerializationFormat(): string; 43 | } 44 | -------------------------------------------------------------------------------- /src/Contracts/Response.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Contracts; 30 | 31 | interface Response extends \JsonSerializable 32 | { 33 | public function hasErrors(): bool; 34 | 35 | /** 36 | * @return \Traversable|HasErrorCode[] 37 | */ 38 | public function getMessages(); 39 | } 40 | -------------------------------------------------------------------------------- /src/Contracts/ShouldAuthorize.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Contracts; 30 | 31 | interface ShouldAuthorize 32 | { 33 | public function date(\DateTimeInterface $date): ShouldAuthorize; 34 | 35 | public function credentials(string $account, string $secure): ShouldAuthorize; 36 | } 37 | -------------------------------------------------------------------------------- /src/Contracts/XmlRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Contracts; 30 | 31 | interface XmlRequest extends Request 32 | { 33 | } 34 | -------------------------------------------------------------------------------- /src/LaravelCdekServiceProvider.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK; 30 | 31 | use CdekSDK\Serialization\Serializer; 32 | use Doctrine\Common\Annotations\AnnotationRegistry; 33 | use GuzzleHttp\Client as GuzzleClient; 34 | use Illuminate\Foundation\Application; 35 | use Illuminate\Support\ServiceProvider; 36 | 37 | /** 38 | * @deprecated https://github.com/cdek-it/sdk2.0 39 | * 40 | * @final 41 | */ 42 | class LaravelCdekServiceProvider extends ServiceProvider 43 | { 44 | protected $defer = true; 45 | 46 | public const SKIP_SERIALIZER_CONFIGURATION_FUNC = [Serializer::class, 'doNotConfigureAnnotationRegistry']; 47 | 48 | public function boot() 49 | { 50 | // @codeCoverageIgnoreStart 51 | /** @phan-suppress-next-line PhanUndeclaredStaticMethodInCallable */ 52 | if (\is_callable(self::SKIP_SERIALIZER_CONFIGURATION_FUNC)) { 53 | /** @phan-suppress-next-line PhanDeprecatedFunction */ 54 | AnnotationRegistry::registerLoader('class_exists'); 55 | /** @phan-suppress-next-line PhanUndeclaredStaticMethodInCallable */ 56 | \call_user_func(self::SKIP_SERIALIZER_CONFIGURATION_FUNC); 57 | } 58 | // @codeCoverageIgnoreEnd 59 | } 60 | 61 | /** 62 | * @psalm-suppress MixedAssignment 63 | * @psalm-suppress MixedArrayAccess 64 | * @psalm-suppress MixedArgument 65 | * @psalm-suppress MixedOperand 66 | */ 67 | public function register() 68 | { 69 | $this->app->singleton(CdekClient::class, function (Application $app) { 70 | $config = $app['config']['services.cdek']; 71 | 72 | $client = !empty($config['guzzle_options']) ? new GuzzleClient($config['guzzle_options'] + [ 73 | 'base_uri' => CdekClient::STANDARD_BASE_URL, 74 | 'timeout' => CdekClient::DEFAULT_TIMEOUT, 75 | ]) : null; 76 | 77 | return new CdekClient($config['account'], $config['password'], $client); 78 | }); 79 | } 80 | 81 | public function provides() 82 | { 83 | return [CdekClient::class]; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/Requests/AddDeliveryRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests; 30 | 31 | use JMS\Serializer\Annotation as JMS; 32 | 33 | /** 34 | * @deprecated https://github.com/cdek-it/sdk2.0 35 | * 36 | * @JMS\XmlRoot(name="DeliveryRequest") 37 | * 38 | * @psalm-suppress InvalidExtendClass 39 | */ 40 | final class AddDeliveryRequest extends DeliveryRequest 41 | { 42 | public const ADDRESS = '/addDelivery'; 43 | } 44 | -------------------------------------------------------------------------------- /src/Requests/CalculationAuthorizedRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests; 30 | 31 | use CdekSDK\Responses\CalculationResponse; 32 | 33 | /** 34 | * @deprecated https://github.com/cdek-it/sdk2.0 35 | * 36 | * Class CalculationAuthorizedRequest. 37 | * 38 | * @final 39 | */ 40 | class CalculationAuthorizedRequest extends Templates\CalculationAuthorizedRequest 41 | { 42 | public const ADDRESS = 'https://api.cdek.ru/calculator/calculate_price_by_json.php'; 43 | public const RESPONSE = CalculationResponse::class; 44 | 45 | /** 46 | * @deprecated 47 | * 48 | * @phan-suppress PhanDeprecatedClass 49 | */ 50 | public static function withAuthorization(): CalculationAuthorizedRequest 51 | { 52 | return new CalculationAuthorizedRequest(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Requests/CalculationRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests; 30 | 31 | use CdekSDK\Requests\Concerns\AnonymousJsonRequest; 32 | 33 | /** 34 | * @deprecated https://github.com/cdek-it/sdk2.0 35 | * 36 | * Class CalculationRequest. 37 | * 38 | * @final 39 | * 40 | * @psalm-suppress InvalidExtendClass 41 | */ 42 | class CalculationRequest extends CalculationAuthorizedRequest 43 | { 44 | use AnonymousJsonRequest; 45 | } 46 | -------------------------------------------------------------------------------- /src/Requests/CalculationWithTariffListAuthorizedRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests; 30 | 31 | use CdekSDK\Responses\CalculationWithTariffListResponse; 32 | 33 | /** 34 | * @deprecated https://github.com/cdek-it/sdk2.0 35 | * 36 | * @final 37 | */ 38 | class CalculationWithTariffListAuthorizedRequest extends Templates\CalculationAuthorizedRequest 39 | { 40 | public const ADDRESS = 'https://api.cdek.ru/calculator/calculate_tarifflist.php'; 41 | public const RESPONSE = CalculationWithTariffListResponse::class; 42 | 43 | final public function setTariffId($id) 44 | { 45 | return $this->addTariffToList($id); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Requests/CalculationWithTariffListRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests; 30 | 31 | use CdekSDK\Requests\Concerns\AnonymousJsonRequest; 32 | 33 | /** 34 | * @deprecated https://github.com/cdek-it/sdk2.0 35 | * 36 | * @psalm-suppress InvalidExtendClass 37 | */ 38 | final class CalculationWithTariffListRequest extends CalculationWithTariffListAuthorizedRequest 39 | { 40 | use AnonymousJsonRequest; 41 | } 42 | -------------------------------------------------------------------------------- /src/Requests/CallCourierRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests; 30 | 31 | use CdekSDK\Common\CallCourier; 32 | use CdekSDK\Common\Fillable; 33 | use CdekSDK\Contracts\ShouldAuthorize; 34 | use CdekSDK\Contracts\XmlRequest; 35 | use CdekSDK\Requests\Concerns\Authorized; 36 | use CdekSDK\Requests\Concerns\RequestCore; 37 | use CdekSDK\Responses\CallCourierResponse; 38 | use JMS\Serializer\Annotation as JMS; 39 | 40 | /** 41 | * @deprecated https://github.com/cdek-it/sdk2.0 42 | * 43 | * @JMS\XmlRoot(name="CallCourier") 44 | */ 45 | final class CallCourierRequest implements XmlRequest, ShouldAuthorize 46 | { 47 | use Authorized; 48 | use RequestCore; 49 | use Fillable; 50 | 51 | public const METHOD = 'POST'; 52 | public const ADDRESS = '/call_courier.php'; 53 | public const RESPONSE = CallCourierResponse::class; 54 | 55 | /** 56 | * @JMS\XmlList(entry = "Call", inline = true) 57 | * 58 | * @JMS\Type("array") 59 | * 60 | * @var CallCourier[] 61 | */ 62 | protected $calls = []; 63 | 64 | /** 65 | * @JMS\XmlAttribute 66 | * 67 | * @JMS\SerializedName("CallCount") 68 | * 69 | * @JMS\Type("int") 70 | * 71 | * @JMS\VirtualProperty() 72 | */ 73 | public function getCallCount() 74 | { 75 | return \count($this->calls); 76 | } 77 | 78 | /** @return self */ 79 | public function addCall(CallCourier $call) 80 | { 81 | $this->calls[] = $call; 82 | 83 | return $this; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/Requests/Concerns/AnonymousJsonRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests\Concerns; 30 | 31 | trait AnonymousJsonRequest 32 | { 33 | /** 34 | * @phan-suppress PhanUndeclaredProperty 35 | * @phan-suppress PhanTraitParentReference 36 | * 37 | * @return array 38 | */ 39 | final public function jsonSerialize() 40 | { 41 | $this->account = ''; 42 | 43 | return parent::jsonSerialize(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Requests/Concerns/Authorized.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests\Concerns; 30 | 31 | use CdekSDK\Contracts\ShouldAuthorize; 32 | use JMS\Serializer\Annotation as JMS; 33 | 34 | trait Authorized 35 | { 36 | /** 37 | * Дата и время в формате ISO 8601:2004: YYYY-MM-DDThh:mm:ss+hh:mm. 38 | * 39 | * @see \CdekSDK\CdekClient::getSecure(); 40 | * 41 | * @JMS\XmlAttribute 42 | * 43 | * @JMS\SerializedName("Date") 44 | * 45 | * @JMS\Type("DateTimeImmutable<'Y-m-d\TH:i:s'>") 46 | * 47 | * @var \DateTimeInterface 48 | * 49 | * @deprecated will be made private/protected 50 | */ 51 | public $date; 52 | 53 | /** 54 | * @JMS\XmlAttribute 55 | * 56 | * @JMS\SerializedName("Account") 57 | * 58 | * @JMS\Type("string") 59 | * 60 | * @var string 61 | * 62 | * @deprecated will be made private/protected 63 | */ 64 | public $account; 65 | 66 | /** 67 | * @JMS\XmlAttribute 68 | * 69 | * @JMS\SerializedName("Secure") 70 | * 71 | * @JMS\Type("string") 72 | * 73 | * @var string 74 | * 75 | * @deprecated will be made private/protected 76 | */ 77 | public $secure; 78 | 79 | /** 80 | * @phan-suppress PhanTypeMismatchReturn 81 | * @phan-suppress PhanDeprecatedProperty 82 | */ 83 | final public function date(\DateTimeInterface $date): ShouldAuthorize 84 | { 85 | $this->date = $date; 86 | 87 | /** @var ShouldAuthorize $this */ 88 | return $this; 89 | } 90 | 91 | /** 92 | * @phan-suppress PhanTypeMismatchReturn 93 | * @phan-suppress PhanDeprecatedProperty 94 | */ 95 | final public function credentials(string $account, string $secure): ShouldAuthorize 96 | { 97 | $this->account = $account; 98 | $this->secure = $secure; 99 | 100 | /** @var ShouldAuthorize $this */ 101 | return $this; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/Requests/Concerns/MagicSetters.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests\Concerns; 30 | 31 | trait MagicSetters 32 | { 33 | /** 34 | * @final 35 | */ 36 | public function __call(string $name, array $arguments) 37 | { 38 | if (0 === strpos($name, 'set') && property_exists($this, $property = lcfirst(substr($name, 3)))) { 39 | $this->{$property} = $arguments[0]; 40 | 41 | return $this; 42 | } 43 | 44 | throw new \BadMethodCallException(sprintf('Accessor [%s] not found in [%s].', $name, __CLASS__)); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Requests/Concerns/OrdersAware.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests\Concerns; 30 | 31 | use CdekSDK\Common\Order; 32 | 33 | trait OrdersAware 34 | { 35 | /** 36 | * @JMS\XmlList(entry = "Order", inline = true) 37 | * 38 | * @JMS\Type("array") 39 | * 40 | * @var Order[] 41 | */ 42 | protected $orders = []; 43 | 44 | /** 45 | * @return Order[] 46 | */ 47 | final public function getOrders() 48 | { 49 | return $this->orders; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Requests/Concerns/ParamRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests\Concerns; 30 | 31 | trait ParamRequest 32 | { 33 | /** 34 | * @final 35 | */ 36 | public function getParams(): array 37 | { 38 | return array_filter(get_object_vars($this), function ($value) { 39 | return $value !== null; 40 | }); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Requests/Concerns/RequestCore.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests\Concerns; 30 | 31 | use CdekSDK\Contracts\JsonRequest; 32 | use CdekSDK\Contracts\ParamRequest; 33 | use CdekSDK\Contracts\XmlRequest; 34 | 35 | trait RequestCore 36 | { 37 | /** 38 | * @phan-suppress PhanUndeclaredConstantOfClass 39 | * 40 | * @psalm-suppress MixedInferredReturnType 41 | */ 42 | final public function getAddress(): string 43 | { 44 | return static::ADDRESS; 45 | } 46 | 47 | /** 48 | * @phan-suppress PhanUndeclaredConstantOfClass 49 | * 50 | * @psalm-suppress MixedInferredReturnType 51 | */ 52 | final public function getMethod(): string 53 | { 54 | return static::METHOD; 55 | } 56 | 57 | /** 58 | * @phan-suppress PhanUndeclaredConstantOfClass 59 | * 60 | * @psalm-suppress MixedInferredReturnType 61 | */ 62 | final public function getResponseClassName(): string 63 | { 64 | return static::RESPONSE; 65 | } 66 | 67 | /** 68 | * @psalm-suppress MixedInferredReturnType 69 | */ 70 | final public function getSerializationFormat(): string 71 | { 72 | if ($this instanceof XmlRequest) { 73 | return $this::SERIALIZATION_XML; 74 | } 75 | 76 | if ($this instanceof JsonRequest) { 77 | return $this::SERIALIZATION_JSON; 78 | } 79 | 80 | if ($this instanceof ParamRequest) { 81 | return $this::SERIALIZATION_XML; 82 | } 83 | 84 | throw new \BadMethodCallException(sprintf('Class [%s] has an unrecognized serialization format.', __CLASS__)); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/Requests/DeleteRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests; 30 | 31 | use CdekSDK\Responses\DeleteResponse; 32 | use JMS\Serializer\Annotation as JMS; 33 | 34 | /** 35 | * @deprecated https://github.com/cdek-it/sdk2.0 36 | * 37 | * Class DeleteRequest. 38 | * 39 | * @JMS\XmlRoot(name="DeleteRequest") 40 | * 41 | * @psalm-suppress InvalidExtendClass 42 | */ 43 | final class DeleteRequest extends DeliveryRequest 44 | { 45 | public const ADDRESS = '/delete_orders.php'; 46 | public const RESPONSE = DeleteResponse::class; 47 | } 48 | -------------------------------------------------------------------------------- /src/Requests/InfoReportRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests; 30 | 31 | use CdekSDK\Common\ChangePeriod; 32 | use CdekSDK\Common\Order; 33 | use CdekSDK\Contracts\ShouldAuthorize; 34 | use CdekSDK\Contracts\XmlRequest; 35 | use CdekSDK\Requests\Concerns\Authorized; 36 | use CdekSDK\Requests\Concerns\OrdersAware; 37 | use CdekSDK\Requests\Concerns\RequestCore; 38 | use CdekSDK\Responses\InfoReportResponse; 39 | use JMS\Serializer\Annotation as JMS; 40 | 41 | /** 42 | * @deprecated https://github.com/cdek-it/sdk2.0 43 | * 44 | * Class InfoReportRequest. 45 | * 46 | * @JMS\XmlRoot(name="InfoRequest") 47 | */ 48 | final class InfoReportRequest implements XmlRequest, ShouldAuthorize 49 | { 50 | use Authorized; 51 | use OrdersAware; 52 | use RequestCore; 53 | 54 | public const METHOD = 'POST'; 55 | public const ADDRESS = '/info_report.php'; 56 | public const RESPONSE = InfoReportResponse::class; 57 | 58 | /** 59 | * @var ChangePeriod|null 60 | */ 61 | protected $ChangePeriod; 62 | 63 | public function addOrder(Order $order) 64 | { 65 | $this->orders[] = $order; 66 | 67 | return $this; 68 | } 69 | 70 | public function setChangePeriod(ChangePeriod $period) 71 | { 72 | $this->ChangePeriod = $period; 73 | 74 | return $this; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/Requests/PreAlertRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests; 30 | 31 | use CdekSDK\Responses\PreAlertResponse; 32 | use JMS\Serializer\Annotation as JMS; 33 | 34 | /** 35 | * @deprecated https://github.com/cdek-it/sdk2.0 36 | * 37 | * Создание преалерта. Метод используется для создания сводного реестра (преалерта), содержащего все накладные, товары по которым передаются на доставку. 38 | * 39 | * @JMS\XmlRoot(name="PreAlert") 40 | * 41 | * @psalm-suppress InvalidExtendClass 42 | * 43 | * @deprecated 44 | */ 45 | final class PreAlertRequest extends DeliveryRequest 46 | { 47 | public const ADDRESS = '/addPreAlert'; 48 | public const RESPONSE = PreAlertResponse::class; 49 | 50 | /** 51 | * @JMS\XmlAttribute 52 | * 53 | * @JMS\Type("string") 54 | * 55 | * @var string 56 | */ 57 | protected $PvzCode; 58 | 59 | /** 60 | * Дата планируемой передачи. В формате YYYY-MM-DD. 61 | * 62 | * @JMS\XmlAttribute 63 | * 64 | * @JMS\Type("DateTimeImmutable<'Y-m-d'>") 65 | * 66 | * @var \DateTimeImmutable 67 | */ 68 | protected $PlannedMeetingDate; 69 | } 70 | -------------------------------------------------------------------------------- /src/Requests/PrintLabelsRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests; 30 | 31 | use CdekSDK\Common\Fillable; 32 | use CdekSDK\Requests\Concerns\Authorized; 33 | use CdekSDK\Requests\Concerns\RequestCore; 34 | use CdekSDK\Requests\Templates\PrintRequest; 35 | use JMS\Serializer\Annotation as JMS; 36 | 37 | /** 38 | * @deprecated https://github.com/cdek-it/sdk2.0 39 | * 40 | * Class PrintLabelsRequest. 41 | * 42 | * @JMS\XmlRoot(name="OrdersPackagesPrint") 43 | */ 44 | final class PrintLabelsRequest extends PrintRequest 45 | { 46 | use Fillable; 47 | use Authorized; 48 | use RequestCore; 49 | 50 | public const METHOD = 'POST'; 51 | public const ADDRESS = '/ordersPackagesPrint'; 52 | 53 | public const PRINT_FORMAT_A4 = 'A4'; 54 | public const PRINT_FORMAT_A5 = 'A5'; 55 | public const PRINT_FORMAT_A6 = 'A6'; 56 | 57 | /** 58 | * @JMS\XmlAttribute 59 | * 60 | * @JMS\Type("string") 61 | * 62 | * @var string 63 | */ 64 | private $PrintFormat = self::PRINT_FORMAT_A4; 65 | } 66 | -------------------------------------------------------------------------------- /src/Requests/PrintReceiptsRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests; 30 | 31 | use CdekSDK\Common\Fillable; 32 | use CdekSDK\Requests\Concerns\Authorized; 33 | use CdekSDK\Requests\Concerns\RequestCore; 34 | use CdekSDK\Requests\Templates\PrintRequest; 35 | use JMS\Serializer\Annotation as JMS; 36 | 37 | /** 38 | * @deprecated https://github.com/cdek-it/sdk2.0 39 | * 40 | * Class PrintReceiptRequest. 41 | * 42 | * @JMS\XmlRoot(name="OrdersPrint") 43 | */ 44 | final class PrintReceiptsRequest extends PrintRequest 45 | { 46 | use Fillable; 47 | use Authorized; 48 | use RequestCore; 49 | 50 | public const METHOD = 'POST'; 51 | public const ADDRESS = '/orders_print.php'; 52 | } 53 | -------------------------------------------------------------------------------- /src/Requests/ScheduleRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests; 30 | 31 | use CdekSDK\Contracts\HasErrorCode; 32 | use CdekSDK\Responses\ScheduleResponse; 33 | use JMS\Serializer\Annotation as JMS; 34 | 35 | /** 36 | * @deprecated https://github.com/cdek-it/sdk2.0 37 | * 38 | * Регистрация информации о результате прозвона. 39 | * 40 | * @JMS\XmlRoot(name="ScheduleRequest") 41 | * 42 | * @psalm-suppress InvalidExtendClass 43 | */ 44 | final class ScheduleRequest extends DeliveryRequest implements HasErrorCode 45 | { 46 | public const ADDRESS = '/new_schedule.php'; 47 | public const RESPONSE = ScheduleResponse::class; 48 | 49 | /** 50 | * @JMS\XmlAttribute 51 | * 52 | * @JMS\Type("string") 53 | * 54 | * @var string 55 | */ 56 | protected $Msg; 57 | 58 | /** 59 | * @JMS\XmlAttribute 60 | * 61 | * @JMS\Type("string") 62 | * 63 | * @var string 64 | */ 65 | protected $ErrorCode; 66 | 67 | public function getMessage(): string 68 | { 69 | return (string) $this->Msg; 70 | } 71 | 72 | public function getErrorCode(): string 73 | { 74 | return (string) $this->ErrorCode; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/Requests/Templates/PrintRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests\Templates; 30 | 31 | use CdekSDK\Common\Order; 32 | use CdekSDK\Contracts\ShouldAuthorize; 33 | use CdekSDK\Contracts\XmlRequest; 34 | use CdekSDK\Requests\Concerns\OrdersAware; 35 | use CdekSDK\Responses\PrintErrorResponse; 36 | use JMS\Serializer\Annotation as JMS; 37 | 38 | abstract class PrintRequest implements XmlRequest, ShouldAuthorize 39 | { 40 | use OrdersAware; 41 | 42 | public const RESPONSE = PrintErrorResponse::class; 43 | 44 | /** 45 | * @JMS\XmlAttribute 46 | * 47 | * @JMS\Type("int") 48 | * 49 | * @var string 50 | */ 51 | protected $CopyCount; 52 | 53 | /** 54 | * @JMS\XmlAttribute 55 | * 56 | * @JMS\SerializedName("OrderCount") 57 | * 58 | * @JMS\Type("int") 59 | * 60 | * @JMS\VirtualProperty() 61 | */ 62 | final public function getOrderCount() 63 | { 64 | return \count($this->orders); 65 | } 66 | 67 | final public function addOrder(Order $order) 68 | { 69 | $this->orders[$order->getId()] = $order; 70 | 71 | return $this; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/Requests/UpdateRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Requests; 30 | 31 | use CdekSDK\Responses\UpdateResponse; 32 | use JMS\Serializer\Annotation as JMS; 33 | 34 | /** 35 | * @deprecated https://github.com/cdek-it/sdk2.0 36 | * 37 | * @JMS\XmlRoot(name="UpdateRequest") 38 | * 39 | * @psalm-suppress InvalidExtendClass 40 | */ 41 | final class UpdateRequest extends DeliveryRequest 42 | { 43 | public const ADDRESS = '/update'; 44 | public const RESPONSE = UpdateResponse::class; 45 | } 46 | -------------------------------------------------------------------------------- /src/Responses/CalculationResponse.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses; 30 | 31 | use CdekSDK\Contracts\HasErrorCode; 32 | use CdekSDK\Contracts\Response; 33 | use CdekSDK\Responses\Concerns\WrapsResult; 34 | use CdekSDK\Responses\Types\AdditionalService; 35 | use CdekSDK\Responses\Types\Error; 36 | use CdekSDK\Responses\Types\Result; 37 | use JMS\Serializer\Annotation as JMS; 38 | 39 | /** 40 | * Class CalculationResponse. 41 | * 42 | * @method float|null getPrice() 43 | * @method int|null getDeliveryPeriodMin() 44 | * @method int|null getDeliveryPeriodMax() 45 | * @method int|null getTariffId() 46 | * @method float|null getPriceByCurrency() 47 | * @method float|null getCashOnDelivery() 48 | * @method string|null getCurrency() 49 | * @method \DateTimeImmutable|null getDeliveryDateMin() 50 | * @method \DateTimeImmutable|null getDeliveryDateMax() 51 | * @method AdditionalService[] getAdditionalServices() 52 | */ 53 | final class CalculationResponse implements Response 54 | { 55 | use WrapsResult; 56 | 57 | /** 58 | * @JMS\SerializedName("error") 59 | * 60 | * @JMS\Type("array") 61 | * 62 | * @var Error[] 63 | */ 64 | private $errors = []; 65 | 66 | public function hasErrors(): bool 67 | { 68 | return !empty($this->errors); 69 | } 70 | 71 | /** 72 | * @return HasErrorCode[]|Error[] 73 | * 74 | * @deprecated use getMessages() 75 | */ 76 | public function getErrors(): array 77 | { 78 | return $this->errors; 79 | } 80 | 81 | public function getMessages() 82 | { 83 | yield from $this->errors; 84 | } 85 | 86 | public function getResult(): Result 87 | { 88 | return $this->result; 89 | } 90 | 91 | public function jsonSerialize() 92 | { 93 | return []; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/Responses/CalculationWithTariffListResponse.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses; 30 | 31 | use CdekSDK\Contracts\HasErrorCode; 32 | use CdekSDK\Contracts\Response; 33 | use CdekSDK\Responses\Types\Error; 34 | use CdekSDK\Responses\Types\TariffResult; 35 | use JMS\Serializer\Annotation as JMS; 36 | 37 | /** 38 | * Class CalculationWithTariffListResponse. 39 | */ 40 | final class CalculationWithTariffListResponse implements Response, \IteratorAggregate 41 | { 42 | /** 43 | * @JMS\Type("array") 44 | * 45 | * @var TariffResult[] 46 | */ 47 | private $result = []; 48 | 49 | /** 50 | * @JMS\SerializedName("error") 51 | * 52 | * @JMS\Type("array") 53 | * 54 | * @var Error[] 55 | */ 56 | private $errors = []; 57 | 58 | public function hasErrors(): bool 59 | { 60 | return !empty($this->errors); 61 | } 62 | 63 | /** 64 | * @return Error[]|HasErrorCode[] 65 | */ 66 | public function getErrors(): array 67 | { 68 | return $this->errors; 69 | } 70 | 71 | public function getMessages() 72 | { 73 | yield from $this->getErrors(); 74 | } 75 | 76 | /** 77 | * @return TariffResult[] 78 | */ 79 | public function getResults() 80 | { 81 | return $this->result; 82 | } 83 | 84 | /** 85 | * @phan-suppress PhanUnextractableAnnotationSuffix 86 | * 87 | * @return \Traversable|TariffResult[] 88 | */ 89 | public function getIterator() 90 | { 91 | return new \ArrayIterator($this->result); 92 | } 93 | 94 | public function jsonSerialize() 95 | { 96 | return []; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/Responses/CitiesResponse.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses; 30 | 31 | use CdekSDK\Common\Location; 32 | use CdekSDK\Contracts\Response; 33 | use JMS\Serializer\Annotation as JMS; 34 | 35 | /** 36 | * Class CitiesResponse. 37 | * 38 | * @template-implements IteratorAggregate 39 | */ 40 | final class CitiesResponse implements \IteratorAggregate, Response 41 | { 42 | /** 43 | * @JMS\XmlList(entry = "Location", inline = true) 44 | * 45 | * @JMS\Type("array") 46 | * 47 | * @var Location[] 48 | */ 49 | private $items = []; 50 | 51 | /** 52 | * @return Location[] 53 | */ 54 | public function getItems(): array 55 | { 56 | return $this->items; 57 | } 58 | 59 | /** 60 | * @phan-suppress PhanUnextractableAnnotationSuffix 61 | * 62 | * @return \Traversable|Location[] 63 | */ 64 | public function getIterator() 65 | { 66 | return new \ArrayIterator($this->getItems()); 67 | } 68 | 69 | public function jsonSerialize() 70 | { 71 | return []; 72 | } 73 | 74 | public function hasErrors(): bool 75 | { 76 | return false; 77 | } 78 | 79 | public function getMessages() 80 | { 81 | return []; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/Responses/Concerns/HasErrors.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses\Concerns; 30 | 31 | use CdekSDK\Contracts\Response; 32 | 33 | trait HasErrors 34 | { 35 | /** 36 | * @final 37 | */ 38 | public function hasErrors(): bool 39 | { 40 | \assert($this instanceof Response); 41 | 42 | foreach ($this->getMessages() as $message) { 43 | if ($message->getErrorCode() !== '') { 44 | return true; 45 | } 46 | } 47 | 48 | return false; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Responses/Concerns/WithTraceId.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses\Concerns; 30 | 31 | trait WithTraceId 32 | { 33 | /** 34 | * @JMS\XmlElement 35 | * 36 | * @JMS\Type("string") 37 | * 38 | * @var string 39 | */ 40 | protected $TraceId = ''; 41 | 42 | final public function getTraceId(): string 43 | { 44 | return $this->TraceId; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Responses/Concerns/WrapsResult.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses\Concerns; 30 | 31 | use CdekSDK\Responses\CalculationResponse; 32 | use CdekSDK\Responses\Types\Result; 33 | use CdekSDK\Responses\Types\TariffResult; 34 | 35 | trait WrapsResult 36 | { 37 | /** 38 | * @JMS\Type("CdekSDK\Responses\Types\Result") 39 | * 40 | * @var Result 41 | */ 42 | private $result; 43 | 44 | /** 45 | * @phan-suppress PhanInfiniteRecursion 46 | * 47 | * @final 48 | */ 49 | public function __call(string $name, array $arguments) 50 | { 51 | /** @var CalculationResponse|TariffResult $this */ 52 | if ($this->hasErrors()) { 53 | throw new \RuntimeException('Calculation request was not successful. Please check for errors before calling any instance methods.'); 54 | } 55 | 56 | if ($this->result && method_exists($this->result, $name)) { 57 | return $this->result->{$name}(...$arguments); 58 | } 59 | 60 | throw new \BadMethodCallException(sprintf('Method [%s] not found in [%s].', $name, __CLASS__)); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Responses/DeleteResponse.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses; 30 | 31 | use CdekSDK\Common\Order; 32 | use CdekSDK\Contracts\Response; 33 | use CdekSDK\Responses\Concerns\HasErrors; 34 | use CdekSDK\Responses\Types\DeleteRequest; 35 | use CdekSDK\Responses\Types\Message; 36 | use JMS\Serializer\Annotation as JMS; 37 | 38 | use function Pipeline\fromArray; 39 | 40 | /** 41 | * Class DeleteResponse. 42 | */ 43 | final class DeleteResponse implements Response 44 | { 45 | use HasErrors; 46 | 47 | /** 48 | * @JMS\XmlList(entry = "DeleteRequest", inline = true) 49 | * 50 | * @JMS\Type("array") 51 | * 52 | * @var DeleteRequest[] 53 | */ 54 | private $requests = []; 55 | 56 | /** 57 | * @JMS\XmlList(entry = "Order", inline = true) 58 | * 59 | * @JMS\Type("array") 60 | * 61 | * @var Order[] 62 | */ 63 | private $orders = []; 64 | 65 | /** 66 | * @return \Pipeline\Standard|Order[] 67 | */ 68 | private function getOrdersFromRequests() 69 | { 70 | return fromArray($this->requests)->map(function (DeleteRequest $request) { 71 | yield from $request->getOrders(); 72 | }); 73 | } 74 | 75 | /** 76 | * @return \Pipeline\Standard|Order[] 77 | */ 78 | public function getOrders() 79 | { 80 | if ($this->orders) { 81 | return fromArray($this->orders)->filter(function (Order $order) { 82 | return $order->getNumber() !== ''; 83 | }); 84 | } 85 | 86 | return $this->getOrdersFromRequests(); 87 | } 88 | 89 | public function getMessages() 90 | { 91 | return Message::from($this->getOrdersFromRequests(), $this->requests, $this->orders); 92 | } 93 | 94 | public function jsonSerialize() 95 | { 96 | return []; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/Responses/FileResponse.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses; 30 | 31 | use CdekSDK\Contracts\Response; 32 | use Psr\Http\Message\StreamInterface; 33 | 34 | /** 35 | * FileResponse содержит данные файла. 36 | */ 37 | final class FileResponse implements Response 38 | { 39 | /** @var StreamInterface */ 40 | private $stream; 41 | 42 | public function __construct(StreamInterface $stream) 43 | { 44 | $this->stream = $stream; 45 | } 46 | 47 | public function getBody(): StreamInterface 48 | { 49 | return $this->stream; 50 | } 51 | 52 | public function jsonSerialize() 53 | { 54 | return (string) $this->getBody(); 55 | } 56 | 57 | public function hasErrors(): bool 58 | { 59 | return false; 60 | } 61 | 62 | public function getMessages() 63 | { 64 | return []; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/Responses/InfoReportResponse.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses; 30 | 31 | use CdekSDK\Common\Order; 32 | use CdekSDK\Contracts\Response; 33 | use CdekSDK\Responses\Concerns\HasErrors; 34 | use CdekSDK\Responses\Types\Message; 35 | use JMS\Serializer\Annotation as JMS; 36 | 37 | /** 38 | * Class InfoReportResponse. 39 | * 40 | * @template-implements IteratorAggregate 41 | */ 42 | final class InfoReportResponse implements Response, \IteratorAggregate 43 | { 44 | use HasErrors; 45 | 46 | /** 47 | * @JMS\XmlList(entry = "Order", inline = true) 48 | * 49 | * @JMS\Type("array") 50 | * 51 | * @var Order[] 52 | */ 53 | private $orders = []; 54 | 55 | /** 56 | * @return Order[] 57 | */ 58 | public function getOrders() 59 | { 60 | return $this->orders; 61 | } 62 | 63 | /** 64 | * @phan-suppress PhanUnextractableAnnotationSuffix 65 | * 66 | * @return \Traversable|Order[] 67 | */ 68 | public function getIterator() 69 | { 70 | return new \ArrayIterator($this->getOrders()); 71 | } 72 | 73 | public function getMessages() 74 | { 75 | return Message::from($this->orders); 76 | } 77 | 78 | public function jsonSerialize() 79 | { 80 | return []; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/Responses/JsonErrorResponse.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses; 30 | 31 | use CdekSDK\Contracts\Response; 32 | use CdekSDK\Responses\Types\JsonAlert; 33 | use CdekSDK\Responses\Types\Message; 34 | use JMS\Serializer\Annotation as JMS; 35 | 36 | /** 37 | * Class JsonErrorResponse. 38 | */ 39 | final class JsonErrorResponse implements Response 40 | { 41 | /** 42 | * @JMS\Type("int") 43 | * 44 | * @var int 45 | */ 46 | private $timestamp; 47 | 48 | /** 49 | * @JMS\Type("string") 50 | * 51 | * @var string 52 | */ 53 | private $path; 54 | 55 | /** 56 | * @JMS\Type("int") 57 | * 58 | * @var int 59 | */ 60 | private $status; 61 | 62 | /** 63 | * @JMS\Type("string") 64 | * 65 | * @var string 66 | */ 67 | private $error; 68 | 69 | /** 70 | * @JMS\Type("string") 71 | * 72 | * @var string 73 | */ 74 | private $message; 75 | 76 | /** 77 | * @JMS\XmlList(entry = "JsonAlert", inline = true) 78 | * 79 | * @JMS\Type("array") 80 | * 81 | * @var JsonAlert[] 82 | */ 83 | private $alerts = []; 84 | 85 | public function hasErrors(): bool 86 | { 87 | return true; 88 | } 89 | 90 | public function getMessages() 91 | { 92 | if ($this->alerts) { 93 | yield from Message::from($this->alerts); 94 | } 95 | 96 | if ($this->error !== null) { 97 | yield new Message($this->error, (string) $this->status); 98 | } 99 | } 100 | 101 | public function jsonSerialize() 102 | { 103 | return []; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/Responses/PreAlertResponse.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses; 30 | 31 | use CdekSDK\Common\Order; 32 | use CdekSDK\Contracts\HasErrorCode; 33 | use CdekSDK\Contracts\Response; 34 | use CdekSDK\Responses\Concerns\HasErrors; 35 | use CdekSDK\Responses\Types\Message; 36 | use JMS\Serializer\Annotation as JMS; 37 | 38 | /** 39 | * Class PreAlertResponse. 40 | * 41 | * @deprecated 42 | */ 43 | final class PreAlertResponse implements Response 44 | { 45 | use HasErrors; 46 | 47 | /** 48 | * @JMS\XmlList(entry = "Order", inline = true) 49 | * 50 | * @JMS\Type("array") 51 | * 52 | * @var Order[] 53 | */ 54 | private $orders = []; 55 | 56 | public function getMessages() 57 | { 58 | return Message::from($this->orders); 59 | } 60 | 61 | /** 62 | * @return \Traversable|HasErrorCode[] 63 | */ 64 | public function getErrors() 65 | { 66 | foreach ($this->getMessages() as $message) { 67 | if ($message->getErrorCode() !== '') { 68 | yield $message; 69 | } 70 | } 71 | } 72 | 73 | public function jsonSerialize() 74 | { 75 | return []; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/Responses/PrintErrorResponse.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses; 30 | 31 | use CdekSDK\Common\Order; 32 | use CdekSDK\Contracts\Response; 33 | use CdekSDK\Responses\Types\Message; 34 | use CdekSDK\Responses\Types\PrintError; 35 | use JMS\Serializer\Annotation as JMS; 36 | 37 | /** 38 | * Class PrintErrorResponse. 39 | */ 40 | final class PrintErrorResponse implements Response 41 | { 42 | /** 43 | * @JMS\XmlList(entry = "Order", inline = true) 44 | * 45 | * @JMS\Type("array") 46 | * 47 | * @var PrintError[] 48 | */ 49 | private $errors = []; 50 | 51 | /** 52 | * @JMS\XmlList(entry = "OrdersPrint", inline = true) 53 | * 54 | * @JMS\Type("array") 55 | * 56 | * @var PrintError[] 57 | */ 58 | private $moreErrors = []; 59 | 60 | public function hasErrors(): bool 61 | { 62 | return true; 63 | } 64 | 65 | public function getMessages() 66 | { 67 | return Message::from($this->errors, $this->moreErrors); 68 | } 69 | 70 | public function jsonSerialize() 71 | { 72 | return []; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/Responses/PvzListResponse.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses; 30 | 31 | use CdekSDK\Common\Pvz; 32 | use CdekSDK\Contracts\Response; 33 | use JMS\Serializer\Annotation as JMS; 34 | 35 | /** 36 | * Class PvzListResponse. 37 | * 38 | * @template-implements IteratorAggregate 39 | */ 40 | final class PvzListResponse implements Response, \IteratorAggregate 41 | { 42 | /** 43 | * @JMS\XmlList(entry="Pvz", inline=true) 44 | * 45 | * @JMS\Type("array") 46 | * 47 | * @var Pvz[] 48 | */ 49 | private $items = []; 50 | 51 | /** 52 | * @return Pvz[] 53 | */ 54 | public function getItems(): array 55 | { 56 | return $this->items; 57 | } 58 | 59 | /** 60 | * @phan-suppress PhanUnextractableAnnotationSuffix 61 | * 62 | * @psalm-suppress InvalidReturnStatement 63 | * 64 | * @return \Traversable|Pvz[] 65 | */ 66 | public function getIterator() 67 | { 68 | return new \ArrayIterator($this->getItems()); 69 | } 70 | 71 | public function jsonSerialize() 72 | { 73 | return []; 74 | } 75 | 76 | public function hasErrors(): bool 77 | { 78 | return false; 79 | } 80 | 81 | public function getMessages() 82 | { 83 | return []; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/Responses/RegionsResponse.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses; 30 | 31 | use CdekSDK\Common\Region; 32 | use CdekSDK\Contracts\Response; 33 | use JMS\Serializer\Annotation as JMS; 34 | 35 | /** 36 | * Class RegionsResponse. 37 | * 38 | * @template-implements IteratorAggregate 39 | */ 40 | final class RegionsResponse implements \IteratorAggregate, Response 41 | { 42 | /** 43 | * @JMS\XmlList(entry = "Region", inline = true) 44 | * 45 | * @JMS\Type("array") 46 | * 47 | * @var Region[] 48 | */ 49 | private $items = []; 50 | 51 | /** 52 | * @return Region[] 53 | */ 54 | public function getItems(): array 55 | { 56 | return $this->items; 57 | } 58 | 59 | /** 60 | * @phan-suppress PhanUnextractableAnnotationSuffix 61 | * 62 | * @psalm-suppress InvalidReturnStatement 63 | * 64 | * @return \Traversable|Region[] 65 | */ 66 | public function getIterator() 67 | { 68 | return new \ArrayIterator($this->getItems()); 69 | } 70 | 71 | public function jsonSerialize() 72 | { 73 | return []; 74 | } 75 | 76 | public function hasErrors(): bool 77 | { 78 | return false; 79 | } 80 | 81 | public function getMessages() 82 | { 83 | return []; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/Responses/ScheduleResponse.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses; 30 | 31 | use CdekSDK\Common\Order; 32 | use CdekSDK\Contracts\HasErrorCode; 33 | use CdekSDK\Contracts\Response; 34 | use CdekSDK\Requests\ScheduleRequest; 35 | use CdekSDK\Responses\Concerns\HasErrors; 36 | use CdekSDK\Responses\Types\Message; 37 | use JMS\Serializer\Annotation as JMS; 38 | 39 | /** 40 | * Class ScheduleResponse. 41 | */ 42 | final class ScheduleResponse implements Response 43 | { 44 | use HasErrors; 45 | 46 | /** 47 | * @JMS\XmlList(entry = "ScheduleRequest", inline = true) 48 | * 49 | * @JMS\Type("array") 50 | * 51 | * @var ScheduleRequest[] 52 | */ 53 | private $requests = []; 54 | 55 | /** 56 | * @JMS\XmlList(entry = "Order", inline = true) 57 | * 58 | * @JMS\Type("array") 59 | * 60 | * @var Order[] 61 | */ 62 | private $orders = []; 63 | 64 | public function getMessages() 65 | { 66 | return Message::from($this->requests, $this->orders); 67 | } 68 | 69 | /** 70 | * @return \Traversable|HasErrorCode[] 71 | */ 72 | public function getErrors() 73 | { 74 | foreach ($this->getMessages() as $message) { 75 | if ($message->getErrorCode() !== '') { 76 | yield $message; 77 | } 78 | } 79 | } 80 | 81 | public function jsonSerialize() 82 | { 83 | return []; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/Responses/Types/AdditionalService.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses\Types; 30 | 31 | use JMS\Serializer\Annotation as JMS; 32 | 33 | final class AdditionalService 34 | { 35 | /** 36 | * @JMS\Type("int") 37 | * 38 | * @var int 39 | */ 40 | private $id; 41 | 42 | /** 43 | * @JMS\Type("string") 44 | * 45 | * @var string 46 | */ 47 | private $title; 48 | 49 | /** 50 | * @JMS\Type("float") 51 | * 52 | * @var float 53 | */ 54 | private $price; 55 | 56 | /** 57 | * @JMS\Type("float") 58 | * 59 | * @var float 60 | */ 61 | private $rate; 62 | 63 | public function getId(): int 64 | { 65 | return $this->id; 66 | } 67 | 68 | public function getTitle(): string 69 | { 70 | return $this->title; 71 | } 72 | 73 | public function getPrice(): float 74 | { 75 | return $this->price; 76 | } 77 | 78 | /** 79 | * @see \CdekSDK\Common\AdditionalService 80 | */ 81 | public function getServiceCode(): int 82 | { 83 | return $this->id; 84 | } 85 | 86 | /** 87 | * @see \CdekSDK\Common\AdditionalService 88 | */ 89 | public function getSum(): float 90 | { 91 | return $this->price; 92 | } 93 | 94 | public function getRate(): float 95 | { 96 | return (float) $this->rate; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/Responses/Types/DeleteRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses\Types; 30 | 31 | use CdekSDK\Contracts\HasErrorCode; 32 | use CdekSDK\Requests\Concerns\OrdersAware; 33 | use JMS\Serializer\Annotation as JMS; 34 | 35 | /** 36 | * DeleteRequest - ответа на успешный одноимённый запрос. 37 | * 38 | * Пример данных: 39 | * 40 | * 41 | * 42 | */ 43 | final class DeleteRequest implements HasErrorCode 44 | { 45 | use OrdersAware; 46 | 47 | /** 48 | * @JMS\XmlAttribute 49 | * 50 | * @JMS\Type("string") 51 | * 52 | * @var string 53 | */ 54 | protected $Msg; 55 | 56 | /** 57 | * @JMS\XmlAttribute 58 | * 59 | * @JMS\Type("string") 60 | * 61 | * @var string 62 | */ 63 | protected $ErrorCode; 64 | 65 | public function getMessage(): string 66 | { 67 | return (string) $this->Msg; 68 | } 69 | 70 | public function getErrorCode(): string 71 | { 72 | return (string) $this->ErrorCode; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/Responses/Types/DeliveryRequest.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses\Types; 30 | 31 | use CdekSDK\Contracts\HasErrorCode; 32 | use JMS\Serializer\Annotation as JMS; 33 | 34 | /** 35 | * DeliveryRequest - эхо из ответа на ошибочный DeliveryRequest. 36 | * 37 | * Пример данных: 38 | * 39 | * 40 | */ 41 | final class DeliveryRequest implements HasErrorCode 42 | { 43 | /** 44 | * @JMS\XmlAttribute 45 | * 46 | * @JMS\Type("string") 47 | * 48 | * @var string 49 | */ 50 | private $Number; 51 | 52 | /** 53 | * @JMS\XmlAttribute 54 | * 55 | * @JMS\Type("string") 56 | * 57 | * @var string 58 | */ 59 | private $ErrorCode; 60 | 61 | /** 62 | * @JMS\XmlAttribute 63 | * 64 | * @JMS\Type("string") 65 | * 66 | * @var string 67 | */ 68 | private $Msg; 69 | 70 | public function getNumber(): string 71 | { 72 | return (string) $this->Number; 73 | } 74 | 75 | public function getErrorCode(): string 76 | { 77 | return (string) $this->ErrorCode; 78 | } 79 | 80 | public function getMessage(): string 81 | { 82 | return (string) $this->Msg; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/Responses/Types/Error.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses\Types; 30 | 31 | use CdekSDK\Contracts\HasErrorCode; 32 | use JMS\Serializer\Annotation as JMS; 33 | 34 | final class Error implements HasErrorCode 35 | { 36 | /** 37 | * @JMS\Type("int") 38 | * 39 | * @var int 40 | */ 41 | private $code; 42 | 43 | /** 44 | * @JMS\Type("string") 45 | * 46 | * @var string 47 | */ 48 | private $text; 49 | 50 | public function getCode(): int 51 | { 52 | return $this->code; 53 | } 54 | 55 | /** 56 | * @deprecated use getMessage() 57 | */ 58 | public function getText(): string 59 | { 60 | return $this->getMessage(); 61 | } 62 | 63 | public function getErrorCode(): string 64 | { 65 | return (string) $this->getCode(); 66 | } 67 | 68 | public function getMessage(): string 69 | { 70 | return $this->text; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Responses/Types/JsonAlert.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses\Types; 30 | 31 | use CdekSDK\Contracts\HasErrorCode; 32 | use JMS\Serializer\Annotation as JMS; 33 | 34 | final class JsonAlert implements HasErrorCode 35 | { 36 | /** 37 | * @JMS\Type("string") 38 | * 39 | * @var string 40 | */ 41 | private $type; 42 | 43 | /** 44 | * @JMS\Type("string") 45 | * 46 | * @var string 47 | */ 48 | private $errorCode; 49 | 50 | public function getErrorCode(): string 51 | { 52 | return $this->errorCode; 53 | } 54 | 55 | public function getMessage(): string 56 | { 57 | return $this->type; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Responses/Types/Message.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses\Types; 30 | 31 | use CdekSDK\Contracts\HasErrorCode; 32 | 33 | use function Pipeline\fromArray; 34 | 35 | final class Message implements HasErrorCode 36 | { 37 | /** @var string */ 38 | private $text; 39 | 40 | /** @var string|null */ 41 | private $errorCode; 42 | 43 | /** 44 | * @param string|null $errorCode 45 | */ 46 | public function __construct(string $text, $errorCode = null) 47 | { 48 | $this->text = $text; 49 | $this->errorCode = $errorCode; 50 | } 51 | 52 | /** 53 | * @deprecated use getMessage() 54 | * 55 | * @codeCoverageIgnore 56 | */ 57 | public function getText(): string 58 | { 59 | return $this->getMessage(); 60 | } 61 | 62 | /** 63 | * @deprecated use getErrorCode() 64 | * 65 | * @codeCoverageIgnore 66 | */ 67 | public function getCode(): string 68 | { 69 | return $this->getErrorCode(); 70 | } 71 | 72 | /** 73 | * @deprecated use getErrorCode() !== '' 74 | * 75 | * @codeCoverageIgnore 76 | */ 77 | public function isError(): bool 78 | { 79 | return (bool) $this->errorCode; 80 | } 81 | 82 | public function getErrorCode(): string 83 | { 84 | return (string) $this->errorCode; 85 | } 86 | 87 | public function getMessage(): string 88 | { 89 | return $this->text; 90 | } 91 | 92 | public static function from(...$inputs): \Traversable 93 | { 94 | return fromArray($inputs)->unpack()->map(function (HasErrorCode $item) { 95 | // В разных версиях API может быть то или другое 96 | if ($item->getMessage() || $item->getErrorCode()) { 97 | yield new Message($item->getMessage(), $item->getErrorCode()); 98 | } 99 | }); 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/Responses/Types/PrintError.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses\Types; 30 | 31 | use CdekSDK\Contracts\HasErrorCode; 32 | use JMS\Serializer\Annotation as JMS; 33 | 34 | final class PrintError implements HasErrorCode 35 | { 36 | /** 37 | * @JMS\XmlAttribute 38 | * 39 | * @JMS\Type("string") 40 | * 41 | * @var string 42 | */ 43 | private $ErrorCode; 44 | 45 | /** 46 | * @JMS\XmlAttribute 47 | * 48 | * @JMS\Type("string") 49 | * 50 | * @var string 51 | */ 52 | private $Msg; 53 | 54 | public function getErrorCode(): string 55 | { 56 | return $this->ErrorCode; 57 | } 58 | 59 | public function getMessage(): string 60 | { 61 | return $this->Msg; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Responses/UpdateResponse.php: -------------------------------------------------------------------------------- 1 | and contributors 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | declare(strict_types=1); 28 | 29 | namespace CdekSDK\Responses; 30 | 31 | use CdekSDK\Common\Order; 32 | use CdekSDK\Contracts\Response; 33 | use CdekSDK\Responses\Concerns\HasErrors; 34 | use CdekSDK\Responses\Concerns\WithTraceId; 35 | use CdekSDK\Responses\Types\Message; 36 | use JMS\Serializer\Annotation as JMS; 37 | 38 | use function Pipeline\fromArray; 39 | 40 | /** 41 | * Class UpdateResponse. 42 | * 43 | * @see DeliveryResponse 44 | */ 45 | final class UpdateResponse implements Response 46 | { 47 | use HasErrors; 48 | use WithTraceId; 49 | 50 | /** 51 | * @JMS\XmlList(entry = "Order", inline = true) 52 | * 53 | * @JMS\Type("array") 54 | * 55 | * @var Order[] 56 | */ 57 | private $orders = []; 58 | 59 | /** 60 | * @JMS\Exclude 61 | * 62 | * @var \Traversable 63 | */ 64 | private $completeOrders; 65 | 66 | /** 67 | * @return \Traversable|Order[] 68 | */ 69 | public function getOrders() 70 | { 71 | return $this->completeOrders; 72 | } 73 | 74 | /** 75 | * @JMS\PostDeserialize 76 | * 77 | * @psalm-suppress InvalidPropertyAssignmentValue 78 | * @psalm-suppress MixedTypeCoercion 79 | */ 80 | private function filterOrders() 81 | { 82 | $this->completeOrders = fromArray($this->orders)->filter(function (Order $order) { 83 | return (bool) $order->getDispatchNumber(); 84 | }); 85 | } 86 | 87 | public function getMessages() 88 | { 89 | return Message::from($this->orders); 90 | } 91 | 92 | public function jsonSerialize() 93 | { 94 | return []; 95 | } 96 | } 97 | --------------------------------------------------------------------------------