-
Notifications
You must be signed in to change notification settings - Fork 0
/
Api.php
46 lines (41 loc) · 1.26 KB
/
Api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace li3_flightaware;
use \lithium\data\Connections;
/**
* Lithium class to read data from the Flightaware API
*
* @author Philip Clifton
* @link http://github.com/pclifton
* @see http://flightxml.flightaware.com/soap/FlightXML2/doc
*/
class Api {
/**
* Query the Flightaware API
*
* @param string $method API endpoint
* @param array $params URL parameters for the API request
* @return array Decoded results from API
*/
public static function query($method, $params) {
$conn = Connections::get('default');
$query = array(
'query' => '{true lifeguard}'
);
$options = array(
'source' => $method
);
// @TODO: Create results wrapper class and test bad-request results
return $conn->read(new Api\Query($params), $options);
}
/**
* Permits the use of shorthand ::[API method name] for requests
*
* @param string $name Called method name
* @param array $args Arguments passed to the method
* @return array Decoded results from API
*/
public static function __callStatic($name, $args) {
// @TODO: Will we do anything else with this thing?
return static::query($name, $args);
}
}