aslam / laravel-rpx
RPX API
v1.0.6
2021-04-08 06:36 UTC
Requires
- php: >=7.2|^8.0
- aslam/response: ^1.0
- guzzlehttp/guzzle: ^7.2
Requires (Dev)
- phpunit/phpunit: ^9.5
README
Laravel RPX 包旨在将您的应用程序与 RPX 快递 API 集成。要获取更清晰、更完整的文档,请访问官方网站 API PPX
功能
此包提供以下工具,以及其他更多功能
- 公共客户
- 客户账号编号
安装
您可以通过 composer 安装此包。
composer require aslam/laravel-rpx
配置
要开始使用,您应该使用以下命令发布 config/rpx.php
配置文件:
php artisan vendor:publish --provider="Aslam\Rpx\Providers\RpxServiceProvider"
响应
API 方法返回一个 \Aslam\Response\Response
实例,该实例提供各种方法,可用于检查响应
method()->body() : string; method()->toJson() : array|mixed; method()->collect() : "\Illuminate\Support\Collection"; method()->status() : int; method()->ok() : bool; method()->successful() : bool; method()->failed() : bool; method()->serverError() : bool; method()->clientError() : bool; method()->header($header) : string; method()->headers() : array;
使用方法
公共客户
/** * Get all province */ $getProvince = rpx()->getProvince()->toJson(); /** * Get city * * @param string|null $province */ $getCity = rpx()->getCity()->toJson(); $getService = rpx()->getService()->toJson(); $getOrigin = rpx()->getOrigin()->toJson(); $getDestination = rpx()->getDestination()->toJson(); /** * @param string origin * @param string destination * @param string|null service type * @param string|float|null weight * @param string|float|null discount */ $getRates = rpx()->getRates('JAK', 'DPS', 'PSR', '1', '50')->toJson(); /** * @param string origin postal code * @param string destination postal code * @param string|null service type * @param string|float|null weight * @param string|float|null discount */ $getRatesPostalCode = rpx()->getRatesPostalCode('12310', '12310')->toJson(); /** * @param string awb */ $getTrackingAWB = rpx()->getTrackingAWB('100055295410')->toJson(); /** * @param string|null city_id * @param string|null cod area * @param string|null service type */ $getPostalCode = rpx()->getPostalCode('JAK', null, 'RGP')->toJson(); /** * @param string awb */ $getAWBbyReference = rpx()->getAWBbyReference('123456789')->toJson();
客户账号编号
/** * @param string trackdate from * @param string trackdate to */ $getRevenue = rpx()->withAccountNumber('234098705')->getRevenue('2018-01-01', '2018-02-01')->toJson(); /** * @param string service type * @param string origin * @param string destination * @param float|null weight * @param float|null disc */ $getCustumerRates = rpx()->getCustumerRates(null, 'JAK', 'JAK', 1, 20)->toJson(); $sendShipmentData = rpx()->sendShipmentData([ 'awb' => '', 'package_id' => '56849', 'order_type' => 'MP', 'order_number' => '101010', 'service_type_id' => 'RGP', 'shipper_account' => '234098705', 'shipper_name' => 'Mahkotababy', 'shipper_company' => 'Mahkotababy', 'shipper_address1' => 'Jl. RS Fatmawati No. 17', 'shipper_address2' => '', 'shipper_kelurahan' => 'Kemayoran', 'shipper_kecamatan' => 'Gandaria Selatan', 'shipper_city' => 'CILANDAK', 'shipper_state' => 'DKI Jakarta', 'shipper_zip' => '12420', 'shipper_phone' => '+6285314855952', 'identity_no' => '', 'shipper_mobile_no' => '+6281297773820', 'shipper_email' => '', 'consignee_account' => '', 'consignee_name' => 'dedeh', 'consignee_company' => '', 'consignee_address1' => 'apotek marga mulyaAlamat kp pasarRtx2Frw 0502 Dssindangkerta', 'consignee_address2' => '', 'consignee_kelurahan' => 'Sukamaju', 'consignee_kecamatan' => 'PAGELARAN', 'consignee_city' => 'Cianjur', 'consignee_state' => 'Jawa Barat', 'consignee_zip' => '43266', 'consignee_phone' => '+6285314855952', 'consignee_mobile_no' => '6285314855952', 'consignee_email' => 'dimas.seputro@gmail.com', 'desc_of_goods' => 'Oblong panjang isi 4 9-12bln kode 3', 'tot_package' => '1', 'actual_weight' => '1', 'tot_weight' => '1', 'tot_declare_value' => '1', 'tot_dimensi' => '1', 'flag_mp_spec_handling' => 'N', 'insurance' => 'N', 'surcharge' => 'N', 'high_value' => 'N', 'high_docs' => 'N', 'electronic' => 'N', 'flag_dangerous_goods' => 'N', 'flag_birdnest' => 'N', 'declare_value' => '91500', 'dest_store_id' => '', 'dest_dc_id' => '', 'widhtx' => '', 'lengthx' => '', 'heightx' => '', 'flight_date' => '', 'flight_no' => '', 'remarks' => 'TEST API jangan Dipuckup', ])->toJson();