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