public function __construct(Config $config, array $data = array()) { if (array_key_exists('resultCode', $data)) { $this->errorStatusMessage = Codes::getErrorName($data['resultCode']); } parent::__construct($config, $data); }
/** * @return SuccessResponse * @throws ApiError * @throws InvalidHttpResponseCode * @throws Exception\JsonDecode * @throws Exception\MacValidation */ private function processResponse() { if (!in_array($this->responseHttpCode, $this->allowedHttpStatusCodes)) { throw new InvalidHttpResponseCode($this->responseHttpCode, $this->responseRaw); } $this->getMacCalculatorResponse()->setResponse($this->responseRaw, $this->headerRaw)->validateResponse(); $data = json_decode($this->responseRaw, true); $data = $this->getUnserializer()->topLevelUnserialize($data); $response = null; if (!Codes::checkCodeIsError($data['resultCode'])) { $response = new SuccessResponse($this->config, $data); } else { $response = new FailureResponse($this->config, $data); throw new ApiError($response, $this->responseRaw, $this->responseHttpCode); } return $response; }