/** * Parses the CurlResponse. * * @param CurlResponse $response * @throws \Exception * @return \Comsolit\ImasysPhp\ApiMethods\SendMessageResponse */ public static function parseResponse(CurlResponse $response) { $body = $response->getState()['body']; if (!self::transmissionSuccessful($body)) { throw new \Exception($body); } return new self(self::getBatchIdFromBody($body)); }
/** * Parses the CurlResponse. * * @param CurlResponse $response * @return BatchStatusResponse */ public static function parseResponse(CurlResponse $response) { $body = $response->getState()['body']; $xml = simplexml_load_string($body); $batchId = (string) $xml->BatchID; $status = (string) $xml->Status; $messages = []; foreach ($xml->Messages->children() as $message) { array_push($messages, new Message((string) $message->MsgID, (string) $message->MsgStatus, (string) $message->NotificationMsg, (int) $message->DeliveryTimeStamp, (int) $message->ErrorCode, (string) $message->ErrorDescription)); } return new self($batchId, $status, $messages); }