From b3f32cc90130bf4d5a6d1d2ac21329de5b3097fc Mon Sep 17 00:00:00 2001 From: Haddo Vervest Date: Mon, 22 Jul 2019 11:40:00 +0200 Subject: [PATCH 1/2] Added 'live' parameter' --- src/Webflow/Api.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Webflow/Api.php b/src/Webflow/Api.php index aaf4564..2585413 100644 --- a/src/Webflow/Api.php +++ b/src/Webflow/Api.php @@ -160,21 +160,21 @@ public function item(string $collectionId, string $itemId) return $this->get("/collections/{$collectionId}/items/{$itemId}"); } - public function createItem(string $collectionId, array $fields) + public function createItem(string $collectionId, array $fields, bool $live = false) { $defaults = [ "_archived" => false, "_draft" => false, ]; - return $this->post("/collections/{$collectionId}/items", [ - 'fields' => array_merge($defaults, $fields), + return $this->post("/collections/{$collectionId}/items" . ($live ? "?live=true": ""), [ + 'fields' => array_merge($defaults, $fields), ]); } - public function updateItem(string $collectionId, string $itemId, array $fields) + public function updateItem(string $collectionId, string $itemId, array $fields, bool $live = false) { - return $this->put("/collections/{$collectionId}/items/{$itemId}", [ + return $this->put("/collections/{$collectionId}/items/{$itemId}" . ($live ? "?live=true": ""), [ 'fields' => $fields, ]); } From a112a1fe234862066ba0ef57833e42a47a49dc43 Mon Sep 17 00:00:00 2001 From: Haddo Vervest Date: Tue, 10 Sep 2019 00:05:41 +0200 Subject: [PATCH 2/2] Fixed styling issue --- src/Webflow/Api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Webflow/Api.php b/src/Webflow/Api.php index 2585413..b9d8e78 100644 --- a/src/Webflow/Api.php +++ b/src/Webflow/Api.php @@ -167,14 +167,14 @@ public function createItem(string $collectionId, array $fields, bool $live = fal "_draft" => false, ]; - return $this->post("/collections/{$collectionId}/items" . ($live ? "?live=true": ""), [ + return $this->post("/collections/{$collectionId}/items" . ($live ? "?live=true" : ""), [ 'fields' => array_merge($defaults, $fields), ]); } public function updateItem(string $collectionId, string $itemId, array $fields, bool $live = false) { - return $this->put("/collections/{$collectionId}/items/{$itemId}" . ($live ? "?live=true": ""), [ + return $this->put("/collections/{$collectionId}/items/{$itemId}" . ($live ? "?live=true" : ""), [ 'fields' => $fields, ]); }