1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ijeffro\Laralocker\LearningLocker\Journeys; |
4
|
|
|
|
5
|
|
|
use Ijeffro\Laralocker\LearningLocker\API\APIHandler; |
6
|
|
|
use Ijeffro\Laralocker\LearningLocker\JourneyProgress\JourneyProgressHandler; |
7
|
|
|
|
8
|
|
|
class JourneyHandler extends APIHandler { |
9
|
|
|
|
10
|
|
|
private $journey = '/journey'; |
11
|
|
|
private $api = '/api'; |
12
|
|
|
private $v1 = '/v1'; |
|
|
|
|
13
|
|
|
private $v2 = '/v2'; |
14
|
|
|
|
15
|
|
|
public $journey_progress; |
16
|
|
|
|
17
|
|
|
protected $headers = [ |
18
|
|
|
'Content-Type' => 'application/json' |
19
|
|
|
]; |
20
|
|
|
|
21
|
|
|
function __construct($id = null) { |
22
|
|
|
parent::__construct(); |
23
|
|
|
$this->id = $id; |
|
|
|
|
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Learning Locker API: Clients |
28
|
|
|
* |
29
|
|
|
* @return ClientHandler |
|
|
|
|
30
|
|
|
*/ |
31
|
|
|
public function progress($id = null) |
32
|
|
|
{ |
33
|
|
|
if ($this->journey_progress) return $this->journey_progress; |
34
|
|
|
|
35
|
|
|
$this->journey_progress = new JourneyProgressHandler($id ? $id : null); |
36
|
|
|
return $this->progress($id ? $id : null); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Learning Locker: Request Organisation Details |
41
|
|
|
* |
42
|
|
|
* @return $response |
|
|
|
|
43
|
|
|
*/ |
44
|
|
|
public function get() { |
45
|
|
|
try { |
46
|
|
|
$url = $this->url . $this->api . $this->v2 . $this->journey; |
47
|
|
|
$response = $this->request($url); |
48
|
|
|
return $response; |
49
|
|
|
} catch (Exception $e) { |
|
|
|
|
50
|
|
|
return $e; |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Learning Locker: Request Organisation Details |
56
|
|
|
* |
57
|
|
|
* @return $response |
|
|
|
|
58
|
|
|
*/ |
59
|
|
|
public function update($data) { |
60
|
|
|
try { |
61
|
|
|
$url = $this->url . $this->api . $this->v2 . $this->journey . '/' . $this->id ?? $this->id; |
62
|
|
|
$response = $this->save($url, $data); |
63
|
|
|
return $response; |
64
|
|
|
} catch (Exception $e) { |
65
|
|
|
return $e; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Learning Locker: Request Organisation Details |
71
|
|
|
* |
72
|
|
|
* @return $response |
|
|
|
|
73
|
|
|
*/ |
74
|
|
|
public function delete() { |
75
|
|
|
try { |
76
|
|
|
$url = $this->url . $this->api . $this->v2 . $this->journey . '/' . $this->id; |
77
|
|
|
$response = $this->destroy($url); |
78
|
|
|
return $response; |
79
|
|
|
} catch (Exception $e) { |
80
|
|
|
return $e; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Learning Locker: Request Organisation Details |
86
|
|
|
* |
87
|
|
|
* @return $response |
|
|
|
|
88
|
|
|
*/ |
89
|
|
|
public function create($data = null) { |
90
|
|
|
try { |
91
|
|
|
$url = $this->url . $this->api . $this->v2 . $this->journey; |
92
|
|
|
$response = $this->make($url, $data); |
93
|
|
|
return $response; |
94
|
|
|
} catch (Exception $e) { |
95
|
|
|
return $e; |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
} |
100
|
|
|
|