From 12f5e901f9afd87823b69a84de6e0690e5b39b65 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 7 Jan 2020 16:29:49 -0500 Subject: [PATCH] Added http PATCH method. Updated corresponding doc. --- README.md | 5 +++++ src/Webflow/Api.php | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/README.md b/README.md index c6b77dc..5eca21f 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,11 @@ $webflow->createItem($collectionId, $fields); $webflow->updateItem($collectionId, $itemId, $fields); ``` +### Patch Collection Item +``` +$webflow->patchItem($collectionId, $itemId, $fields); +``` + ### Remove Collection Item ``` $webflow->removeItem($collectionId, $itemId); diff --git a/src/Webflow/Api.php b/src/Webflow/Api.php index b9d8e78..18bca2b 100644 --- a/src/Webflow/Api.php +++ b/src/Webflow/Api.php @@ -76,6 +76,11 @@ private function put($path, $data) return $this->request($path, "PUT", $data); } + private function patch($path, $data) + { + return $this->request($path, "PATCH", $data); + } + private function delete($path) { return $this->request($path, "DELETE"); @@ -179,6 +184,13 @@ public function updateItem(string $collectionId, string $itemId, array $fields, ]); } + public function patchItem(string $collectionId, string $itemId, array $fields, bool $live = false) + { + return $this->patch("/collections/{$collectionId}/items/{$itemId}" . ($live ? "?live=true" : ""), [ + 'fields' => $fields, + ]); + } + public function removeItem(string $collectionId, $itemId) { return $this->delete("/collections/{$collectionId}/items/{$itemId}");