Skip to content

Commit

Permalink
Merge pull request #7 from Beeldvoerders/WorkWithLiveItems
Browse files Browse the repository at this point in the history
Support 'live' parameter for item create and update
  • Loading branch information
wivern-co-uk authored Sep 12, 2019
2 parents c22fb59 + a112a1f commit ead2a27
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Webflow/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
}
Expand Down

0 comments on commit ead2a27

Please sign in to comment.