Skip to content

Commit 347fadf

Browse files
mo7amed-3bdalla7swilla
authored andcommitted
add fields key to post , put and patch (#3)
* add fields key to post , put and patch we can now create update a record with sending array of fields and you can create empty records as api documentation. ``` \Airtable::table('default')->create( ['name' => 'mohamed']); // or empty record \Airtable::table('default')->create(null); // or with stdclass object \Airtable::table('users')->create($user); ``` * Resolve style changes.
1 parent b468ce7 commit 347fadf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Api/AirtableApiClient.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function post($contents = null)
6060
{
6161
$url = $this->getEndpointUrl();
6262

63-
$params = $contents === null ? ['body' => ''] : ['json' => $contents];
63+
$params = ['json' => ['fields' => (object) $contents]];
6464

6565
return $this->jsonToObject($this->client->post($url, $params));
6666
}
@@ -69,7 +69,7 @@ public function put(string $id, $contents = null)
6969
{
7070
$url = $this->getEndpointUrl($id);
7171

72-
$params = $contents === null ? ['body' => ''] : ['json' => $contents];
72+
$params = ['json' => ['fields' => (object) $contents]];
7373

7474
return $this->jsonToObject($this->client->put($url, $params));
7575
}
@@ -78,7 +78,7 @@ public function patch(string $id, $contents = null)
7878
{
7979
$url = $this->getEndpointUrl($id);
8080

81-
$params = $contents === null ? ['body' => ''] : ['json' => $contents];
81+
$params = ['json' => ['fields' => (object) $contents]];
8282

8383
return $this->jsonToObject($this->client->patch($url, $params));
8484
}

0 commit comments

Comments
 (0)