Ejemplo n.º 1
0
 /**
  * 物流轨迹查询
  * @return mixed
  */
 public function getTrackingOrder($orderNo)
 {
     if (parent::getEnv() == 'PRO') {
         $host = 'http://api.tr.4px.com/';
     } else {
         $host = 'http://preview.api.transrush.com/';
     }
     $baseUrl = $host . Config::get('endpoints.get_tracking_orders') . '?token=' . parent::getApiKey() . '&orderNo=' . $orderNo;
     $request = parent::createBaseRequest(parent::getApiKey(), 'GET', $baseUrl);
     try {
         $response = parent::getClient()->send($request);
     } catch (ClientException $e) {
         throw parent::convertException($e);
     }
     $body = $response->xml();
     $json = json_encode($body);
     $res = json_decode($json, TRUE);
     return $res;
 }
Ejemplo n.º 2
0
 /**
  * 删除预报
  * @return \TransRush\Components\ResultSet
  * @throws
  */
 public function deletePreAlert(DeletePreAlert $deletePreAlert, array $params = array())
 {
     $baseUrl = parent::getEnvUrl() . Config::get('endpoints.delete_pre_alert');
     $request = parent::createBaseRequest(parent::getApiKey(), 'POST', $baseUrl);
     if ($params) {
         $query = $request->getQuery();
         foreach ($params as $name => $value) {
             $query->add($name, $value);
         }
     }
     $requestSet = new RequestSet();
     $requestSet->Token = parent::getApiKey();
     $requestSet->Data = $deletePreAlert;
     $stream = Stream::factory(json_encode($requestSet));
     $request->setBody($stream);
     try {
         $response = parent::getClient()->send($request);
     } catch (ClientException $e) {
         throw parent::convertException($e);
     }
     return ResultSet::create($response->json());
 }
Ejemplo n.º 3
0
 /**
  * 查询转运四方在国外的仓库信息
  * @return array
  * @throws 
  */
 public function getWareHouse()
 {
     $baseUrl = parent::getEnvUrl() . Config::get('endpoints.get_ware_house');
     $request = parent::createBaseRequest(parent::getApiKey(), 'POST', $baseUrl);
     $requestSet = new RequestSet();
     $requestSet->Token = parent::getApiKey();
     $requestSet->Data = null;
     $stream = Stream::factory(json_encode($requestSet));
     $request->setBody($stream);
     try {
         $response = parent::getClient()->send($request);
     } catch (ClientException $e) {
         throw parent::convertException($e);
     }
     $body = $response->json();
     $wareHouses = array();
     $res = json_decode(stripcslashes($body['Data']));
     // 这里Data是字符串 需要先反转义
     foreach ($res as $wareHouse) {
         $wareHouses[] = WareHouse::create(ArrayUtil::object_to_array($wareHouse));
     }
     return $wareHouses;
 }