From 54f415555b6f8880843a2bb34db9aca19c3209a6 Mon Sep 17 00:00:00 2001 From: Ahmed Safaa Date: Mon, 2 Nov 2020 22:27:14 +0300 Subject: [PATCH 1/4] Update composer Add support for guzzlehttp 7.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 81112ad0..b8097832 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "PHP binding for v4 of the Cloudflare Client API.", "type": "library", "require": { - "guzzlehttp/guzzle": "^7.0.1", + "guzzlehttp/guzzle": "^7.2", "php": ">=7.2.5", "psr/http-message": "~1.0", "ext-json": "*" From ccaece6641bab960499fe287d5ff47cd92439f4c Mon Sep 17 00:00:00 2001 From: Ahmed Safaa Date: Mon, 2 Nov 2020 22:37:49 +0300 Subject: [PATCH 2/4] update composer allow 7.2.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b8097832..ae6cf62b 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "PHP binding for v4 of the Cloudflare Client API.", "type": "library", "require": { - "guzzlehttp/guzzle": "^7.2", + "guzzlehttp/guzzle": "^7.2.0", "php": ">=7.2.5", "psr/http-message": "~1.0", "ext-json": "*" From da487d8b84138a569c77942183175d1c36558c13 Mon Sep 17 00:00:00 2001 From: Ahmed Safaa Date: Tue, 17 Dec 2024 17:01:07 +0300 Subject: [PATCH 3/4] Batch #1 --- src/Endpoints/DNS.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/Endpoints/DNS.php b/src/Endpoints/DNS.php index a9f74749..39bf9076 100644 --- a/src/Endpoints/DNS.php +++ b/src/Endpoints/DNS.php @@ -153,4 +153,42 @@ public function deleteRecord(string $zoneID, string $recordID): bool return false; } + + + /** + * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * + * @param string $zoneID + * @param array $deletes + * @param array $patches + * @param array $posts + * @param array $puts + * @param bool $proxied + * @param string $priority + * @param array $data + * @return bool + */ + public function batchRecords( + string $zoneID, + array $deletes = [], + array $patches = [], + array $posts = [], + array $puts = [] + ): array { + $options = [ + 'deletes' => $deletes, + 'patches' => $patches, + 'posts' => $posts, + 'puts' => $puts, + ]; + + + $user = $this->adapter->post('zones/' . $zoneID . '/dns_records/batch', $options); + + $this->body = json_decode($user->getBody()); + + + return $this-body; + } + } From 54f220efd4713cc3ce6bda3a41f59ecbe1f4f64a Mon Sep 17 00:00:00 2001 From: Ahmed Safaa Date: Tue, 17 Dec 2024 17:18:47 +0300 Subject: [PATCH 4/4] Fix --- src/Endpoints/DNS.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Endpoints/DNS.php b/src/Endpoints/DNS.php index 39bf9076..bc7488d3 100644 --- a/src/Endpoints/DNS.php +++ b/src/Endpoints/DNS.php @@ -174,7 +174,7 @@ public function batchRecords( array $patches = [], array $posts = [], array $puts = [] - ): array { + ): bool { $options = [ 'deletes' => $deletes, 'patches' => $patches, @@ -185,10 +185,8 @@ public function batchRecords( $user = $this->adapter->post('zones/' . $zoneID . '/dns_records/batch', $options); - $this->body = json_decode($user->getBody()); + return $user->getStatusCode() === 200; - - return $this-body; } }