Skip to content

Commit ed28e9b

Browse files
Added dateformats to getRecord/create/update
1 parent ac58c1b commit ed28e9b

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/Supporting/FileMakerLayout.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,12 +232,14 @@ public function query(array|null $condition = null,
232232
* @param int|null $recordId The recordId.
233233
* @param array|null $portal See the query() method's same parameter.
234234
* @param array|null $script scripts that should execute the right timings. See FileMakerRelation::query().
235+
* @param int|null $dateformats Use this option to specify date formats for date, time, and timestamp fields. The relevant values are: 0 for US, 1 for file locale, or 2 for ISO8601
235236
* @return FileMakerRelation|null Query result.
236237
* @throws Exception In case of any error, an exception arises.
237238
*/
238239
public function getRecord(int|null $recordId,
239240
array|null $portal = null,
240-
array|null $script = null): FileMakerRelation|null
241+
array|null $script = null,
242+
int|null $dateformats = null): FileMakerRelation|null
241243
{
242244
if (is_null($recordId)) {
243245
return null;
@@ -250,6 +252,9 @@ public function getRecord(int|null $recordId,
250252
if (!is_null($script)) {
251253
$request = array_merge($request, $this->buildScriptParameters($script));
252254
}
255+
if (!is_null($dateformats)) {
256+
$request["dateformats"] = $dateformats;
257+
}
253258
$headers = ["Content-Type" => "application/json"];
254259
$params = ["layouts" => $this->layout, "records" => $recordId];
255260
$this->restAPI->callRestAPI($params, true, "GET", $request, $headers); // Throw Exception
@@ -279,13 +284,15 @@ public function getRecord(int|null $recordId,
279284
* @param array|null $portal Associated array contains the modifying values in the portal.
280285
* Ex.: {"<PortalName>"=>{"<FieldName>"=>"<Value>"...}}. FieldName has to "<TOCName>::<FieldName>".
281286
* @param array|null $script scripts that should execute the right timings. See FileMakerRelation::query().
287+
* @param int|null $dateformats Use this option to specify date formats for date, time, and timestamp fields. The relevant values are: 0 for US, 1 for file locale, or 2 for ISO8601
282288
* @return int|null The recordId of created record.
283289
* If the returned value is an integer larger than 0, it shows one record was created.
284290
* @throws Exception In case of any error, an exception arises.
285291
*/
286292
public function create(array|null $data = null,
287293
array|null $portal = null,
288-
array|null $script = null): int|null
294+
array|null $script = null,
295+
int|null $dateformats = null): int|null
289296
{
290297
if ($this->restAPI->login()) {
291298
$headers = ["Content-Type" => "application/json"];
@@ -297,6 +304,9 @@ public function create(array|null $data = null,
297304
if (!is_null($script)) {
298305
$request = array_merge($request, $this->buildScriptParameters($script));
299306
}
307+
if (!is_null($dateformats)) {
308+
$request["dateformats"] = $dateformats;
309+
}
300310
$this->restAPI->callRestAPI($params, true, "POST", $request, $headers); // Throw Exception
301311
$result = $this->restAPI->responseBody;
302312
$this->restAPI->storeToProperties();
@@ -368,13 +378,15 @@ public function delete(int|null $recordId,
368378
* Ex.: {"<PortalName>"=>{"<FieldName>"=>"<Value>", "recordId"=>"12"}}. FieldName has to "<TOCName>::<FieldName>".
369379
* The recordId key specifies the record to edit in the portal.
370380
* @param array|null $script scripts that should execute the right timings. See FileMakerRelation::query().
381+
* @param int|null $dateformats Use this option to specify date formats for date, time, and timestamp fields. The relevant values are: 0 for US, 1 for file locale, or 2 for ISO8601
371382
* @throws Exception In case of any error, an exception arises.
372383
*/
373384
public function update(int|null $recordId,
374385
array|null $data,
375386
int $modId = -1,
376387
array|object|null $portal = null,
377-
array|null $script = null): void
388+
array|null $script = null,
389+
int|null $dateformats = null): void
378390
{
379391
if (is_null($recordId)) {
380392
return;
@@ -392,6 +404,9 @@ public function update(int|null $recordId,
392404
if (!is_null($script)) {
393405
$request = array_merge($request, $this->buildScriptParameters($script));
394406
}
407+
if (!is_null($dateformats)) {
408+
$request["dateformats"] = $dateformats;
409+
}
395410
if ($modId > -1) {
396411
$request = array_merge($request, ["modId" => (string)$modId]);
397412
}

0 commit comments

Comments
 (0)