1 | <?php |
||
15 | trait MakesHttpRequests |
||
16 | { |
||
17 | /** |
||
18 | * Make a GET request to ActiveCampaign and return the response. |
||
19 | * |
||
20 | * @param string $uri |
||
21 | * @param array $payload |
||
22 | * |
||
23 | * @throws \TestMonitor\ActiveCampaign\Exceptions\FailedActionException |
||
24 | * @throws \TestMonitor\ActiveCampaign\Exceptions\NotFoundException |
||
25 | * @throws \TestMonitor\ActiveCampaign\Exceptions\ValidationException |
||
26 | * |
||
27 | * @return mixed |
||
28 | */ |
||
29 | private function get($uri, $payload = []) |
||
33 | |||
34 | /** |
||
35 | * Make a POST request to ActiveCampaign and return the response. |
||
36 | * |
||
37 | * @param string $uri |
||
38 | * @param array $payload |
||
39 | * |
||
40 | * @throws \TestMonitor\ActiveCampaign\Exceptions\FailedActionException |
||
41 | * @throws \TestMonitor\ActiveCampaign\Exceptions\NotFoundException |
||
42 | * @throws \TestMonitor\ActiveCampaign\Exceptions\ValidationException |
||
43 | * |
||
44 | * @return mixed |
||
45 | */ |
||
46 | private function post($uri, array $payload = []) |
||
50 | |||
51 | /** |
||
52 | * Make a PUT request to ActiveCampaign and return the response. |
||
53 | * |
||
54 | * @param string $uri |
||
55 | * @param array $payload |
||
56 | * |
||
57 | * @throws \TestMonitor\ActiveCampaign\Exceptions\FailedActionException |
||
58 | * @throws \TestMonitor\ActiveCampaign\Exceptions\NotFoundException |
||
59 | * @throws \TestMonitor\ActiveCampaign\Exceptions\ValidationException |
||
60 | * |
||
61 | * @return mixed |
||
62 | */ |
||
63 | private function put($uri, array $payload = []) |
||
67 | |||
68 | /** |
||
69 | * Make a DELETE request to ActiveCampaign and return the response. |
||
70 | * |
||
71 | * @param string $uri |
||
72 | * @param array $payload |
||
73 | * |
||
74 | * @throws \TestMonitor\ActiveCampaign\Exceptions\FailedActionException |
||
75 | * @throws \TestMonitor\ActiveCampaign\Exceptions\NotFoundException |
||
76 | * @throws \TestMonitor\ActiveCampaign\Exceptions\ValidationException |
||
77 | * |
||
78 | * @return mixed |
||
79 | */ |
||
80 | private function delete($uri, array $payload = []) |
||
84 | |||
85 | /** |
||
86 | * Make request to ActiveCampaign and return the response. |
||
87 | * |
||
88 | * @param string $verb |
||
89 | * @param string $uri |
||
90 | * @param array $payload |
||
91 | * |
||
92 | * @throws \TestMonitor\ActiveCampaign\Exceptions\FailedActionException |
||
93 | * @throws \TestMonitor\ActiveCampaign\Exceptions\NotFoundException |
||
94 | * @throws \TestMonitor\ActiveCampaign\Exceptions\ValidationException |
||
95 | * |
||
96 | * @return mixed |
||
97 | */ |
||
98 | private function request($verb, $uri, array $payload = []) |
||
114 | |||
115 | /** |
||
116 | * @param \Psr\Http\Message\ResponseInterface $response |
||
117 | * |
||
118 | * @throws \TestMonitor\ActiveCampaign\Exceptions\ValidationException |
||
119 | * @throws \TestMonitor\ActiveCampaign\Exceptions\NotFoundException |
||
120 | * @throws \TestMonitor\ActiveCampaign\Exceptions\FailedActionException |
||
121 | * @throws \Exception |
||
122 | * |
||
123 | * @return void |
||
124 | */ |
||
125 | private function handleRequestError(ResponseInterface $response) |
||
141 | } |
||
142 |