Total Complexity | 11 |
Total Lines | 79 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | class StoreHandler extends APIHandler { |
||
8 | |||
9 | private $store = '/lrs'; |
||
10 | private $api = '/api'; |
||
11 | private $v1 = '/v1'; |
||
|
|||
12 | private $v2 = '/v2'; |
||
13 | |||
14 | protected $headers = [ |
||
15 | 'Accept' => 'application/json', |
||
16 | 'Content-Type' => 'application/json' |
||
17 | ]; |
||
18 | |||
19 | public function __construct($id = null) { |
||
20 | parent::__construct(); |
||
21 | |||
22 | $this->id = $id ? $id : null; |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * Learning Locker: Request Organisation Details |
||
27 | * |
||
28 | * @return $response |
||
29 | */ |
||
30 | public function get($selected = []) { |
||
31 | try { |
||
32 | $url = $this->url . $this->api . $this->v2 . $this->store . '/' . $this->id ?? $this->id; |
||
33 | $response = $this->request($url); |
||
34 | |||
35 | if ($selected) $response = $this->select($selected, $response); |
||
36 | |||
37 | return $response; |
||
38 | |||
39 | } catch (Exception $e) { |
||
40 | return $e; |
||
41 | } |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Learning Locker: Update Store |
||
46 | * |
||
47 | * @return $response |
||
48 | */ |
||
49 | public function update($data) { |
||
50 | try { |
||
51 | $url = $this->url . $this->api . $this->v2 . $this->store . '/' . $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() { |
||
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 |