1 | <?php |
||
2 | |||
3 | namespace Ijeffro\Laralocker\LearningLocker\Dashboards; |
||
4 | |||
5 | use Ijeffro\Laralocker\LearningLocker\API\APIHandler; |
||
6 | |||
7 | class DashboardHandler extends APIHandler implements DashboardInterface { |
||
8 | |||
9 | |||
10 | private $dashboard = '/dashboard'; |
||
11 | private $api = '/api'; |
||
12 | private $v1 = '/v1'; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
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; |
||
0 ignored issues
–
show
|
|||
22 | } |
||
23 | |||
24 | /** |
||
25 | * Learning Locker API: Get Dashboard |
||
26 | * |
||
27 | * @return $response |
||
0 ignored issues
–
show
|
|||
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) { |
||
0 ignored issues
–
show
|
|||
35 | return $e; |
||
36 | } |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Learning Locker API: Update Dashboard |
||
41 | * |
||
42 | * @param $data |
||
43 | * @return $response |
||
0 ignored issues
–
show
|
|||
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 |
||
0 ignored issues
–
show
|
|||
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 |
||
0 ignored issues
–
show
|
|||
76 | */ |
||
77 | public function create($data = null) { |
||
78 | try { |
||
79 | $url = $this->url . $this->api . $this->v2 . $this->dashboard; |
||
80 | $response = $this->make($url, $data); |
||
81 | return $response; |
||
82 | } catch (Exception $e) { |
||
83 | return $e; |
||
84 | } |
||
85 | } |
||
86 | } |
||
87 |