@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | } |
@@ -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 | /** |
@@ -6,51 +6,51 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | class ProgressHandler 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 $saas_enterprise_domain = 'https://saas.learninglocker.net'; |
|
| 30 | - private $journey_progress = '/journeyProgress'; |
|
| 31 | - private $api = '/api'; |
|
| 32 | - private $v2 = '/v2'; |
|
| 29 | + private $saas_enterprise_domain = 'https://saas.learninglocker.net'; |
|
| 30 | + private $journey_progress = '/journeyProgress'; |
|
| 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 | - /** |
|
| 39 | - * Construct the Learning Locker URL |
|
| 40 | - * |
|
| 41 | - * @param string|null $id |
|
| 42 | - * @return string |
|
| 43 | - */ |
|
| 44 | - public function url(string $id = null) { |
|
| 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->client, '/'), $id ?? $id]); |
| 46 | - } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Learning Locker: Request Organisation Details |
|
| 50 | - * |
|
| 51 | - * @return $response |
|
| 52 | - */ |
|
| 53 | - public function get() { |
|
| 48 | + /** |
|
| 49 | + * Learning Locker: Request Organisation Details |
|
| 50 | + * |
|
| 51 | + * @return $response |
|
| 52 | + */ |
|
| 53 | + public function get() { |
|
| 54 | 54 | try { |
| 55 | 55 | $url = $this->url . $this->api . $this->v2 . $this->journey_progress . '/' . $this->id ?? $this->id; |
| 56 | 56 | $response = $this->getFromLearningLocker($url); |
@@ -58,14 +58,14 @@ discard block |
||
| 58 | 58 | } catch (Exception $e) { |
| 59 | 59 | return $e; |
| 60 | 60 | } |
| 61 | - } |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Learning Locker: Request Organisation Details |
|
| 65 | - * |
|
| 66 | - * @return $response |
|
| 67 | - */ |
|
| 68 | - public function update($data) { |
|
| 63 | + /** |
|
| 64 | + * Learning Locker: Request Organisation Details |
|
| 65 | + * |
|
| 66 | + * @return $response |
|
| 67 | + */ |
|
| 68 | + public function update($data) { |
|
| 69 | 69 | try { |
| 70 | 70 | $url = $this->url . $this->api . $this->v2 . $this->journey_progress . '/' . $this->id ?? $this->id; |
| 71 | 71 | $response = $this->patchToLearningLocker($url, $data); |
@@ -73,19 +73,19 @@ discard block |
||
| 73 | 73 | } catch (Exception $e) { |
| 74 | 74 | return $e; |
| 75 | 75 | } |
| 76 | - } |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Learning Locker: Request Organisation Details |
|
| 80 | - * |
|
| 81 | - * @return $response |
|
| 82 | - */ |
|
| 83 | - public function create($data = null) { |
|
| 78 | + /** |
|
| 79 | + * Learning Locker: Request Organisation Details |
|
| 80 | + * |
|
| 81 | + * @return $response |
|
| 82 | + */ |
|
| 83 | + public function create($data = null) { |
|
| 84 | 84 | try { |
| 85 | 85 | $response = $this->postToLearningLocker($this->url(), $data); |
| 86 | 86 | return $response; |
| 87 | 87 | } catch (Exception $e) { |
| 88 | 88 | return $e; |
| 89 | 89 | } |
| 90 | - } |
|
| 90 | + } |
|
| 91 | 91 | } |
@@ -6,58 +6,58 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | class JourneyHandler 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 $journey = '/journey'; |
|
| 30 | - private $api = '/api'; |
|
| 31 | - private $v2 = '/v2'; |
|
| 29 | + private $journey = '/journey'; |
|
| 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 | - /** |
|
| 39 | - * Construct the Learning Locker URL |
|
| 40 | - * |
|
| 41 | - * @param string|null $id |
|
| 42 | - * @return string |
|
| 43 | - */ |
|
| 44 | - public function url(string $id = null) { |
|
| 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->journey, '/'), $id ?? $id]); |
| 46 | - } |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Learning Locker API: Persona |
|
| 50 | - * |
|
| 51 | - * @param $id |
|
| 52 | - * @return PersonaHandler |
|
| 53 | - */ |
|
| 54 | - public function progress(string $id = null) |
|
| 55 | - { |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Learning Locker API: Persona |
|
| 50 | + * |
|
| 51 | + * @param $id |
|
| 52 | + * @return PersonaHandler |
|
| 53 | + */ |
|
| 54 | + public function progress(string $id = null) |
|
| 55 | + { |
|
| 56 | 56 | $progress = new ProgressHandler($id ? $id : null, $this->key, $this->secret, $this->url); |
| 57 | 57 | if ($progress) return $progress; |
| 58 | 58 | |
| 59 | 59 | return self::progress($id ? $id : null); |
| 60 | - } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * Learning Locker: Request Organisation Details |
@@ -93,13 +93,13 @@ discard block |
||
| 93 | 93 | * @return $response |
| 94 | 94 | */ |
| 95 | 95 | public function delete() { |
| 96 | - try { |
|
| 96 | + try { |
|
| 97 | 97 | $url = $this->url . $this->api . $this->v2 . $this->journey . '/' . $this->id; |
| 98 | 98 | $response = $this->deleteFromLearningLocker($url); |
| 99 | 99 | return $response; |
| 100 | - } catch (Exception $e) { |
|
| 101 | - return $e; |
|
| 102 | - } |
|
| 100 | + } catch (Exception $e) { |
|
| 101 | + return $e; |
|
| 102 | + } |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |