示例#1
0
 public static function createFromSoapResponse($response)
 {
     $amounts = Amount::createFromSoapResponse($response->amounts);
     $takingDate = static::ParseDate($response->takingDate);
     $deadlineDelivery = static::ParseDate($response->deadlineDelivery);
     $partialDiscount = !!$response->partialDiscount;
     if (!$amounts instanceof Collection || !$takingDate || !$deadlineDelivery) {
         throw new SpeedyException('Invalid calculation result data detected.');
     }
     return new static($amounts, $takingDate, $deadlineDelivery, $partialDiscount);
 }
示例#2
0
文件: BOL.php 项目: rolice/speedy
 public static function createFromSoapResponse($response)
 {
     $result = new static();
     $result->generatedParcels = ParcelInfo::createFromSoapResponse($response->generatedParcels);
     $result->amounts = Amount::createFromSoapResponse($response->amounts);
     $result->deadlineDelivery = static::ParseDate($result->deadlineDelivery);
     if (!$result->generatedParcels || $result->generatedParcels->isEmpty()) {
         throw new SpeedyException('Invalid bill of lading (BOL/waybill detected) - no parcel info found.');
     }
     if (!$result->amounts || !$result->deadlineDelivery) {
         throw new SpeedyException('Invalid bill of lading (BOL/waybill detected) - no amount or deadline found.');
     }
     return $result;
 }