Skip to content

Commit

Permalink
Merge pull request #5 from assertchris/feature/improve-api
Browse files Browse the repository at this point in the history
Improve API: fix items delete and update operations.
  • Loading branch information
wivern-co-uk authored May 8, 2019
2 parents a37182f + b9f689f commit c22fb59
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Webflow/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ private function put($path, $data)
return $this->request($path, "PUT", $data);
}

private function delete($path, $data)
private function delete($path)
{
return $this->request($path, "DELETE", $data);
return $this->request($path, "DELETE");
}

private function parse($response)
Expand Down Expand Up @@ -163,17 +163,20 @@ public function item(string $collectionId, string $itemId)
public function createItem(string $collectionId, array $fields)
{
$defaults = [
"_archived" => false,
"_draft" => false,
"_archived" => false,
"_draft" => false,
];

return $this->post("/collections/{$collectionId}/items", [
'fields' => $defaults + $fields,
'fields' => array_merge($defaults, $fields),
]);
}

public function updateItem(string $collectionId, string $itemId, array $fields)
{
return $this->put("/collections/{$collectionId}/items/{$itemId}", $fields);
return $this->put("/collections/{$collectionId}/items/{$itemId}", [
'fields' => $fields,
]);
}

public function removeItem(string $collectionId, $itemId)
Expand Down

0 comments on commit c22fb59

Please sign in to comment.