1 | <?php |
||
7 | abstract class Endpoint |
||
8 | { |
||
9 | /** |
||
10 | * The Client object. |
||
11 | * |
||
12 | * @var Client |
||
13 | */ |
||
14 | protected $client; |
||
15 | |||
16 | /** |
||
17 | * The client branch id. |
||
18 | * |
||
19 | * @var int |
||
20 | */ |
||
21 | protected $branchId; |
||
22 | |||
23 | /** |
||
24 | * Create a new Endpoint instance. |
||
25 | * |
||
26 | * @param Client $client |
||
27 | */ |
||
28 | public function __construct(Client $client) |
||
32 | |||
33 | /** |
||
34 | * Set the client branch id. |
||
35 | * |
||
36 | * @param int $branchId |
||
37 | * |
||
38 | * @return self |
||
39 | */ |
||
40 | public function setBranch($branchId) |
||
47 | |||
48 | /** |
||
49 | * Execute a page request. |
||
50 | * |
||
51 | * @param string $point |
||
52 | * @param array $query |
||
53 | * |
||
54 | * @return stdClass |
||
55 | */ |
||
56 | protected function page($point, array $query = []) |
||
57 | { |
||
58 | $query['pageSize'] = isset($query['pageSize']) ? $query['pageSize'] : 100; |
||
59 | $query['start'] = isset($query['start']) ? $query['start'] : 0; |
||
60 | |||
61 | return $this->run('GET', $point, ['query' => $query]); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Run the endpoint operation. |
||
66 | * |
||
67 | * @return stdObject |
||
68 | */ |
||
69 | protected function run($method, $endpoint, array $data = []) |
||
83 | } |
||
84 |