public static function errorHandler($resp, $code) { $resp = json_decode($resp, true); $message = isset($resp['message']) ? $resp['message'] : null; $message_to_purchaser = isset($resp['message_to_purchaser']) ? $resp['message_to_purchaser'] : null; $type = isset($resp['type']) ? $resp['type'] : null; $params = isset($resp['param']) ? $resp['param'] : null; if (isset($code) != true || $code == 0) { throw new NoConnectionError(Lang::translate('error.requestor.connection', Lang::EN, array('BASE' => Conekta::$apiBase)), Lang::translate('error.requestor.connection_purchaser', Conekta::$locale), $type, $code, $params); } switch ($code) { case 400: throw new MalformedRequestError($message, $message_to_purchaser, $type, $code, $params); case 401: throw new AuthenticationError($message, $message_to_purchaser, $type, $code, $params); case 402: throw new ProcessingError($message, $message_to_purchaser, $type, $code, $params); case 404: throw new ResourceNotFoundError($message, $message_to_purchaser, $type, $code, $params); case 422: throw new ParameterValidationError($message, $message_to_purchaser, $type, $code, $params); case 500: throw new ApiError($message, $message_to_purchaser, $type, $code, $params); default: throw new self($message, $message_to_purchaser, $type, $code, $params); } }
public function instanceUrl() { $id = $this->id; if (!$id) { throw new Error(Lang::translate('error.resource.id', Lang::EN, array('RESOURCE' => get_class())), Lang::translate('error.resource.id_purchaser', Conekta::$locale)); } $class = get_class($this); $base = '/subscription'; $customerUrl = $this->customer->instanceUrl(); return $customerUrl . $base; }
public function instanceUrl() { $id = $this->id; if (!$id) { throw new Error(Lang::translate('error.resource.id', Lang::EN, array('RESOURCE' => get_class())), Lang::translate('error.resource.id_purchaser', Conekta::$locale)); } $class = get_class($this); $base = $this->classUrl($class); $extn = urlencode($id); return "{$base}/{$extn}"; }