Skip to content

Commit c22fb59

Browse files
authored
Merge pull request #5 from assertchris/feature/improve-api
Improve API: fix items delete and update operations.
2 parents a37182f + b9f689f commit c22fb59

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/Webflow/Api.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ private function put($path, $data)
7676
return $this->request($path, "PUT", $data);
7777
}
7878

79-
private function delete($path, $data)
79+
private function delete($path)
8080
{
81-
return $this->request($path, "DELETE", $data);
81+
return $this->request($path, "DELETE");
8282
}
8383

8484
private function parse($response)
@@ -163,17 +163,20 @@ public function item(string $collectionId, string $itemId)
163163
public function createItem(string $collectionId, array $fields)
164164
{
165165
$defaults = [
166-
"_archived" => false,
167-
"_draft" => false,
166+
"_archived" => false,
167+
"_draft" => false,
168168
];
169+
169170
return $this->post("/collections/{$collectionId}/items", [
170-
'fields' => $defaults + $fields,
171+
'fields' => array_merge($defaults, $fields),
171172
]);
172173
}
173174

174175
public function updateItem(string $collectionId, string $itemId, array $fields)
175176
{
176-
return $this->put("/collections/{$collectionId}/items/{$itemId}", $fields);
177+
return $this->put("/collections/{$collectionId}/items/{$itemId}", [
178+
'fields' => $fields,
179+
]);
177180
}
178181

179182
public function removeItem(string $collectionId, $itemId)

0 commit comments

Comments
 (0)