Skip to content

Commit 58dcc83

Browse files
author
Vítězslav Dvořák
committed
functions for resource obtaining and saving added
1 parent 7e6bc70 commit 58dcc83

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/ApiClient.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ public function disconnect()
196196
}
197197

198198
/**
199+
* Obtain All resources listing
199200
*
200201
* @return array
201202
*/
@@ -214,14 +215,42 @@ public function listResources()
214215
}
215216

216217
/**
218+
* Obtain Resource by UID
217219
*
220+
* @param string $uid
221+
*
222+
* @return string|null
223+
*/
224+
public function getResource($uid)
225+
{
226+
$responseCode = $this->doCurlRequest($this->baseEndpoint . 'resource/' . $uid, 'POST');
227+
return $responseCode == 200 ? $this->lastCurlResponse : null;
228+
}
229+
230+
/**
231+
* Saver Response
232+
*
233+
* @param string $uid Resource UUID
234+
* @param string $filename Save
235+
*
236+
* @return int size of saved file in bites
237+
*/
238+
public function saveResource($uid, $filename)
239+
{
240+
$resource = $this->getResource($uid);
241+
return $this->lastResponseCode == 200 ? file_put_contents($filename, $resource) : 0;
242+
}
243+
244+
/**
245+
* Close Curl Handle before serizaliation
218246
*/
219247
public function __destruct()
220248
{
221249
$this->disconnect();
222250
}
223251

224252
/**
253+
* Obtain listing of all Customers
225254
*
226255
* @return array
227256
*/

0 commit comments

Comments
 (0)