diff --git a/src/Endpoints/RulesLists.php b/src/Endpoints/RulesLists.php index 6ef83d1..3513256 100755 --- a/src/Endpoints/RulesLists.php +++ b/src/Endpoints/RulesLists.php @@ -18,15 +18,15 @@ class RulesLists implements API public function getLists(string $accountId) { - $response = $this->adapter->get('/accounts/' . $accountId . '/rules/lists'); + $response = $this->adapter->get('accounts/' . $accountId . '/rules/lists'); $this->body = json_decode($response->getBody()); - return (object)['result' => $this->body->result]; + return $this->body->result; } public function getListDetails(string $accountId, string $listId) { - $response = $this->adapter->get('/accounts/' . $accountId . '/rules/lists/' . $listId); + $response = $this->adapter->get('accounts/' . $accountId . '/rules/lists/' . $listId); $this->body = json_decode($response->getBody()); return $this->body->result; @@ -47,10 +47,10 @@ class RulesLists implements API $options['cursor'] = $cursor; } - $response = $this->adapter->get('/accounts/' . $accountId . '/rules/lists/' . $listId . '/items', $options); + $response = $this->adapter->get('accounts/' . $accountId . '/rules/lists/' . $listId . '/items', $options); $this->body = json_decode($response->getBody()); - return (object)['result' => $this->body->result, 'result_info' => $this->body->result_info]; + return (object)['result' => $this->body->result, 'result_info' => $this->body->result_info ?? null]; } public function createList(string $accountId, string $kind, string $name, string $description = '') @@ -64,7 +64,7 @@ class RulesLists implements API $options['description'] = $description; } - $response = $this->adapter->post('/accounts/' . $accountId . '/rules/lists', $options); + $response = $this->adapter->post('accounts/' . $accountId . '/rules/lists', $options); $this->body = json_decode($response->getBody()); return $this->body->result; @@ -74,19 +74,24 @@ class RulesLists implements API { $options = []; foreach ($ip as $ipAddress) { - $options['ip'] = $ipAddress; + $options[] = ['ip' => $ipAddress]; } - $response = $this->adapter->post('/accounts/' . $accountId . '/rules/lists/' . $listId . '/items', $options); + $response = $this->adapter->post('accounts/' . $accountId . '/rules/lists/' . $listId . '/items', $options); $this->body = json_decode($response->getBody()); return $this->body->result; } - public function deleteListItem(string $accountId, string $listId, string $item = '') + public function deleteListItem(string $accountId, string $listId, array $itemIds) { - $response = $this->adapter->delete('/accounts/' . $accountId . '/rules/lists/' . $listId . '/items' . ($item ? '/' . $item : '')); + $options = ['items' => []]; + foreach ($itemIds as $itemId) { + $options['items'][] = ['id' => $itemId]; + } + + $response = $this->adapter->delete('accounts/' . $accountId . '/rules/lists/' . $listId . '/items', $options); $this->body = json_decode($response->getBody()); return $this->body->result; @@ -94,7 +99,7 @@ class RulesLists implements API public function getOperationStatus(string $accountId, string $operationId) { - $response = $this->adapter->get('/accounts/' . $accountId . '/rules/lists/bulk_operations/' . $operationId); + $response = $this->adapter->get('accounts/' . $accountId . '/rules/lists/bulk_operations/' . $operationId); $this->body = json_decode($response->getBody()); return $this->body->result; diff --git a/tests/Endpoints/RulesListsTest.php b/tests/Endpoints/RulesListsTest.php index 34a0884..18a93fc 100755 --- a/tests/Endpoints/RulesListsTest.php +++ b/tests/Endpoints/RulesListsTest.php @@ -143,7 +143,7 @@ class RulesListsTest extends TestCase ); $rulesLists = new \Cloudflare\API\Endpoints\RulesLists($mock); - $result = $rulesLists->deleteListItem('01a7362d577a6c3019a474fd6f485823', '2c0fc9fa937b11eaa1b71c4d701ab86e'); + $result = $rulesLists->deleteListItem('01a7362d577a6c3019a474fd6f485823', '2c0fc9fa937b11eaa1b71c4d701ab86e', ['6as9450mma215q6so7p79dd981r4ee09']); $this->assertEquals('4da8780eeb215e6cb7f48dd981c4ea02', $result->operation_id); $this->assertEquals('4da8780eeb215e6cb7f48dd981c4ea02', $rulesLists->getBody()->result->operation_id);