1 | <?php |
||
33 | class WosClient implements WosClientInterface |
||
34 | { |
||
35 | use Helper\ValidateByteRangeTrait; |
||
36 | use Helper\ArrayToMetadataStringTrait; |
||
37 | |||
38 | /** |
||
39 | * @var Client |
||
40 | */ |
||
41 | private $guzzleClient; |
||
42 | |||
43 | /** |
||
44 | * Build a WOS Client from parameters |
||
45 | * |
||
46 | * @param string $wosUrl |
||
47 | * @param string $wosPolicy |
||
48 | * @param array $guzzleOptions |
||
49 | * @return WosClient |
||
50 | */ |
||
51 | public static function build($wosUrl, $wosPolicy = '', array $guzzleOptions = []) |
||
63 | |||
64 | /** |
||
65 | * WOS Client constructor |
||
66 | * |
||
67 | * The constructor expects a guzzleClient with the base_url value set, and |
||
68 | * any default options that should be used on all requests. |
||
69 | * |
||
70 | * For convenience, you probably want to set the 'x-ddn-policy' header by |
||
71 | * default. See the self::build() method above for an example of setting |
||
72 | * this. |
||
73 | * |
||
74 | * @param Client $guzzleClient |
||
75 | */ |
||
76 | public function __construct(Client $guzzleClient) |
||
84 | |||
85 | /** |
||
86 | * {@inheritdoc} |
||
87 | */ |
||
88 | public function putObject($data, array $meta = [], $objectId = '', array $options = []) |
||
108 | |||
109 | /** |
||
110 | * {@inheritdoc} |
||
111 | */ |
||
112 | public function getObject($objectId, $byteRange = '', array $options = []) |
||
126 | |||
127 | /** |
||
128 | * {@inheritdoc} |
||
129 | */ |
||
130 | public function getMetadata($objectId, array $options = []) |
||
137 | |||
138 | /** |
||
139 | * {@inheritdoc} |
||
140 | */ |
||
141 | public function deleteObject($objectId, array $options = []) |
||
153 | |||
154 | /** |
||
155 | * {@inheritdoc} |
||
156 | */ |
||
157 | public function reserveObject(array $options = []) |
||
164 | |||
165 | /** |
||
166 | * @return Client |
||
167 | */ |
||
168 | public function getHttpClient() |
||
172 | |||
173 | /** |
||
174 | * Perform a request |
||
175 | * |
||
176 | * @param string $method |
||
177 | * @param string $path |
||
178 | * @param array $options |
||
179 | * @return ResponseInterface |
||
180 | */ |
||
181 | public function sendRequest($method, $path, array $options = []) |
||
191 | |||
192 | /** |
||
193 | * Process a response |
||
194 | * |
||
195 | * Ensure that this is a valid response, and |
||
196 | * convert any DDN errors into appropriate exceptions |
||
197 | * |
||
198 | * @param ResponseInterface $response |
||
199 | */ |
||
200 | private function checkResponse(ResponseInterface $response) |
||
211 | } |
||
212 |