| @@ 53-77 (lines=25) @@ | ||
| 50 | */ |
|
| 51 | protected $base_url = "https://hummingbird.me/"; |
|
| 52 | ||
| 53 | protected function _auth_json_call($type, $url, $json) |
|
| 54 | { |
|
| 55 | $token = $this->container->get('auth') |
|
| 56 | ->get_auth_token(); |
|
| 57 | ||
| 58 | // Set the token cookie, with the authentication token |
|
| 59 | // from the auth class. |
|
| 60 | $cookieJar = $this->cookieJar; |
|
| 61 | $cookie_data = new SetCookie([ |
|
| 62 | 'Name' => 'token', |
|
| 63 | 'Value' => $token, |
|
| 64 | 'Domain' => 'hummingbird.me' |
|
| 65 | ]); |
|
| 66 | $cookieJar->setCookie($cookie_data); |
|
| 67 | ||
| 68 | $result = $this->client->request(strtoupper($type), $url, [ |
|
| 69 | 'cookies' => $cookieJar, |
|
| 70 | 'json' => $json |
|
| 71 | ]); |
|
| 72 | ||
| 73 | return [ |
|
| 74 | 'statusCode' => $result->getStatusCode(), |
|
| 75 | 'body' => $result->getBody() |
|
| 76 | ]; |
|
| 77 | } |
|
| 78 | ||
| 79 | /** |
|
| 80 | * Add a manga to the list |
|
| @@ 119-144 (lines=26) @@ | ||
| 116 | * @param array $data |
|
| 117 | * @return array |
|
| 118 | */ |
|
| 119 | public function delete($data) |
|
| 120 | { |
|
| 121 | $id = $data['id']; |
|
| 122 | ||
| 123 | $token = $this->container->get('auth') |
|
| 124 | ->get_auth_token(); |
|
| 125 | ||
| 126 | // Set the token cookie, with the authentication token |
|
| 127 | // from the auth class. |
|
| 128 | $cookieJar = $this->cookieJar; |
|
| 129 | $cookie_data = new SetCookie([ |
|
| 130 | 'Name' => 'token', |
|
| 131 | 'Value' => $token, |
|
| 132 | 'Domain' => 'hummingbird.me' |
|
| 133 | ]); |
|
| 134 | $cookieJar->setCookie($cookie_data); |
|
| 135 | ||
| 136 | $result = $this->delete("manga_library_entries/{$id}", [ |
|
| 137 | 'cookies' => $cookieJar, |
|
| 138 | ]); |
|
| 139 | ||
| 140 | return [ |
|
| 141 | 'statusCode' => $result->getStatusCode(), |
|
| 142 | 'body' => $result->getBody() |
|
| 143 | ]; |
|
| 144 | } |
|
| 145 | ||
| 146 | /** |
|
| 147 | * Search for manga by name |
|