10 defined(
'JPATH_PLATFORM') or die;
33 public function createAuthorisation(array $scopes = array(), $note =
'', $url =
'')
36 $path =
'/authorizations';
39 array(
'scopes' => $scopes,
'note' => $note,
'note_url' => $url)
43 $response = $this->client->post($this->fetchUrl($path), $data);
46 if ($response->code != 201)
49 $error = json_decode($response->body);
50 throw new DomainException($error->message, $response->code);
53 return json_decode($response->body);
66 public function deleteAuthorisation($id)
69 $path =
'/authorizations/' . $id;
72 $response = $this->client->delete($this->fetchUrl($path));
75 if ($response->code != 204)
78 $error = json_decode($response->body);
79 throw new DomainException($error->message, $response->code);
82 return json_decode($response->body);
101 public function editAuthorisation($id, array $scopes = array(), array $addScopes = array(), array $removeScopes = array(), $note =
'', $url =
'')
109 $scopeData = $scopes;
112 if (!empty($addScopes))
114 $scope =
'add_scopes';
115 $scopeData = $addScopes;
118 if (!empty($removeScopes))
120 $scope =
'remove_scopes';
121 $scopeData = $removeScopes;
126 if ($scopesCount >= 2)
128 throw new RuntimeException(
'You can only send one scope key in this request.');
132 $path =
'/authorizations/' . $id;
136 $scope => $scopeData,
143 $response = $this->client->patch($this->fetchUrl($path), $data);
146 if ($response->code != 200)
149 $error = json_decode($response->body);
150 throw new DomainException($error->message, $response->code);
153 return json_decode($response->body);
167 public function getAuthorisation($id)
170 $path =
'/authorizations/' . $id;
173 $response = $this->client->get($this->fetchUrl($path));
176 if ($response->code != 200)
179 $error = json_decode($response->body);
180 throw new DomainException($error->message, $response->code);
183 return json_decode($response->body);
195 public function getAuthorisations()
198 $path =
'/authorizations';
201 $response = $this->client->get($this->fetchUrl($path));
204 if ($response->code != 200)
207 $error = json_decode($response->body);
208 throw new DomainException($error->message, $response->code);
211 return json_decode($response->body);
222 public function getRateLimit()
225 $path =
'/rate_limit';
228 $response = $this->client->get($this->fetchUrl($path));
231 if ($response->code != 200)
234 $error = json_decode($response->body);
235 throw new DomainException($error->message, $response->code);
238 return json_decode($response->body);