1 | <?php |
||
5 | abstract class Resource |
||
6 | { |
||
7 | /** |
||
8 | * @var \Vindi\ApiRequester |
||
9 | */ |
||
10 | public $apiRequester; |
||
11 | |||
12 | /** |
||
13 | * Resource constructor. |
||
14 | * |
||
15 | * @param array $arguments |
||
16 | */ |
||
17 | 416 | public function __construct($arguments = []) |
|
28 | |||
29 | /** |
||
30 | * The endpoint at default state that will hit the API. |
||
31 | * |
||
32 | * @return string |
||
33 | */ |
||
34 | abstract public function endpoint(); |
||
35 | |||
36 | /** |
||
37 | * Build url that will hit the API. |
||
38 | * |
||
39 | * @param int $id The resource's id. |
||
40 | * @param string $additionalEndpoint Additional endpoint that will be appended to the URL. |
||
41 | * |
||
42 | * @return string |
||
43 | */ |
||
44 | 296 | public function url($id = null, $additionalEndpoint = null) |
|
57 | |||
58 | /** |
||
59 | * Retrieve all resources. |
||
60 | * |
||
61 | * @param array $params Pagination and Filter parameters. |
||
62 | * |
||
63 | * @return mixed |
||
64 | */ |
||
65 | 40 | public function all(array $params = []) |
|
69 | |||
70 | /** |
||
71 | * Create a new resource. |
||
72 | * |
||
73 | * @param array $form_params The request body. |
||
74 | * |
||
75 | * @return mixed |
||
76 | */ |
||
77 | 40 | public function create(array $form_params = []) |
|
81 | |||
82 | /** |
||
83 | * Retrieve a specific resource. |
||
84 | * |
||
85 | * @param int $id The resource's id. |
||
86 | * |
||
87 | * @return mixed |
||
88 | */ |
||
89 | 40 | public function retrieve($id = null) |
|
93 | |||
94 | /** |
||
95 | * Update a specific resource. |
||
96 | * |
||
97 | * @param int $id The resource's id. |
||
98 | * @param array $form_params The request body. |
||
99 | * |
||
100 | * @return mixed |
||
101 | */ |
||
102 | 40 | public function update($id = null, array $form_params = []) |
|
106 | |||
107 | /** |
||
108 | * Delete a specific resource. |
||
109 | * |
||
110 | * @param int $id The resource's id. |
||
111 | * @param array $form_params The request body. |
||
112 | * |
||
113 | * @return mixed |
||
114 | */ |
||
115 | 40 | public function delete($id = null, array $form_params = []) |
|
119 | |||
120 | /** |
||
121 | * Make a GET request to an additional endpoint for a specific resource. |
||
122 | * |
||
123 | * @param int $id The resource's id. |
||
124 | * @param string $additionalEndpoint Additional endpoint that will be appended to the URL. |
||
125 | * |
||
126 | * @return mixed |
||
127 | */ |
||
128 | 42 | public function get($id = null, $additionalEndpoint = null) |
|
132 | |||
133 | /** |
||
134 | * Make a POST request to an additional endpoint for a specific resource. |
||
135 | * |
||
136 | * @param int $id The resource's id. |
||
137 | * @param string $additionalEndpoint Additional endpoint that will be appended to the URL. |
||
138 | * @param array $form_params The request body. |
||
139 | * |
||
140 | * @return mixed |
||
141 | */ |
||
142 | 54 | public function post($id = null, $additionalEndpoint = null, array $form_params = []) |
|
146 | |||
147 | /** |
||
148 | * Return the last response from a preview request |
||
149 | * |
||
150 | * @return mixed |
||
151 | */ |
||
152 | 80 | public function getLastResponse() |
|
156 | } |
||
157 |