1 | <?php |
||
26 | class Route extends HttpApi |
||
27 | { |
||
28 | /** |
||
29 | * Fetches the list of Routes. |
||
30 | * |
||
31 | * @param int $limit Maximum number of records to return. (100 by default) |
||
32 | * @param int $skip Number of records to skip. (0 by default) |
||
33 | * |
||
34 | * @return IndexResponse |
||
35 | */ |
||
36 | 1 | public function index(int $limit = 100, int $skip = 0) |
|
37 | { |
||
38 | 1 | Assert::greaterThan($limit, 0); |
|
39 | 1 | Assert::greaterThanEq($skip, 0); |
|
40 | |||
41 | $params = [ |
||
42 | 1 | 'limit' => $limit, |
|
43 | 1 | 'skip' => $skip, |
|
44 | ]; |
||
45 | |||
46 | 1 | $response = $this->httpGet('/v3/routes', $params); |
|
47 | |||
48 | 1 | return $this->hydrateResponse($response, IndexResponse::class); |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * Returns a single Route object based on its ID. |
||
53 | * |
||
54 | * @param string $routeId Route ID returned by the Routes::index() method |
||
55 | * |
||
56 | * @return ShowResponse |
||
57 | */ |
||
58 | 1 | public function show(string $routeId) |
|
66 | |||
67 | /** |
||
68 | * Creates a new Route. |
||
69 | * |
||
70 | * @param string $expression A filter expression like "match_recipient('.*@gmail.com')" |
||
71 | * @param array $actions Route action. This action is executed when the expression evaluates to True. Example: "forward('[email protected]')" |
||
72 | * @param string $description An arbitrary string |
||
73 | * @param int $priority Integer: smaller number indicates higher priority. Higher priority routes are handled first. Defaults to 0. |
||
74 | * |
||
75 | * @return CreateResponse |
||
76 | */ |
||
77 | 1 | public function create(string $expression, array $actions, string $description, int $priority = 0) |
|
92 | |||
93 | /** |
||
94 | * Updates a given Route by ID. All parameters are optional. |
||
95 | * This API call only updates the specified fields leaving others unchanged. |
||
96 | * |
||
97 | * @param string $routeId Route ID returned by the Routes::index() method |
||
98 | * @param string|null $expression A filter expression like "match_recipient('.*@gmail.com')" |
||
99 | * @param array $actions Route action. This action is executed when the expression evaluates to True. Example: "forward('[email protected]')" |
||
100 | * @param string|null $description An arbitrary string |
||
101 | * @param int|null $priority Integer: smaller number indicates higher priority. Higher priority routes are handled first. Defaults to 0. |
||
102 | * |
||
103 | * @return UpdateResponse |
||
104 | */ |
||
105 | 1 | public function update( |
|
138 | |||
139 | /** |
||
140 | * Deletes a Route based on the ID. |
||
141 | * |
||
142 | * @param string $routeId Route ID returned by the Routes::index() method |
||
143 | * |
||
144 | * @return DeleteResponse |
||
145 | */ |
||
146 | 1 | public function delete(string $routeId) |
|
154 | } |
||
155 |