Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
Infamoustrey committed Dec 28, 2020
1 parent 85b792f commit dc7fa9f
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PHP Composer
name: Run Tests

on:
push:
Expand Down
1 change: 0 additions & 1 deletion src/APIClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/
class APIClient
{

protected const BASE_URL = "https://api.smartsheet.com/2.0/";

protected GuzzleClient $guzzleClient;
Expand Down
1 change: 0 additions & 1 deletion src/Resources/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

class Resource
{

protected array $data;

public function __construct(array $data = [])
Expand Down
1 change: 0 additions & 1 deletion src/Resources/Row.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Smartsheet\Resources;

use GuzzleHttp\Psr7\Response;
use Smartsheet\SmartsheetClient;

use Illuminate\Support\Collection;
Expand Down
9 changes: 4 additions & 5 deletions src/Resources/Sheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

class Sheet extends Resource
{

protected SmartsheetClient $client;

protected string $id;
Expand Down Expand Up @@ -66,9 +65,10 @@ public function copyRowsTo(array $rowIds, string $sheetId)

public function getRows(): Collection
{
return collect($this->rows)->map(function ($row) {
return new Row($this->client, (array) $row, $this);
});
return collect($this->rows)
->map(function ($row) {
return new Row($this->client, (array) $row, $this);
});
}

/**
Expand All @@ -78,7 +78,6 @@ public function getRows(): Collection
*/
public function getColumnId($title): string
{

$column = collect($this->columns)
->first(function ($col) use ($title) {
return $col->title == $title;
Expand Down
31 changes: 17 additions & 14 deletions src/Resources/Workspace.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class Workspace extends Resource
protected string $name;
protected array $sheets = [];

/**
* Workspace constructor.
* @param SmartsheetClient $client
* @param $data
*/
public function __construct(SmartsheetClient $client, $data)
{
parent::__construct($data);
Expand All @@ -44,6 +49,17 @@ public function createSheet($name, $columns = DEFAULT_COLUMNS): mixed
]);
}

/**
* Fetches the sheet if it exists
* @param string $name
* @return Sheet $sheet
* @throws Exception
*/
public function getSheet(string $name): Sheet
{
return $this->client->getSheet($this->getSheetId($name));
}

/**
* @return array
*/
Expand Down Expand Up @@ -72,20 +88,6 @@ public function getSheetId(string $name): string
return $sheet->id;
}

/**
* Fetches the sheet if it exists
* @param string $name
* @return Sheet $sheet
* @throws Exception
*/
public function getSheet(string $name): Sheet
{
return $this->client->getSheet($this->getSheetId($name));
}

/**
* @return string
*/
public function getId(): string
{
return $this->id;
Expand All @@ -95,4 +97,5 @@ public function getName(): string
{
return $this->name;
}

}
11 changes: 7 additions & 4 deletions src/SmartsheetClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ public function __construct(array $config = [])
parent::__construct($config);
}

protected function instantiateCollection(string $class, array $target): Collection {
protected function instantiateCollection(string $class, array $target): Collection
{
$temp = collect([]);

foreach($target as $t) {
$temp->add(new $class($this, (array) $t));
foreach ($target as $t) {
$temp->add(new $class($this, (array)$t));
}

return $temp;
Expand Down Expand Up @@ -65,7 +66,7 @@ public function getSheet(string $sheetId): Sheet
{
$response = $this->get("sheets/$sheetId");

return new Sheet($this, (array) $response);
return new Sheet($this, (array)$response);
}

/**
Expand All @@ -84,6 +85,7 @@ public function getRow(string $sheetId, string $rowId): Row

/**
* Fetch a folder with a given ID
*
* @param string $folderId
* @return Folder
*/
Expand All @@ -94,6 +96,7 @@ public function getFolder(string $folderId): Folder

/**
* Fetch a workspace with a given ID
*
* @param string $workspaceId
* @return Workspace
*/
Expand Down

0 comments on commit dc7fa9f

Please sign in to comment.