|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"). |
| 6 | + * You may not use this file except in compliance with the License. |
| 7 | + * A copy of the License is located at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * or in the "license" file accompanying this file. This file is distributed |
| 12 | + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 13 | + * express or implied. See the License for the specific language governing |
| 14 | + * permissions and limitations under the License. |
| 15 | + */ |
| 16 | +namespace Amazon\ProductAdvertisingAPI\v1; |
| 17 | + |
| 18 | +use \Exception; |
| 19 | + |
| 20 | +/** |
| 21 | + * ApiException Class Doc Comment |
| 22 | + * |
| 23 | + * @category Class |
| 24 | + * @package Amazon\ProductAdvertisingAPI\v1 |
| 25 | + * @author Product Advertising API team |
| 26 | + */ |
| 27 | +class ApiException extends Exception |
| 28 | +{ |
| 29 | + |
| 30 | + /** |
| 31 | + * The HTTP body of the server response either as Json or string. |
| 32 | + * |
| 33 | + * @var mixed |
| 34 | + */ |
| 35 | + protected $responseBody; |
| 36 | + |
| 37 | + /** |
| 38 | + * The HTTP header of the server response. |
| 39 | + * |
| 40 | + * @var string[]|null |
| 41 | + */ |
| 42 | + protected $responseHeaders; |
| 43 | + |
| 44 | + /** |
| 45 | + * The deserialized response object |
| 46 | + * |
| 47 | + * @var $responseObject; |
| 48 | + */ |
| 49 | + protected $responseObject; |
| 50 | + |
| 51 | + /** |
| 52 | + * Constructor |
| 53 | + * |
| 54 | + * @param string $message Error message |
| 55 | + * @param int $code HTTP status code |
| 56 | + * @param string[]|null $responseHeaders HTTP response header |
| 57 | + * @param mixed $responseBody HTTP decoded body of the server response either as \stdClass or string |
| 58 | + */ |
| 59 | + public function __construct($message = "", $code = 0, $responseHeaders = [], $responseBody = null) |
| 60 | + { |
| 61 | + parent::__construct($message, $code); |
| 62 | + $this->responseHeaders = $responseHeaders; |
| 63 | + $this->responseBody = $responseBody; |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * Gets the HTTP response header |
| 68 | + * |
| 69 | + * @return string[]|null HTTP response header |
| 70 | + */ |
| 71 | + public function getResponseHeaders() |
| 72 | + { |
| 73 | + return $this->responseHeaders; |
| 74 | + } |
| 75 | + |
| 76 | + /** |
| 77 | + * Gets the HTTP body of the server response either as Json or string |
| 78 | + * |
| 79 | + * @return mixed HTTP body of the server response either as \stdClass or string |
| 80 | + */ |
| 81 | + public function getResponseBody() |
| 82 | + { |
| 83 | + return $this->responseBody; |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * Sets the deseralized response object (during deserialization) |
| 88 | + * |
| 89 | + * @param mixed $obj Deserialized response object |
| 90 | + * |
| 91 | + * @return void |
| 92 | + */ |
| 93 | + public function setResponseObject($obj) |
| 94 | + { |
| 95 | + $this->responseObject = $obj; |
| 96 | + } |
| 97 | + |
| 98 | + /** |
| 99 | + * Gets the deseralized response object (during deserialization) |
| 100 | + * |
| 101 | + * @return mixed the deserialized response object |
| 102 | + */ |
| 103 | + public function getResponseObject() |
| 104 | + { |
| 105 | + return $this->responseObject; |
| 106 | + } |
| 107 | +} |
0 commit comments