1 | <?php |
||
35 | class API extends BaseModel { |
||
36 | |||
37 | /** |
||
38 | * Base url for making api requests |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $base_url = ''; |
||
42 | |||
43 | /** |
||
44 | * The Guzzle http client object |
||
45 | * @var object |
||
46 | */ |
||
47 | protected $client; |
||
48 | |||
49 | /** |
||
50 | * Cookie jar object for api requests |
||
51 | * @var object |
||
52 | */ |
||
53 | protected $cookieJar; |
||
54 | |||
55 | /** |
||
56 | * Constructor |
||
57 | * |
||
58 | * @param ContainerInterface $container |
||
59 | */ |
||
60 | public function __construct(ContainerInterface $container) |
||
65 | |||
66 | /** |
||
67 | * Set up the class properties |
||
68 | * |
||
69 | * @return void |
||
70 | */ |
||
71 | protected function init() |
||
89 | |||
90 | /** |
||
91 | * Magic methods to call guzzle api client |
||
92 | * |
||
93 | * @param string $method |
||
94 | * @param array $args |
||
95 | * @return ResponseInterface|null |
||
96 | */ |
||
97 | public function __call($method, $args) |
||
117 | |||
118 | /** |
||
119 | * Get the data for the specified library entry |
||
120 | * |
||
121 | * @param string $id |
||
122 | * @param string $status |
||
123 | * @return array |
||
124 | */ |
||
125 | public function get_library_item($id, $status) |
||
136 | |||
137 | /** |
||
138 | * Sort the manga entries by their title |
||
139 | * |
||
140 | * @codeCoverageIgnore |
||
141 | * @param array $array |
||
142 | * @param string $sort_key |
||
143 | * @return void |
||
144 | */ |
||
145 | protected function sort_by_name(&$array, $sort_key) |
||
156 | |||
157 | /** |
||
158 | * Attempt login via the api |
||
159 | * |
||
160 | * @codeCoverageIgnore |
||
161 | * @param string $username |
||
162 | * @param string $password |
||
163 | * @return string|false |
||
164 | */ |
||
165 | public function authenticate($username, $password) |
||
181 | |||
182 | /** |
||
183 | * Dummy function that should be abstract. Is not abstract because |
||
184 | * this class is used concretely for authorizing API calls |
||
185 | * |
||
186 | * @TODO Refactor, and make this abstract |
||
187 | * @param string $status |
||
188 | * @return array |
||
189 | */ |
||
190 | protected function _get_list_from_api($status) |
||
194 | } |
||
195 | // End of BaseApiModel.php |