No Description

SetSubscriptionAttributeResponse.php 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace AliyunMNS\Responses;
  3. use AliyunMNS\Constants;
  4. use AliyunMNS\Exception\MnsException;
  5. use AliyunMNS\Exception\SubscriptionNotExistException;
  6. use AliyunMNS\Exception\InvalidArgumentException;
  7. use AliyunMNS\Responses\BaseResponse;
  8. use AliyunMNS\Common\XMLParser;
  9. class SetSubscriptionAttributeResponse extends BaseResponse
  10. {
  11. public function __construct()
  12. {
  13. }
  14. public function parseResponse($statusCode, $content)
  15. {
  16. $this->statusCode = $statusCode;
  17. if ($statusCode == 204) {
  18. $this->succeed = TRUE;
  19. } else {
  20. $this->parseErrorResponse($statusCode, $content);
  21. }
  22. }
  23. public function parseErrorResponse($statusCode, $content, MnsException $exception = NULL)
  24. {
  25. $this->succeed = FALSE;
  26. $xmlReader = $this->loadXmlContent($content);
  27. try {
  28. $result = XMLParser::parseNormalError($xmlReader);
  29. if ($result['Code'] == Constants::INVALID_ARGUMENT)
  30. {
  31. throw new InvalidArgumentException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
  32. }
  33. if ($result['Code'] == Constants::SUBSCRIPTION_NOT_EXIST)
  34. {
  35. throw new SubscriptionNotExistException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
  36. }
  37. throw new MnsException($statusCode, $result['Message'], $exception, $result['Code'], $result['RequestId'], $result['HostId']);
  38. }
  39. catch (\Exception $e)
  40. {
  41. if ($exception != NULL) {
  42. throw $exception;
  43. }
  44. elseif ($e instanceof MnsException)
  45. {
  46. throw $e;
  47. }
  48. else
  49. {
  50. throw new MnsException($statusCode, $e->getMessage());
  51. }
  52. } catch (\Throwable $t) {
  53. throw new MnsException($statusCode, $t->getMessage());
  54. }
  55. }
  56. }
  57. ?>