| Total Complexity | 10 |
| Total Lines | 78 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class ClientHandler extends APIHandler { |
||
| 9 | |||
| 10 | private $client = '/client'; |
||
| 11 | private $api = '/api'; |
||
| 12 | private $v1 = '/v1'; |
||
|
|
|||
| 13 | private $v2 = '/v2'; |
||
| 14 | |||
| 15 | protected $headers = [ |
||
| 16 | 'Accept' => 'application/json', |
||
| 17 | 'Content-Type' => 'application/json' |
||
| 18 | ]; |
||
| 19 | |||
| 20 | |||
| 21 | function __construct($id = null) { |
||
| 22 | parent::__construct(); |
||
| 23 | $this->id = $id; |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Learning Locker: Request Organisation Details |
||
| 28 | * |
||
| 29 | * @return $response |
||
| 30 | */ |
||
| 31 | public function get($selected = []) { |
||
| 32 | try { |
||
| 33 | $url = $this->url . $this->api . $this->v2 . $this->client . '/' . $this->id ?? $this->id; |
||
| 34 | $response = $this->request($url); |
||
| 35 | |||
| 36 | if ($selected) $response = $this->select($selected, $response); |
||
| 37 | |||
| 38 | return $response; |
||
| 39 | } catch (Exception $e) { |
||
| 40 | return $e; |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Learning Locker: Request Organisation Details |
||
| 46 | * |
||
| 47 | * @return $response |
||
| 48 | */ |
||
| 49 | public function update($data) { |
||
| 50 | try { |
||
| 51 | $url = $this->url . $this->api . $this->v2 . $this->client . '/' . $this->id ?? $this->id; |
||
| 52 | $response = $this->save($url, $data); |
||
| 53 | return $response; |
||
| 54 | } catch (Exception $e) { |
||
| 55 | return $e; |
||
| 56 | } |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Learning Locker: Request Organisation Details |
||
| 61 | * |
||
| 62 | * @return $response |
||
| 63 | */ |
||
| 64 | public function delete() { |
||
| 65 | try { |
||
| 66 | $url = $this->url . $this->api . $this->v2 . $this->client . '/' . $this->id; |
||
| 67 | $response = $this->destroy($url); |
||
| 68 | return $response; |
||
| 69 | } catch (Exception $e) { |
||
| 70 | return $e; |
||
| 71 | } |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Learning Locker: Request Organisation Details |
||
| 76 | * |
||
| 77 | * @return $response |
||
| 78 | */ |
||
| 79 | public function create($data = null) { |
||
| 86 | } |
||
| 87 | } |
||
| 88 | |||
| 89 | } |
||
| 90 |