From 2e50212b4f69dbf24c1d23d49de6dd269fe35421 Mon Sep 17 00:00:00 2001 From: Jordy Yau Date: Tue, 2 Nov 2021 09:45:26 -0500 Subject: [PATCH 1/2] chunk row inserts --- src/Resources/Sheet.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Resources/Sheet.php b/src/Resources/Sheet.php index fd81b5b..c141feb 100644 --- a/src/Resources/Sheet.php +++ b/src/Resources/Sheet.php @@ -32,7 +32,9 @@ public function dropAndReplace(array $rows) { $this->dropAllRows(); - $this->addRows($rows); + foreach (collect($rows)->chunk(500) as $chunk) { + $this->addRows($chunk->toArray()); + } } public function dropAllRows() @@ -186,6 +188,7 @@ public function addRows(array $rows): object 'cells' => $this->generateRowCells($cells) ]; }) + ->values() ->toArray() ); } From 90b8ecc3d670f278b26d6ccec024f4ee62108b43 Mon Sep 17 00:00:00 2001 From: Jordy Yau Date: Tue, 2 Nov 2021 09:46:24 -0500 Subject: [PATCH 2/2] fix expected data types --- src/Resources/Sheet.php | 4 ++-- src/SmartsheetClient.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Resources/Sheet.php b/src/Resources/Sheet.php index c141feb..57eb76a 100644 --- a/src/Resources/Sheet.php +++ b/src/Resources/Sheet.php @@ -275,10 +275,10 @@ public function replaceRows(array $cells, string $primaryColumnName) * Adds a row to the sheet * * @param array $cells - * @return array + * @return object * @throws Exception */ - public function createRow(array $cells): array + public function createRow(array $cells): object { return $this->insertRows([ 'toBottom' => true, diff --git a/src/SmartsheetClient.php b/src/SmartsheetClient.php index bebef98..ccdead7 100644 --- a/src/SmartsheetClient.php +++ b/src/SmartsheetClient.php @@ -102,7 +102,7 @@ public function getFolder(string $folderId): Folder */ public function getWorkspace(string $workspaceId): Workspace { - return new Workspace($this, $this->get("workspaces/$workspaceId")); + return new Workspace($this, (array) $this->get("workspaces/$workspaceId")); } /**