@@ -6,68 +6,68 @@ |
||
6 | 6 | |
7 | 7 | class ForwardingHandler extends APIHandler { |
8 | 8 | |
9 | - /** |
|
10 | - * Learning Locker Conection Details |
|
11 | - * |
|
12 | - * @param string|null $id |
|
13 | - * @param string|null $key |
|
14 | - * @param string|null $secret |
|
15 | - * @param string|null $url |
|
16 | - * |
|
17 | - * @return void |
|
18 | - */ |
|
19 | - public function __construct(string $id = null, string $key = null, string $secret = null, string $url = null) |
|
20 | - { |
|
9 | + /** |
|
10 | + * Learning Locker Conection Details |
|
11 | + * |
|
12 | + * @param string|null $id |
|
13 | + * @param string|null $key |
|
14 | + * @param string|null $secret |
|
15 | + * @param string|null $url |
|
16 | + * |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + public function __construct(string $id = null, string $key = null, string $secret = null, string $url = null) |
|
20 | + { |
|
21 | 21 | $this->id = $id ? (string) $id : null; |
22 | 22 | $this->key = $key ? (string) $key : null; |
23 | 23 | $this->secret = $secret ? (string) $secret : null; |
24 | 24 | $this->url = $url ? (string) $url : null; |
25 | 25 | |
26 | 26 | parent::__construct($this->key, $this->secret, $this->url); |
27 | - } |
|
27 | + } |
|
28 | 28 | |
29 | - private $statements = '/statements'; |
|
30 | - private $delete = '/delete'; |
|
31 | - private $api = '/api'; |
|
32 | - private $v2 = '/v2'; |
|
29 | + private $statements = '/statements'; |
|
30 | + private $delete = '/delete'; |
|
31 | + private $api = '/api'; |
|
32 | + private $v2 = '/v2'; |
|
33 | 33 | |
34 | - protected $headers = [ |
|
34 | + protected $headers = [ |
|
35 | 35 | 'Content-Type' => 'application/json', |
36 | - ]; |
|
36 | + ]; |
|
37 | 37 | |
38 | 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->statement_forwarding . '/' . $this->id ?? $this->id; |
|
47 | - $response = $this->getFromLearningLocker($url); |
|
48 | - return $response; |
|
49 | - } catch (Exception $e) { |
|
50 | - return $e; |
|
51 | - } |
|
52 | - } |
|
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->statement_forwarding . '/' . $this->id ?? $this->id; |
|
47 | + $response = $this->getFromLearningLocker($url); |
|
48 | + return $response; |
|
49 | + } catch (Exception $e) { |
|
50 | + return $e; |
|
51 | + } |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Learning Locker: Request Organisation Details |
|
56 | - * |
|
57 | - * @return $response |
|
58 | - */ |
|
59 | - public function delete() { |
|
60 | - try { |
|
61 | - $url = $this->url . $this->api . $this->v2 . $this->store . '/' . $this->id; |
|
62 | - $response = $this->deleteFromLearningLocker($url); |
|
63 | - return $response; |
|
64 | - } catch (Exception $e) { |
|
65 | - return $e; |
|
66 | - } |
|
67 | - } |
|
54 | + /** |
|
55 | + * Learning Locker: Request Organisation Details |
|
56 | + * |
|
57 | + * @return $response |
|
58 | + */ |
|
59 | + public function delete() { |
|
60 | + try { |
|
61 | + $url = $this->url . $this->api . $this->v2 . $this->store . '/' . $this->id; |
|
62 | + $response = $this->deleteFromLearningLocker($url); |
|
63 | + return $response; |
|
64 | + } catch (Exception $e) { |
|
65 | + return $e; |
|
66 | + } |
|
67 | + } |
|
68 | 68 | |
69 | 69 | |
70 | - public function single() { |
|
70 | + public function single() { |
|
71 | 71 | |
72 | - } |
|
72 | + } |
|
73 | 73 | } |
@@ -6,119 +6,119 @@ |
||
6 | 6 | |
7 | 7 | class StatementHandler extends APIHandler { |
8 | 8 | |
9 | - /** |
|
10 | - * Learning Locker Conection Details |
|
11 | - * |
|
12 | - * @param string|null $id |
|
13 | - * @param string|null $key |
|
14 | - * @param string|null $secret |
|
15 | - * @param string|null $url |
|
16 | - * |
|
17 | - * @return void |
|
18 | - */ |
|
19 | - public function __construct(string $id = null, string $key = null, string $secret = null, string $url = null) |
|
20 | - { |
|
9 | + /** |
|
10 | + * Learning Locker Conection Details |
|
11 | + * |
|
12 | + * @param string|null $id |
|
13 | + * @param string|null $key |
|
14 | + * @param string|null $secret |
|
15 | + * @param string|null $url |
|
16 | + * |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + public function __construct(string $id = null, string $key = null, string $secret = null, string $url = null) |
|
20 | + { |
|
21 | 21 | $this->id = $id ? (string) $id : null; |
22 | 22 | $this->key = $key ? (string) $key : null; |
23 | 23 | $this->secret = $secret ? (string) $secret : null; |
24 | 24 | $this->url = $url ? (string) $url : null; |
25 | 25 | |
26 | 26 | parent::__construct($this->key, $this->secret, $this->url); |
27 | - } |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | - private $statements = '/statement'; |
|
31 | - private $api = '/api'; |
|
32 | - private $v2 = '/v2'; |
|
30 | + private $statements = '/statement'; |
|
31 | + private $api = '/api'; |
|
32 | + private $v2 = '/v2'; |
|
33 | 33 | |
34 | - public $statement_forwarding; |
|
34 | + public $statement_forwarding; |
|
35 | 35 | |
36 | - protected $headers = [ |
|
36 | + protected $headers = [ |
|
37 | 37 | 'Content-Type' => 'application/json' |
38 | - ]; |
|
39 | - |
|
40 | - /** |
|
41 | - * Learning Locker Statement Forwarding |
|
42 | - * |
|
43 | - * @param string|null $id |
|
44 | - * @return ForwardingHandler |
|
45 | - */ |
|
46 | - public function forwarding(string $id = null) |
|
47 | - { |
|
38 | + ]; |
|
39 | + |
|
40 | + /** |
|
41 | + * Learning Locker Statement Forwarding |
|
42 | + * |
|
43 | + * @param string|null $id |
|
44 | + * @return ForwardingHandler |
|
45 | + */ |
|
46 | + public function forwarding(string $id = null) |
|
47 | + { |
|
48 | 48 | $statement_forwarding = new ForwardingHandler($id ? $id : null, $this->key, $this->secret, $this->url); |
49 | 49 | if ($statement_forwarding) return $statement_forwarding; |
50 | 50 | |
51 | 51 | return self::statementForwarding($id ? $id : null); |
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Construct the Learning Locker URL |
|
56 | - * |
|
57 | - * @param string|null $id |
|
58 | - * @return string |
|
59 | - */ |
|
60 | - public function url(string $id = null) { |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Construct the Learning Locker URL |
|
56 | + * |
|
57 | + * @param string|null $id |
|
58 | + * @return string |
|
59 | + */ |
|
60 | + public function url(string $id = null) { |
|
61 | 61 | return implode('/', [trim($this->url . $this->api . $this->v2 . $this->statements, '/'), $id ?? $id]); |
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * Learning Locker: Get Clients |
|
66 | - * |
|
67 | - * @param array $selected |
|
68 | - * @return object $response |
|
69 | - */ |
|
70 | - public function get(array $selected = []) { |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * Learning Locker: Get Clients |
|
66 | + * |
|
67 | + * @param array $selected |
|
68 | + * @return object $response |
|
69 | + */ |
|
70 | + public function get(array $selected = []) { |
|
71 | 71 | try { |
72 | - $response = $this->getFromLearningLocker($this->url($this->id ?? $this->id)); |
|
72 | + $response = $this->getFromLearningLocker($this->url($this->id ?? $this->id)); |
|
73 | 73 | |
74 | - if ($selected) $response = $this->select($selected, $response); |
|
74 | + if ($selected) $response = $this->select($selected, $response); |
|
75 | 75 | |
76 | - return $response; |
|
76 | + return $response; |
|
77 | 77 | } catch (Exception $e) { |
78 | - return $e; |
|
78 | + return $e; |
|
79 | + } |
|
79 | 80 | } |
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * Learning Locker: Update Client |
|
84 | - * |
|
85 | - * @return $response |
|
86 | - */ |
|
87 | - public function update($data) { |
|
81 | + |
|
82 | + /** |
|
83 | + * Learning Locker: Update Client |
|
84 | + * |
|
85 | + * @return $response |
|
86 | + */ |
|
87 | + public function update($data) { |
|
88 | 88 | try { |
89 | - $response = $this->patchToLearningLocker($this->url($this->id ?? $this->id), $data); |
|
89 | + $response = $this->patchToLearningLocker($this->url($this->id ?? $this->id), $data); |
|
90 | 90 | |
91 | - return $response; |
|
91 | + return $response; |
|
92 | 92 | } catch (Exception $e) { |
93 | - return $e; |
|
93 | + return $e; |
|
94 | + } |
|
94 | 95 | } |
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * Learning Locker: Delete Client |
|
99 | - * |
|
100 | - * @return $response |
|
101 | - */ |
|
102 | - public function delete() { |
|
96 | + |
|
97 | + /** |
|
98 | + * Learning Locker: Delete Client |
|
99 | + * |
|
100 | + * @return $response |
|
101 | + */ |
|
102 | + public function delete() { |
|
103 | 103 | try { |
104 | - $response = $this->deleteFromLearningLocker($this->url($this->id)); |
|
105 | - return $response; |
|
104 | + $response = $this->deleteFromLearningLocker($this->url($this->id)); |
|
105 | + return $response; |
|
106 | 106 | } catch (Exception $e) { |
107 | - return $e; |
|
107 | + return $e; |
|
108 | 108 | } |
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Learning Locker: Request Organisation Details |
|
113 | - * |
|
114 | - * @return $response |
|
115 | - */ |
|
116 | - public function create($data = null) { |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Learning Locker: Request Organisation Details |
|
113 | + * |
|
114 | + * @return $response |
|
115 | + */ |
|
116 | + public function create($data = null) { |
|
117 | 117 | try { |
118 | - $response = $this->postToLearningLocker($this->url(), $data); |
|
119 | - return $response; |
|
118 | + $response = $this->postToLearningLocker($this->url(), $data); |
|
119 | + return $response; |
|
120 | 120 | } catch (Exception $e) { |
121 | - Log::error('Creating Client: ' . $e, array('context' => $data)); |
|
121 | + Log::error('Creating Client: ' . $e, array('context' => $data)); |
|
122 | + } |
|
122 | 123 | } |
123 | - } |
|
124 | 124 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace Ijeffro\Laralocker\LearningLocker\Statements; |
4 | 4 | |
5 | -use Ijeffro\Laralocker\LearningLocker\API\APIHandler;; |
|
5 | +use Ijeffro\Laralocker\LearningLocker\API\APIHandler; ; |
|
6 | 6 | |
7 | 7 | class StatementHandler extends APIHandler { |
8 | 8 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @return string |
59 | 59 | */ |
60 | 60 | public function url(string $id = null) { |
61 | - return implode('/', [trim($this->url . $this->api . $this->v2 . $this->statements, '/'), $id ?? $id]); |
|
61 | + return implode('/', [ trim($this->url . $this->api . $this->v2 . $this->statements, '/'), $id ?? $id ]); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param array $selected |
68 | 68 | * @return object $response |
69 | 69 | */ |
70 | - public function get(array $selected = []) { |
|
70 | + public function get(array $selected = [ ]) { |
|
71 | 71 | try { |
72 | 72 | $response = $this->getFromLearningLocker($this->url($this->id ?? $this->id)); |
73 | 73 |
@@ -46,7 +46,9 @@ discard block |
||
46 | 46 | public function forwarding(string $id = null) |
47 | 47 | { |
48 | 48 | $statement_forwarding = new ForwardingHandler($id ? $id : null, $this->key, $this->secret, $this->url); |
49 | - if ($statement_forwarding) return $statement_forwarding; |
|
49 | + if ($statement_forwarding) { |
|
50 | + return $statement_forwarding; |
|
51 | + } |
|
50 | 52 | |
51 | 53 | return self::statementForwarding($id ? $id : null); |
52 | 54 | } |
@@ -71,7 +73,9 @@ discard block |
||
71 | 73 | try { |
72 | 74 | $response = $this->getFromLearningLocker($this->url($this->id ?? $this->id)); |
73 | 75 | |
74 | - if ($selected) $response = $this->select($selected, $response); |
|
76 | + if ($selected) { |
|
77 | + $response = $this->select($selected, $response); |
|
78 | + } |
|
75 | 79 | |
76 | 80 | return $response; |
77 | 81 | } catch (Exception $e) { |
@@ -6,103 +6,103 @@ |
||
6 | 6 | |
7 | 7 | class ForwardingHandler extends APIHandler { |
8 | 8 | |
9 | - /** |
|
10 | - * Learning Locker Conection Details |
|
11 | - * |
|
12 | - * @param string|null $id |
|
13 | - * @param string|null $key |
|
14 | - * @param string|null $secret |
|
15 | - * @param string|null $url |
|
16 | - * |
|
17 | - * @return void |
|
18 | - */ |
|
19 | - public function __construct(string $id = null, string $key = null, string $secret = null, string $url = null) |
|
20 | - { |
|
9 | + /** |
|
10 | + * Learning Locker Conection Details |
|
11 | + * |
|
12 | + * @param string|null $id |
|
13 | + * @param string|null $key |
|
14 | + * @param string|null $secret |
|
15 | + * @param string|null $url |
|
16 | + * |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + public function __construct(string $id = null, string $key = null, string $secret = null, string $url = null) |
|
20 | + { |
|
21 | 21 | $this->id = $id ? (string) $id : null; |
22 | 22 | $this->key = $key ? (string) $key : null; |
23 | 23 | $this->secret = $secret ? (string) $secret : null; |
24 | 24 | $this->url = $url ? (string) $url : null; |
25 | 25 | |
26 | 26 | parent::__construct($this->key, $this->secret, $this->url); |
27 | - } |
|
27 | + } |
|
28 | 28 | |
29 | - private $statement_forwarding = '/statementforwarding'; |
|
30 | - private $api = '/api'; |
|
31 | - private $v2 = '/v2'; |
|
29 | + private $statement_forwarding = '/statementforwarding'; |
|
30 | + private $api = '/api'; |
|
31 | + private $v2 = '/v2'; |
|
32 | 32 | |
33 | - protected $headers = [ |
|
33 | + protected $headers = [ |
|
34 | 34 | 'Content-Type' => 'application/json', |
35 | - ]; |
|
35 | + ]; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Construct the Learning Locker URL |
|
39 | - * |
|
40 | - * @param string|null $id |
|
41 | - * @return string |
|
42 | - */ |
|
43 | - public function url(string $id = null) { |
|
37 | + /** |
|
38 | + * Construct the Learning Locker URL |
|
39 | + * |
|
40 | + * @param string|null $id |
|
41 | + * @return string |
|
42 | + */ |
|
43 | + public function url(string $id = null) { |
|
44 | 44 | return implode('/', [trim($this->url . $this->api . $this->v2 . $this->statement_forwarding, '/'), $id ?? $id]); |
45 | - } |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Learning Locker: Get Clients |
|
49 | - * |
|
50 | - * @param array $selected |
|
51 | - * @return object $response |
|
52 | - */ |
|
53 | - public function get(array $selected = []) { |
|
47 | + /** |
|
48 | + * Learning Locker: Get Clients |
|
49 | + * |
|
50 | + * @param array $selected |
|
51 | + * @return object $response |
|
52 | + */ |
|
53 | + public function get(array $selected = []) { |
|
54 | 54 | try { |
55 | - if ($selected) { |
|
55 | + if ($selected) { |
|
56 | 56 | return $this->select($selected, |
57 | - $this->getFromLearningLocker( |
|
57 | + $this->getFromLearningLocker( |
|
58 | 58 | $this->url($this->id ?? $this->id) |
59 | - ) |
|
59 | + ) |
|
60 | 60 | ); |
61 | - } |
|
61 | + } |
|
62 | 62 | |
63 | - return $this->getFromLearningLocker($this->url($this->id ?? $this->id));; |
|
63 | + return $this->getFromLearningLocker($this->url($this->id ?? $this->id));; |
|
64 | 64 | } catch (Exception $e) { |
65 | - Log::error('Getting Client: ' . $e); |
|
65 | + Log::error('Getting Client: ' . $e); |
|
66 | + } |
|
66 | 67 | } |
67 | - } |
|
68 | 68 | |
69 | - /** |
|
70 | - * Learning Locker: Update Client |
|
71 | - * |
|
72 | - * @return $response |
|
73 | - */ |
|
74 | - public function update($data) { |
|
69 | + /** |
|
70 | + * Learning Locker: Update Client |
|
71 | + * |
|
72 | + * @return $response |
|
73 | + */ |
|
74 | + public function update($data) { |
|
75 | 75 | try { |
76 | - return $this->patchToLearningLocker($this->url($this->id ?? $this->id), $data);; |
|
76 | + return $this->patchToLearningLocker($this->url($this->id ?? $this->id), $data);; |
|
77 | 77 | } catch (Exception $e) { |
78 | - Log::error('Updating Client: ' . $e, array('context' => $data)); |
|
78 | + Log::error('Updating Client: ' . $e, array('context' => $data)); |
|
79 | + } |
|
79 | 80 | } |
80 | - } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Learning Locker: Delete Client |
|
84 | - * |
|
85 | - * @return $response |
|
86 | - */ |
|
87 | - public function delete() { |
|
82 | + /** |
|
83 | + * Learning Locker: Delete Client |
|
84 | + * |
|
85 | + * @return $response |
|
86 | + */ |
|
87 | + public function delete() { |
|
88 | 88 | try { |
89 | - return $this->deleteFromLearningLocker($this->url($this->id)); |
|
89 | + return $this->deleteFromLearningLocker($this->url($this->id)); |
|
90 | 90 | } catch (Exception $e) { |
91 | - Log::error('Deleting Client: ' . $e); |
|
91 | + Log::error('Deleting Client: ' . $e); |
|
92 | + } |
|
92 | 93 | } |
93 | - } |
|
94 | 94 | |
95 | - /** |
|
96 | - * Learning Locker: Create Client |
|
97 | - * |
|
98 | - * @return $response |
|
99 | - */ |
|
100 | - public function create($data = null) { |
|
95 | + /** |
|
96 | + * Learning Locker: Create Client |
|
97 | + * |
|
98 | + * @return $response |
|
99 | + */ |
|
100 | + public function create($data = null) { |
|
101 | 101 | try { |
102 | - return $this->postToLearningLocker($this->url(), $data);; |
|
102 | + return $this->postToLearningLocker($this->url(), $data);; |
|
103 | 103 | } catch (Exception $e) { |
104 | - Log::error('Creating Client: ' . $e, array('context' => $data)); |
|
104 | + Log::error('Creating Client: ' . $e, array('context' => $data)); |
|
105 | + } |
|
105 | 106 | } |
106 | - } |
|
107 | 107 | |
108 | 108 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @return string |
42 | 42 | */ |
43 | 43 | public function url(string $id = null) { |
44 | - return implode('/', [trim($this->url . $this->api . $this->v2 . $this->statement_forwarding, '/'), $id ?? $id]); |
|
44 | + return implode('/', [ trim($this->url . $this->api . $this->v2 . $this->statement_forwarding, '/'), $id ?? $id ]); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param array $selected |
51 | 51 | * @return object $response |
52 | 52 | */ |
53 | - public function get(array $selected = []) { |
|
53 | + public function get(array $selected = [ ]) { |
|
54 | 54 | try { |
55 | 55 | if ($selected) { |
56 | 56 | return $this->select($selected, |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | ); |
61 | 61 | } |
62 | 62 | |
63 | - return $this->getFromLearningLocker($this->url($this->id ?? $this->id));; |
|
63 | + return $this->getFromLearningLocker($this->url($this->id ?? $this->id)); ; |
|
64 | 64 | } catch (Exception $e) { |
65 | 65 | Log::error('Getting Client: ' . $e); |
66 | 66 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function update($data) { |
75 | 75 | try { |
76 | - return $this->patchToLearningLocker($this->url($this->id ?? $this->id), $data);; |
|
76 | + return $this->patchToLearningLocker($this->url($this->id ?? $this->id), $data); ; |
|
77 | 77 | } catch (Exception $e) { |
78 | 78 | Log::error('Updating Client: ' . $e, array('context' => $data)); |
79 | 79 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function create($data = null) { |
101 | 101 | try { |
102 | - return $this->postToLearningLocker($this->url(), $data);; |
|
102 | + return $this->postToLearningLocker($this->url(), $data); ; |
|
103 | 103 | } catch (Exception $e) { |
104 | 104 | Log::error('Creating Client: ' . $e, array('context' => $data)); |
105 | 105 | } |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | |
8 | 8 | class Connection { |
9 | 9 | |
10 | - protected $url; |
|
11 | - protected $key; |
|
12 | - protected $secret; |
|
13 | - protected $headers; |
|
10 | + protected $url; |
|
11 | + protected $key; |
|
12 | + protected $secret; |
|
13 | + protected $headers; |
|
14 | 14 | |
15 | - public function __construct(string $key = null, string $secret = null, string $url = null) { |
|
15 | + public function __construct(string $key = null, string $secret = null, string $url = null) { |
|
16 | 16 | |
17 | 17 | $this->key = $key; |
18 | 18 | $this->secret = $secret; |
@@ -30,21 +30,21 @@ discard block |
||
30 | 30 | |
31 | 31 | |
32 | 32 | $this->headers = [ |
33 | - 'Accept' => 'application/json', |
|
34 | - 'Content-Type' => 'application/json' |
|
33 | + 'Accept' => 'application/json', |
|
34 | + 'Content-Type' => 'application/json' |
|
35 | 35 | ]; |
36 | 36 | |
37 | - } |
|
37 | + } |
|
38 | 38 | |
39 | - protected function client() { |
|
39 | + protected function client() { |
|
40 | 40 | return new Client(); |
41 | - } |
|
41 | + } |
|
42 | 42 | |
43 | - protected function auth() { |
|
43 | + protected function auth() { |
|
44 | 44 | return [$this->key, $this->secret]; |
45 | - } |
|
45 | + } |
|
46 | 46 | |
47 | - protected function headers() { |
|
47 | + protected function headers() { |
|
48 | 48 | return $this->headers; |
49 | - } |
|
49 | + } |
|
50 | 50 | } |
@@ -50,7 +50,7 @@ |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | protected function auth() { |
53 | - return [$this->key, $this->secret]; |
|
53 | + return [ $this->key, $this->secret ]; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | protected function headers() { |
@@ -6,176 +6,176 @@ |
||
6 | 6 | |
7 | 7 | class APIHandler extends Connection { |
8 | 8 | |
9 | - /** |
|
10 | - * Learning Locker Conection Details |
|
11 | - * |
|
12 | - * @param string $key |
|
13 | - * @param string $secret |
|
14 | - * @param string $url |
|
15 | - * |
|
16 | - * @return void |
|
17 | - */ |
|
18 | - public function __construct($key = null, $secret = null, $url = null) { |
|
9 | + /** |
|
10 | + * Learning Locker Conection Details |
|
11 | + * |
|
12 | + * @param string $key |
|
13 | + * @param string $secret |
|
14 | + * @param string $url |
|
15 | + * |
|
16 | + * @return void |
|
17 | + */ |
|
18 | + public function __construct($key = null, $secret = null, $url = null) { |
|
19 | 19 | $this->key = $key ? $key : null; |
20 | 20 | $this->secret = $secret ? $secret : null; |
21 | 21 | $this->url = $url ? $url : null; |
22 | 22 | |
23 | 23 | parent::__construct($this->key, $this->secret, $this->url); |
24 | - } |
|
25 | - |
|
26 | - const AUTH = 'auth'; |
|
27 | - const BODY = 'body'; |
|
28 | - const HEADERS = 'headers'; |
|
29 | - |
|
30 | - /** |
|
31 | - * Prepare Request Data |
|
32 | - * |
|
33 | - * @param string $data |
|
34 | - * @return object |
|
35 | - */ |
|
36 | - public function data(string $data) { |
|
24 | + } |
|
25 | + |
|
26 | + const AUTH = 'auth'; |
|
27 | + const BODY = 'body'; |
|
28 | + const HEADERS = 'headers'; |
|
29 | + |
|
30 | + /** |
|
31 | + * Prepare Request Data |
|
32 | + * |
|
33 | + * @param string $data |
|
34 | + * @return object |
|
35 | + */ |
|
36 | + public function data(string $data) { |
|
37 | 37 | return json_encode($data); |
38 | - } |
|
39 | - |
|
40 | - /** |
|
41 | - * Prepare Request Response |
|
42 | - * |
|
43 | - * @param object $response |
|
44 | - * @return array |
|
45 | - */ |
|
46 | - public function response($response) { |
|
38 | + } |
|
39 | + |
|
40 | + /** |
|
41 | + * Prepare Request Response |
|
42 | + * |
|
43 | + * @param object $response |
|
44 | + * @return array |
|
45 | + */ |
|
46 | + public function response($response) { |
|
47 | 47 | return json_decode($response->getBody()->getContents()); |
48 | - } |
|
49 | - |
|
50 | - /** |
|
51 | - * Learning Locker: Requst URL |
|
52 | - * |
|
53 | - * @return $response |
|
54 | - */ |
|
55 | - public function getFromLearningLocker($url) { |
|
48 | + } |
|
49 | + |
|
50 | + /** |
|
51 | + * Learning Locker: Requst URL |
|
52 | + * |
|
53 | + * @return $response |
|
54 | + */ |
|
55 | + public function getFromLearningLocker($url) { |
|
56 | 56 | try { |
57 | - $response = $this->client()->get($url, [ |
|
57 | + $response = $this->client()->get($url, [ |
|
58 | 58 | self::AUTH => $this->auth(), |
59 | 59 | self::HEADERS => $this->headers() |
60 | - ]); |
|
60 | + ]); |
|
61 | 61 | |
62 | - if ( $response->getStatusCode() === 404 ) return null; |
|
62 | + if ( $response->getStatusCode() === 404 ) return null; |
|
63 | 63 | |
64 | - return $this->response($response); |
|
64 | + return $this->response($response); |
|
65 | 65 | } catch (ClientException $e) { |
66 | - Log::error($e); |
|
66 | + Log::error($e); |
|
67 | + } |
|
67 | 68 | } |
68 | - } |
|
69 | 69 | |
70 | - public function patchToLearningLocker($url, $data) |
|
71 | - { |
|
70 | + public function patchToLearningLocker($url, $data) |
|
71 | + { |
|
72 | 72 | try { |
73 | - $response = $this->client()->patch($url, [ |
|
73 | + $response = $this->client()->patch($url, [ |
|
74 | 74 | self::AUTH => $this->auth(), |
75 | 75 | self::HEADERS => $this->headers(), |
76 | 76 | self::BODY => $this->data($data) |
77 | - ]); |
|
77 | + ]); |
|
78 | 78 | |
79 | - if ( $response->getStatusCode() === 404 ) return null; |
|
79 | + if ( $response->getStatusCode() === 404 ) return null; |
|
80 | 80 | |
81 | - return $this->response($response); |
|
81 | + return $this->response($response); |
|
82 | 82 | } catch (ClientException $e) { |
83 | - Log::error($e); |
|
83 | + Log::error($e); |
|
84 | + } |
|
84 | 85 | } |
85 | - } |
|
86 | 86 | |
87 | - public function deleteFromLearningLocker(string $url) |
|
88 | - { |
|
87 | + public function deleteFromLearningLocker(string $url) |
|
88 | + { |
|
89 | 89 | try { |
90 | - $response = $this->client()->delete($url, [ |
|
91 | - self::AUTH => $this->auth(), |
|
92 | - self::HEADERS => $this->headers() |
|
93 | - ]); |
|
90 | + $response = $this->client()->delete($url, [ |
|
91 | + self::AUTH => $this->auth(), |
|
92 | + self::HEADERS => $this->headers() |
|
93 | + ]); |
|
94 | 94 | |
95 | - if ($response->getStatusCode() === 404) return null; |
|
95 | + if ($response->getStatusCode() === 404) return null; |
|
96 | 96 | |
97 | - return $this->response($response); |
|
97 | + return $this->response($response); |
|
98 | 98 | } catch (ClientException $e) { |
99 | - Log::error($e); |
|
100 | - } |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * Learning Locker Post |
|
105 | - * |
|
106 | - * @param string $url |
|
107 | - * @param string|null $data |
|
108 | - * @return Client |
|
109 | - */ |
|
110 | - public function postToLearningLocker(string $url, $data = null) |
|
111 | - { |
|
99 | + Log::error($e); |
|
100 | + } |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * Learning Locker Post |
|
105 | + * |
|
106 | + * @param string $url |
|
107 | + * @param string|null $data |
|
108 | + * @return Client |
|
109 | + */ |
|
110 | + public function postToLearningLocker(string $url, $data = null) |
|
111 | + { |
|
112 | 112 | try { |
113 | - $response = $this->client()->post($url, [ |
|
113 | + $response = $this->client()->post($url, [ |
|
114 | 114 | self::AUTH => $this->auth(), |
115 | 115 | self::HEADERS => $this->headers(), |
116 | 116 | self::BODY => $this->data($data) |
117 | - ]); |
|
117 | + ]); |
|
118 | 118 | |
119 | - return $this->response($response); |
|
119 | + return $this->response($response); |
|
120 | 120 | } catch (ClientException $e) { |
121 | - Log::error($e); |
|
121 | + Log::error($e); |
|
122 | + } |
|
122 | 123 | } |
123 | - } |
|
124 | 124 | |
125 | - public function select(array $selected = array(), $response) |
|
126 | - { |
|
125 | + public function select(array $selected = array(), $response) |
|
126 | + { |
|
127 | 127 | if (!is_array($selected) || !$response) { |
128 | - $error = [ "error" => "Select must be an array."]; |
|
129 | - return json_encode($error); |
|
128 | + $error = [ "error" => "Select must be an array."]; |
|
129 | + return json_encode($error); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | if ($selected) { |
133 | - $response = (array) json_decode($response); |
|
134 | - $items = []; |
|
133 | + $response = (array) json_decode($response); |
|
134 | + $items = []; |
|
135 | 135 | |
136 | - foreach($selected as $select) { |
|
136 | + foreach($selected as $select) { |
|
137 | 137 | $search = array_key_exists($select, $response); |
138 | 138 | |
139 | 139 | if ($search === true) { |
140 | - $items[$select] = $response[$select]; |
|
140 | + $items[$select] = $response[$select]; |
|
141 | + } |
|
141 | 142 | } |
142 | - } |
|
143 | 143 | |
144 | - return json_encode($items); |
|
144 | + return json_encode($items); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | return $response; |
148 | - } |
|
148 | + } |
|
149 | 149 | |
150 | 150 | |
151 | 151 | |
152 | 152 | |
153 | - public function checkLearningLocker() |
|
154 | - { |
|
153 | + public function checkLearningLocker() |
|
154 | + { |
|
155 | 155 | try { |
156 | - $domain = Config::get("laralocker.learning_locker.api.url"); |
|
157 | - $url = $domain . '/api'; |
|
158 | - $response = $this->client()->get($url, [ |
|
159 | - 'auth' => $this->auth(), |
|
160 | - 'headers' => $this->headers() |
|
161 | - ]); |
|
162 | - |
|
163 | - if ($response->getStatusCode() === 200) { |
|
156 | + $domain = Config::get("laralocker.learning_locker.api.url"); |
|
157 | + $url = $domain . '/api'; |
|
158 | + $response = $this->client()->get($url, [ |
|
159 | + 'auth' => $this->auth(), |
|
160 | + 'headers' => $this->headers() |
|
161 | + ]); |
|
162 | + |
|
163 | + if ($response->getStatusCode() === 200) { |
|
164 | 164 | return true; |
165 | - } |
|
165 | + } |
|
166 | 166 | |
167 | - return $response->getBody()->getContents(); |
|
167 | + return $response->getBody()->getContents(); |
|
168 | 168 | } catch (ClientException $e) { |
169 | - Log::error($e); |
|
170 | - } |
|
171 | - } |
|
172 | - // dd($this->headers()); |
|
173 | - // $response = $client->get('http://httpbin.org/get'); |
|
174 | - // $response = $client->delete('http://httpbin.org/delete'); |
|
175 | - // $response = $client->head('http://httpbin.org/get'); |
|
176 | - // $response = $client->options('http://httpbin.org/get'); |
|
177 | - // $response = $client->patch('http://httpbin.org/patch'); |
|
178 | - // $reponse = $client->post('http://httpbin.org/post'); |
|
179 | - // $response = $client->put('http://httpbin.org/put'); |
|
169 | + Log::error($e); |
|
170 | + } |
|
171 | + } |
|
172 | + // dd($this->headers()); |
|
173 | + // $response = $client->get('http://httpbin.org/get'); |
|
174 | + // $response = $client->delete('http://httpbin.org/delete'); |
|
175 | + // $response = $client->head('http://httpbin.org/get'); |
|
176 | + // $response = $client->options('http://httpbin.org/get'); |
|
177 | + // $response = $client->patch('http://httpbin.org/patch'); |
|
178 | + // $reponse = $client->post('http://httpbin.org/post'); |
|
179 | + // $response = $client->put('http://httpbin.org/put'); |
|
180 | 180 | |
181 | 181 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | self::HEADERS => $this->headers() |
60 | 60 | ]); |
61 | 61 | |
62 | - if ( $response->getStatusCode() === 404 ) return null; |
|
62 | + if ($response->getStatusCode() === 404) return null; |
|
63 | 63 | |
64 | 64 | return $this->response($response); |
65 | 65 | } catch (ClientException $e) { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | self::BODY => $this->data($data) |
77 | 77 | ]); |
78 | 78 | |
79 | - if ( $response->getStatusCode() === 404 ) return null; |
|
79 | + if ($response->getStatusCode() === 404) return null; |
|
80 | 80 | |
81 | 81 | return $this->response($response); |
82 | 82 | } catch (ClientException $e) { |
@@ -124,20 +124,20 @@ discard block |
||
124 | 124 | |
125 | 125 | public function select(array $selected = array(), $response) |
126 | 126 | { |
127 | - if (!is_array($selected) || !$response) { |
|
128 | - $error = [ "error" => "Select must be an array."]; |
|
127 | + if (!is_array($selected) || !$response) { |
|
128 | + $error = [ "error" => "Select must be an array." ]; |
|
129 | 129 | return json_encode($error); |
130 | 130 | } |
131 | 131 | |
132 | 132 | if ($selected) { |
133 | 133 | $response = (array) json_decode($response); |
134 | - $items = []; |
|
134 | + $items = [ ]; |
|
135 | 135 | |
136 | - foreach($selected as $select) { |
|
136 | + foreach ($selected as $select) { |
|
137 | 137 | $search = array_key_exists($select, $response); |
138 | 138 | |
139 | 139 | if ($search === true) { |
140 | - $items[$select] = $response[$select]; |
|
140 | + $items[ $select ] = $response[ $select ]; |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 |
@@ -59,7 +59,9 @@ discard block |
||
59 | 59 | self::HEADERS => $this->headers() |
60 | 60 | ]); |
61 | 61 | |
62 | - if ( $response->getStatusCode() === 404 ) return null; |
|
62 | + if ( $response->getStatusCode() === 404 ) { |
|
63 | + return null; |
|
64 | + } |
|
63 | 65 | |
64 | 66 | return $this->response($response); |
65 | 67 | } catch (ClientException $e) { |
@@ -76,7 +78,9 @@ discard block |
||
76 | 78 | self::BODY => $this->data($data) |
77 | 79 | ]); |
78 | 80 | |
79 | - if ( $response->getStatusCode() === 404 ) return null; |
|
81 | + if ( $response->getStatusCode() === 404 ) { |
|
82 | + return null; |
|
83 | + } |
|
80 | 84 | |
81 | 85 | return $this->response($response); |
82 | 86 | } catch (ClientException $e) { |
@@ -92,7 +96,9 @@ discard block |
||
92 | 96 | self::HEADERS => $this->headers() |
93 | 97 | ]); |
94 | 98 | |
95 | - if ($response->getStatusCode() === 404) return null; |
|
99 | + if ($response->getStatusCode() === 404) { |
|
100 | + return null; |
|
101 | + } |
|
96 | 102 | |
97 | 103 | return $this->response($response); |
98 | 104 | } catch (ClientException $e) { |
@@ -6,104 +6,104 @@ |
||
6 | 6 | |
7 | 7 | class DownloadHandler extends APIHandler { |
8 | 8 | |
9 | - /** |
|
10 | - * Learning Locker Conection Details |
|
11 | - * |
|
12 | - * @param string|null $id |
|
13 | - * @param string|null $key |
|
14 | - * @param string|null $secret |
|
15 | - * @param string|null $url |
|
16 | - * |
|
17 | - * @return void |
|
18 | - */ |
|
19 | - public function __construct(string $id = null, string $key = null, string $secret = null, string $url = null) |
|
20 | - { |
|
9 | + /** |
|
10 | + * Learning Locker Conection Details |
|
11 | + * |
|
12 | + * @param string|null $id |
|
13 | + * @param string|null $key |
|
14 | + * @param string|null $secret |
|
15 | + * @param string|null $url |
|
16 | + * |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + public function __construct(string $id = null, string $key = null, string $secret = null, string $url = null) |
|
20 | + { |
|
21 | 21 | $this->id = $id ? (string) $id : null; |
22 | 22 | $this->key = $key ? (string) $key : null; |
23 | 23 | $this->secret = $secret ? (string) $secret : null; |
24 | 24 | $this->url = $url ? (string) $url : null; |
25 | 25 | |
26 | 26 | parent::__construct($this->key, $this->secret, $this->url); |
27 | - } |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | - private $download = '/download'; |
|
31 | - private $api = '/api'; |
|
32 | - private $v2 = '/v2'; |
|
30 | + private $download = '/download'; |
|
31 | + private $api = '/api'; |
|
32 | + private $v2 = '/v2'; |
|
33 | 33 | |
34 | - protected $headers = [ |
|
34 | + protected $headers = [ |
|
35 | 35 | 'content-type' => 'application/json' |
36 | - ]; |
|
37 | - |
|
38 | - /** |
|
39 | - * Construct the Learning Locker URL |
|
40 | - * |
|
41 | - * @param string|null $id |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - public function url(string $id = null) { |
|
36 | + ]; |
|
37 | + |
|
38 | + /** |
|
39 | + * Construct the Learning Locker URL |
|
40 | + * |
|
41 | + * @param string|null $id |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + public function url(string $id = null) { |
|
45 | 45 | return implode('/', [trim($this->url . $this->api . $this->v2 . $this->download, '/'), $id ?? $id]); |
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * Learning Locker: Get Downloads |
|
50 | - * |
|
51 | - * @param array $selected |
|
52 | - * @return object $response |
|
53 | - */ |
|
54 | - public function get(array $selected = []) { |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * Learning Locker: Get Downloads |
|
50 | + * |
|
51 | + * @param array $selected |
|
52 | + * @return object $response |
|
53 | + */ |
|
54 | + public function get(array $selected = []) { |
|
55 | 55 | try { |
56 | - $response = $this->getFromLearningLocker($this->url($this->id ?? $this->id)); |
|
56 | + $response = $this->getFromLearningLocker($this->url($this->id ?? $this->id)); |
|
57 | 57 | |
58 | - if ($selected) $response = $this->select($selected, $response); |
|
58 | + if ($selected) $response = $this->select($selected, $response); |
|
59 | 59 | |
60 | - return $response; |
|
60 | + return $response; |
|
61 | 61 | } catch (Exception $e) { |
62 | - return $e; |
|
62 | + return $e; |
|
63 | 63 | } |
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * Learning Locker: Update Download |
|
68 | - * |
|
69 | - * @return $response |
|
70 | - */ |
|
71 | - public function update($data) { |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * Learning Locker: Update Download |
|
68 | + * |
|
69 | + * @return $response |
|
70 | + */ |
|
71 | + public function update($data) { |
|
72 | 72 | try { |
73 | - $response = $this->patchToLearningLocker($this->url($this->id ?? $this->id), $data); |
|
73 | + $response = $this->patchToLearningLocker($this->url($this->id ?? $this->id), $data); |
|
74 | 74 | |
75 | - return $response; |
|
75 | + return $response; |
|
76 | 76 | } catch (Exception $e) { |
77 | - return $e; |
|
77 | + return $e; |
|
78 | 78 | } |
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * Learning Locker: Delete Download |
|
83 | - * |
|
84 | - * @return $response |
|
85 | - */ |
|
86 | - public function delete() { |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * Learning Locker: Delete Download |
|
83 | + * |
|
84 | + * @return $response |
|
85 | + */ |
|
86 | + public function delete() { |
|
87 | 87 | try { |
88 | - $response = $this->deleteFromLearningLocker($this->url($this->id)); |
|
89 | - return $response; |
|
88 | + $response = $this->deleteFromLearningLocker($this->url($this->id)); |
|
89 | + return $response; |
|
90 | 90 | } catch (Exception $e) { |
91 | - return $e; |
|
91 | + return $e; |
|
92 | + } |
|
92 | 93 | } |
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Learning Locker: Create Download |
|
97 | - * |
|
98 | - * @return $response |
|
99 | - */ |
|
100 | - public function create($data = null) { |
|
94 | + |
|
95 | + /** |
|
96 | + * Learning Locker: Create Download |
|
97 | + * |
|
98 | + * @return $response |
|
99 | + */ |
|
100 | + public function create($data = null) { |
|
101 | 101 | try { |
102 | - $response = $this->postToLearningLocker($this->url(), $data); |
|
103 | - return $response; |
|
102 | + $response = $this->postToLearningLocker($this->url(), $data); |
|
103 | + return $response; |
|
104 | 104 | } catch (Exception $e) { |
105 | - Log::error('Creating Download: ' . $e, array('context' => $data)); |
|
105 | + Log::error('Creating Download: ' . $e, array('context' => $data)); |
|
106 | + } |
|
106 | 107 | } |
107 | - } |
|
108 | 108 | |
109 | 109 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @return string |
43 | 43 | */ |
44 | 44 | public function url(string $id = null) { |
45 | - return implode('/', [trim($this->url . $this->api . $this->v2 . $this->download, '/'), $id ?? $id]); |
|
45 | + return implode('/', [ trim($this->url . $this->api . $this->v2 . $this->download, '/'), $id ?? $id ]); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param array $selected |
52 | 52 | * @return object $response |
53 | 53 | */ |
54 | - public function get(array $selected = []) { |
|
54 | + public function get(array $selected = [ ]) { |
|
55 | 55 | try { |
56 | 56 | $response = $this->getFromLearningLocker($this->url($this->id ?? $this->id)); |
57 | 57 |
@@ -55,7 +55,9 @@ |
||
55 | 55 | try { |
56 | 56 | $response = $this->getFromLearningLocker($this->url($this->id ?? $this->id)); |
57 | 57 | |
58 | - if ($selected) $response = $this->select($selected, $response); |
|
58 | + if ($selected) { |
|
59 | + $response = $this->select($selected, $response); |
|
60 | + } |
|
59 | 61 | |
60 | 62 | return $response; |
61 | 63 | } catch (Exception $e) { |
@@ -8,101 +8,101 @@ |
||
8 | 8 | class AggregationHandler extends APIHandler { |
9 | 9 | |
10 | 10 | |
11 | - /** |
|
12 | - * Learning Locker Conection Details |
|
13 | - * |
|
14 | - * @param string|null $id |
|
15 | - * @param string|null $key |
|
16 | - * @param string|null $secret |
|
17 | - * @param string|null $url |
|
18 | - * |
|
19 | - * @return void |
|
20 | - */ |
|
21 | - public function __construct(string $id = null, string $key = null, string $secret = null, string $url = null) |
|
22 | - { |
|
11 | + /** |
|
12 | + * Learning Locker Conection Details |
|
13 | + * |
|
14 | + * @param string|null $id |
|
15 | + * @param string|null $key |
|
16 | + * @param string|null $secret |
|
17 | + * @param string|null $url |
|
18 | + * |
|
19 | + * @return void |
|
20 | + */ |
|
21 | + public function __construct(string $id = null, string $key = null, string $secret = null, string $url = null) |
|
22 | + { |
|
23 | 23 | $this->id = $id ? (string) $id : null; |
24 | 24 | $this->key = $key ? (string) $key : null; |
25 | 25 | $this->secret = $secret ? (string) $secret : null; |
26 | 26 | $this->url = $url ? (string) $url : null; |
27 | 27 | |
28 | 28 | parent::__construct($this->key, $this->secret, $this->url); |
29 | - } |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - private $client = '/client'; |
|
33 | - private $api = '/api'; |
|
34 | - private $v2 = '/v2'; |
|
32 | + private $client = '/client'; |
|
33 | + private $api = '/api'; |
|
34 | + private $v2 = '/v2'; |
|
35 | 35 | |
36 | - protected $headers = [ |
|
36 | + protected $headers = [ |
|
37 | 37 | 'Accept' => 'application/json', |
38 | 38 | 'Content-Type' => 'application/json' |
39 | - ]; |
|
39 | + ]; |
|
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * Construct the Learning Locker URL |
|
44 | - * |
|
45 | - * @param string|null $id |
|
46 | - * @return string |
|
47 | - */ |
|
48 | - public function url(string $id = null) { |
|
42 | + /** |
|
43 | + * Construct the Learning Locker URL |
|
44 | + * |
|
45 | + * @param string|null $id |
|
46 | + * @return string |
|
47 | + */ |
|
48 | + public function url(string $id = null) { |
|
49 | 49 | return implode('/', [trim($this->url . $this->api . $this->v2 . $this->client, '/'), $id ?? $id]); |
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * Learning Locker: Get Clients |
|
54 | - * |
|
55 | - * @param array $selected |
|
56 | - * @return object $response |
|
57 | - */ |
|
58 | - public function get(array $selected = []) { |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * Learning Locker: Get Clients |
|
54 | + * |
|
55 | + * @param array $selected |
|
56 | + * @return object $response |
|
57 | + */ |
|
58 | + public function get(array $selected = []) { |
|
59 | 59 | try { |
60 | 60 | } catch (Exception $e) { |
61 | - return $e; |
|
61 | + return $e; |
|
62 | 62 | } |
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * Learning Locker: Update Client |
|
67 | - * |
|
68 | - * @return $response |
|
69 | - */ |
|
70 | - public function update($data) { |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * Learning Locker: Update Client |
|
67 | + * |
|
68 | + * @return $response |
|
69 | + */ |
|
70 | + public function update($data) { |
|
71 | 71 | try { |
72 | - $response = $this->patchToLearningLocker($this->url($this->id ?? $this->id), $data); |
|
72 | + $response = $this->patchToLearningLocker($this->url($this->id ?? $this->id), $data); |
|
73 | 73 | |
74 | - return $response; |
|
74 | + return $response; |
|
75 | 75 | } catch (Exception $e) { |
76 | - return $e; |
|
76 | + return $e; |
|
77 | 77 | } |
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Learning Locker: Delete Client |
|
82 | - * |
|
83 | - * @return $response |
|
84 | - */ |
|
85 | - public function delete() { |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Learning Locker: Delete Client |
|
82 | + * |
|
83 | + * @return $response |
|
84 | + */ |
|
85 | + public function delete() { |
|
86 | 86 | try { |
87 | - $response = $this->deleteFromLearningLocker($this->url($this->id)); |
|
88 | - return $response; |
|
87 | + $response = $this->deleteFromLearningLocker($this->url($this->id)); |
|
88 | + return $response; |
|
89 | 89 | } catch (Exception $e) { |
90 | - return $e; |
|
90 | + return $e; |
|
91 | + } |
|
91 | 92 | } |
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Learning Locker: Request Organisation Details |
|
96 | - * |
|
97 | - * @return $response |
|
98 | - */ |
|
99 | - public function create($data = null) { |
|
93 | + |
|
94 | + /** |
|
95 | + * Learning Locker: Request Organisation Details |
|
96 | + * |
|
97 | + * @return $response |
|
98 | + */ |
|
99 | + public function create($data = null) { |
|
100 | 100 | try { |
101 | - $response = $this->postToLearningLocker($this->url(), $data); |
|
102 | - return $response; |
|
101 | + $response = $this->postToLearningLocker($this->url(), $data); |
|
102 | + return $response; |
|
103 | 103 | } catch (Exception $e) { |
104 | - Log::error('Creating Client: ' . $e, array('context' => $data)); |
|
104 | + Log::error('Creating Client: ' . $e, array('context' => $data)); |
|
105 | + } |
|
105 | 106 | } |
106 | - } |
|
107 | 107 | |
108 | 108 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @return string |
47 | 47 | */ |
48 | 48 | public function url(string $id = null) { |
49 | - return implode('/', [trim($this->url . $this->api . $this->v2 . $this->client, '/'), $id ?? $id]); |
|
49 | + return implode('/', [ trim($this->url . $this->api . $this->v2 . $this->client, '/'), $id ?? $id ]); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @param array $selected |
56 | 56 | * @return object $response |
57 | 57 | */ |
58 | - public function get(array $selected = []) { |
|
58 | + public function get(array $selected = [ ]) { |
|
59 | 59 | try { |
60 | 60 | } catch (Exception $e) { |
61 | 61 | return $e; |
@@ -6,105 +6,105 @@ |
||
6 | 6 | |
7 | 7 | class UserHandler extends APIHandler { |
8 | 8 | |
9 | - /** |
|
10 | - * Learning Locker Conection Details |
|
11 | - * |
|
12 | - * @param string|null $id |
|
13 | - * @param string|null $key |
|
14 | - * @param string|null $secret |
|
15 | - * @param string|null $url |
|
16 | - * |
|
17 | - * @return void |
|
18 | - */ |
|
19 | - public function __construct(string $id = null, string $key = null, string $secret = null, string $url = null) |
|
20 | - { |
|
9 | + /** |
|
10 | + * Learning Locker Conection Details |
|
11 | + * |
|
12 | + * @param string|null $id |
|
13 | + * @param string|null $key |
|
14 | + * @param string|null $secret |
|
15 | + * @param string|null $url |
|
16 | + * |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + public function __construct(string $id = null, string $key = null, string $secret = null, string $url = null) |
|
20 | + { |
|
21 | 21 | $this->id = $id ? (string) $id : null; |
22 | 22 | $this->key = $key ? (string) $key : null; |
23 | 23 | $this->secret = $secret ? (string) $secret : null; |
24 | 24 | $this->url = $url ? (string) $url : null; |
25 | 25 | |
26 | 26 | parent::__construct($this->key, $this->secret, $this->url); |
27 | - } |
|
27 | + } |
|
28 | 28 | |
29 | - private $user = '/user'; |
|
30 | - private $api = '/api'; |
|
31 | - private $v2 = '/v2'; |
|
29 | + private $user = '/user'; |
|
30 | + private $api = '/api'; |
|
31 | + private $v2 = '/v2'; |
|
32 | 32 | |
33 | - protected $headers = [ |
|
33 | + protected $headers = [ |
|
34 | 34 | 'Accept' => 'application/json', |
35 | 35 | 'Content-Type' => 'application/json' |
36 | - ]; |
|
36 | + ]; |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Construct the Learning Locker URL |
|
41 | - * |
|
42 | - * @param string|null $id |
|
43 | - * @return string |
|
44 | - */ |
|
45 | - public function url(string $id = null) { |
|
39 | + /** |
|
40 | + * Construct the Learning Locker URL |
|
41 | + * |
|
42 | + * @param string|null $id |
|
43 | + * @return string |
|
44 | + */ |
|
45 | + public function url(string $id = null) { |
|
46 | 46 | return implode('/', [trim($this->url . $this->api . $this->v2 . $this->user, '/'), $id ?? $id]); |
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * Learning Locker: Get Users |
|
51 | - * |
|
52 | - * @param array $selected |
|
53 | - * @return object $response |
|
54 | - */ |
|
55 | - public function get(array $selected = []) { |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * Learning Locker: Get Users |
|
51 | + * |
|
52 | + * @param array $selected |
|
53 | + * @return object $response |
|
54 | + */ |
|
55 | + public function get(array $selected = []) { |
|
56 | 56 | try { |
57 | - $response = $this->getFromLearningLocker($this->url($this->id ?? $this->id)); |
|
57 | + $response = $this->getFromLearningLocker($this->url($this->id ?? $this->id)); |
|
58 | 58 | |
59 | - if ($selected) $response = $this->select($selected, $response); |
|
59 | + if ($selected) $response = $this->select($selected, $response); |
|
60 | 60 | |
61 | - return $response; |
|
61 | + return $response; |
|
62 | 62 | } catch (Exception $e) { |
63 | - Log::error('Getting User: ' . $e); |
|
63 | + Log::error('Getting User: ' . $e); |
|
64 | 64 | } |
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * Learning Locker: Update User |
|
69 | - * |
|
70 | - * @return $response |
|
71 | - */ |
|
72 | - public function update($data) { |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * Learning Locker: Update User |
|
69 | + * |
|
70 | + * @return $response |
|
71 | + */ |
|
72 | + public function update($data) { |
|
73 | 73 | try { |
74 | - $response = $this->patchToLearningLocker($this->url($this->id ?? $this->id), $data); |
|
74 | + $response = $this->patchToLearningLocker($this->url($this->id ?? $this->id), $data); |
|
75 | 75 | |
76 | - return $response; |
|
76 | + return $response; |
|
77 | 77 | } catch (Exception $e) { |
78 | - Log::error('Updating User: ' . $e, array('context' => $data)); |
|
78 | + Log::error('Updating User: ' . $e, array('context' => $data)); |
|
79 | 79 | } |
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * Learning Locker: Delete User |
|
84 | - * |
|
85 | - * @return $response |
|
86 | - */ |
|
87 | - public function delete() { |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * Learning Locker: Delete User |
|
84 | + * |
|
85 | + * @return $response |
|
86 | + */ |
|
87 | + public function delete() { |
|
88 | 88 | try { |
89 | - $response = $this->deleteFromLearningLocker($this->url($this->id)); |
|
90 | - return $response; |
|
89 | + $response = $this->deleteFromLearningLocker($this->url($this->id)); |
|
90 | + return $response; |
|
91 | 91 | } catch (Exception $e) { |
92 | - Log::error('Deleting User: ' . $e); |
|
92 | + Log::error('Deleting User: ' . $e); |
|
93 | + } |
|
93 | 94 | } |
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Learning Locker: Create User |
|
98 | - * |
|
99 | - * @return $response |
|
100 | - */ |
|
101 | - public function create($data = null) { |
|
95 | + |
|
96 | + /** |
|
97 | + * Learning Locker: Create User |
|
98 | + * |
|
99 | + * @return $response |
|
100 | + */ |
|
101 | + public function create($data = null) { |
|
102 | 102 | try { |
103 | - $response = $this->postToLearningLocker($this->url(), $data); |
|
104 | - return $response; |
|
103 | + $response = $this->postToLearningLocker($this->url(), $data); |
|
104 | + return $response; |
|
105 | 105 | } catch (Exception $e) { |
106 | - Log::error('Creating User: ' . $e, array('context' => $data)); |
|
106 | + Log::error('Creating User: ' . $e, array('context' => $data)); |
|
107 | + } |
|
107 | 108 | } |
108 | - } |
|
109 | 109 | |
110 | 110 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return string |
44 | 44 | */ |
45 | 45 | public function url(string $id = null) { |
46 | - return implode('/', [trim($this->url . $this->api . $this->v2 . $this->user, '/'), $id ?? $id]); |
|
46 | + return implode('/', [ trim($this->url . $this->api . $this->v2 . $this->user, '/'), $id ?? $id ]); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param array $selected |
53 | 53 | * @return object $response |
54 | 54 | */ |
55 | - public function get(array $selected = []) { |
|
55 | + public function get(array $selected = [ ]) { |
|
56 | 56 | try { |
57 | 57 | $response = $this->getFromLearningLocker($this->url($this->id ?? $this->id)); |
58 | 58 |
@@ -56,7 +56,9 @@ |
||
56 | 56 | try { |
57 | 57 | $response = $this->getFromLearningLocker($this->url($this->id ?? $this->id)); |
58 | 58 | |
59 | - if ($selected) $response = $this->select($selected, $response); |
|
59 | + if ($selected) { |
|
60 | + $response = $this->select($selected, $response); |
|
61 | + } |
|
60 | 62 | |
61 | 63 | return $response; |
62 | 64 | } catch (Exception $e) { |
@@ -6,33 +6,33 @@ discard block |
||
6 | 6 | |
7 | 7 | class RoleHandler extends APIHandler { |
8 | 8 | |
9 | - /** |
|
10 | - * Learning Locker Conection Details |
|
11 | - * |
|
12 | - * @param string|null $id |
|
13 | - * @param string|null $key |
|
14 | - * @param string|null $secret |
|
15 | - * @param string|null $url |
|
16 | - * |
|
17 | - * @return void |
|
18 | - */ |
|
19 | - public function __construct(string $id = null, string $key = null, string $secret = null, string $url = null) |
|
20 | - { |
|
9 | + /** |
|
10 | + * Learning Locker Conection Details |
|
11 | + * |
|
12 | + * @param string|null $id |
|
13 | + * @param string|null $key |
|
14 | + * @param string|null $secret |
|
15 | + * @param string|null $url |
|
16 | + * |
|
17 | + * @return void |
|
18 | + */ |
|
19 | + public function __construct(string $id = null, string $key = null, string $secret = null, string $url = null) |
|
20 | + { |
|
21 | 21 | $this->id = $id ? (string) $id : null; |
22 | 22 | $this->key = $key ? (string) $key : null; |
23 | 23 | $this->secret = $secret ? (string) $secret : null; |
24 | 24 | $this->url = $url ? (string) $url : null; |
25 | 25 | |
26 | 26 | parent::__construct($this->key, $this->secret, $this->url); |
27 | - } |
|
27 | + } |
|
28 | 28 | |
29 | - private $role = '/role'; |
|
30 | - private $api = '/api'; |
|
31 | - private $v2 = '/v2'; |
|
29 | + private $role = '/role'; |
|
30 | + private $api = '/api'; |
|
31 | + private $v2 = '/v2'; |
|
32 | 32 | |
33 | - protected $headers = [ |
|
33 | + protected $headers = [ |
|
34 | 34 | 'content-type' => 'application/json' |
35 | - ]; |
|
35 | + ]; |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * Learning Locker: Request Organisation Details |
@@ -40,13 +40,13 @@ discard block |
||
40 | 40 | * @return $response |
41 | 41 | */ |
42 | 42 | public function get() { |
43 | - try { |
|
43 | + try { |
|
44 | 44 | $url = $this->url . $this->api . $this->v2 . $this->role . '/' . $this->id ?? $this->id; |
45 | 45 | $response = $this->getFromLearningLocker($url); |
46 | 46 | return $response; |
47 | - } catch (Exception $e) { |
|
47 | + } catch (Exception $e) { |
|
48 | 48 | return $e; |
49 | - } |
|
49 | + } |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |