mchervenkov / inout
Laravel InOut API 包装器
1.0.1
2024-07-10 10:45 UTC
Requires
- php: ^8.0|^8.1|^8.2
- guzzlehttp/guzzle: ^7.4
- illuminate/support: ^8.0|^9.0|^10.0
Requires (Dev)
- larastan/larastan: ^2.9
- orchestra/testbench: ^8.18
- pestphp/pest: ^2.34
This package is auto-updated.
Last update: 2024-09-10 11:12:51 UTC
README
安装
您可以通过 composer 安装此包
composer require mchervenkov/inout
如果您打算使用数据库存储品名
php artisan migrate
如果您需要导出配置文件
php artisan vendor:publish --tag=inout-config
如果您需要导出迁移
php artisan vendor:publish --tag=inout-migrations
如果您需要导出模型
php artisan vendor:publish --tag=inout-models
如果您需要导出命令
php artisan vendor:publish --tag=inout-commands
配置
INOUT_ENV=test|production #default=test INOUT_API_TOKEN= #default=test-api-token INOUT_API_TEST_BASE_URI= #default=https://test-api.inout.bg/api/v1 INOUT_API_PRODUCTION_BASE_URI= #default=https://api1.inout.bg/api/v1 INOUT_COMPANY_ID= #default=0 INOUT_API_TIMEOUT= #default=5 INOUT_TEST_MODE= #default=1
用法
方法
// Init Inout Client $inout = new Inout(); // Awb endpoints $inout->awbDetails($awbNumber); $inout->awbStatus($awbNumber); $inout->awbPrint($awbNumber, 1); $inout->awbHistory($awbNumber); $inout->pickupAwbCreation(PickupAwbCreation); // Companies endpoints $inout->getCompanies(); // Couriers endpoints $inout->getCouriers(); $inout->getCourierOffices($courierId); // Locations endpoints $inout->getCounties($countryId); $inout->getCities(City, $countryId); $inout->getCountries(); $inout->getCitiesSuggestions($countryId, $searchString, 1); // Shipments endpoints $inout->shipmentCreation(Shipment) $inout->shipmentPrice(ShipmentPrice) // Additional services endpoints $inout->codInformation($referenceNumber) $inout->phoneCallHistory($awbNumber) $inout->waybillsHistory(WaybillsHistory)
命令
#get counties with database (use -h to view options) php artisan inout:sync-counties #get countries with database (use -h to view options) php artisan inout:sync-countries #get cities with database (use -h to view options) php artisan inout:sync-cities #create cities map with other carriers in database (use -h to view options) php artisan inout:map-cities #get company couriers with database (use -h to view options) php artisan inout:sync-couriers #get courier offices with database (use -h to view options) php artisan inout:sync-courier-offices #get inout api status (use -h to view options) php artisan inout:api-status
模型
InoutCity InoutCompanyCourier InoutCountry InoutCounty InoutCourierOffice InoutApiStatus CarrierCityMap
示例
$inout = new Inout(); $shipment = new \Mchervenkov\Inout\Hydrators\Shipment([ "senderId" => 333, "courierId" => 20, "waybillAvailableDate" => "2023-06-29", "serviceName" => "crossborder", "recipient": [ "name" => "Test User", //Name of recipient or company. Typically, both customer names (first name and last name) or company. "countryIsoCode" => "HU", //Two digits country ISO code. "cityId" => 20144281, //The ID of a city where the shipment needs to delivery. Obtain an ID from Cities_Web_Service_v1.0. Using cityId, cityName and zipCode can be null. "region" => "null", //The Municipality/county were the city is located. "cityName" => "Balatonszárszó", //City name. If you have your own nomenclature with а cities, you can fill in the fields cityName, zipCode and region. "zipCode" => "8624", //Zip code. "streetName" => "test street", //Name of the street, office address or office name - e.g. If you create shipment to address - Main street or Main street 10.If you want to create shipment to an office, please add a keyword "to office: " to office name or office address. "buildingNumber" => 0, //Number of the street/building - e.g. 10 "officeId" => 1297, //if the courier support PUDO delivery, you can send ID of the PUDO. Obtain the PUDO ID'\''s from "Courier_Offices_Web_Service_v1.2" "officeCode" => "1182", //if the courier support PUDO delivery, you can send COURIER_OFFICE_CODE of the PUDO. Obtain the PUDO COURIER_OFFICE_CODE'\''s from "Courier_Offices_Web_Service_v1.2" "addressText" => "additional text, address test", //Additional address information – e.g. бл.25 ет 3. or bl.25 et. 3 *NOT ALL COURIERS SUPPORT IT* "contactPerson" => "Test User", //Contact person. Usually is the same as the name of recipient. "phoneNumber" => "00889000000", //Recipient'\''s phone number - mandatory for all coureirs. "email" => "2@2.com" // Recipient'\''s email - highly recomended ], "awb": [ "shipmentType" => "pack", //pack or pallet "parcels" => 1, // Number of parcels in the shipment. *NOT ALL COURIERS SUPPORT MULTIPARCEL SERVICE* "envelopes" => 0, //Always send "0". "totalWeight" => 1.000, //Total weight of the shipment in kg. The value have to be equal to the sum of all packages. "declaredValue" => 0, //Insurance amount of the shipment. *NOT ALL COURIERS SUPPORT THE SERVICE* "bankRepayment" => 0.0, //COD amount of the shipment in local currency. You can set to 0 if the shipment doesn'\''t have a COD amount. "otherRepayment" => "additional text for repayment",//The service is no longer supported "observations" => "notes", //Additional information about the shipment/products. (notes) "openPackage" => false, //Check up the shipment before pay. "shipmentPayer" => "sender", //Always "sender" "saturdayDelivery" => false, //The service is no longer supported "referenceNumber" => "000000", //Client reference number. Important: The information in the field must be unique to avoid duplicate shipments! "products" => "test product", //The content of the shipment. e.g. product1 product2 "fragile": 1, //Marker whether the content is fragile. (fragile = 1 if the content is fragile) – Used only for BG "productsInfo" => "1111;2222;3333;4444", //Аdditional product information. "piecesInPack" => 4, //Products amount in one shipment. e.g If the shipment contain 5 products the field will be filled with 5. "packages" => [ "1": [ "dimensions" => [ "width" => 20, "height" => 20, "length" => 20 ], "weight" => 2.300 ] ] ], "returnLabel" => [ "nDaysValid" => 0 //By default is 0 (infinity). FUsed only for Greece ] ]); $response = $inout->shipmentCreation($shipment); dd($response);
测试
在运行测试之前,请将您的 API 凭证设置在 inout.php 配置文件中
composer test
变更日志
有关最近更改的更多信息,请参阅CHANGELOG
贡献
有关详细信息,请参阅CONTRIBUTING
安全
如果您发现任何与安全相关的问题,请通过电子邮件mario.chervenkov@gmail.com 而不是使用问题跟踪器来报告。
鸣谢
许可证
MIT 许可证(MIT)。有关更多信息,请参阅许可证文件