Skip to content

Commit d418cfe

Browse files
author
SheetDB
committed
add. support for multiple spreadsheets 🗂
1 parent d61e917 commit d418cfe

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/Connection.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ class Connection
1212

1313
private $url;
1414
private $queryParams = [];
15+
private $sheet = null;
1516

16-
public function __construct($url) {
17+
public function __construct($url, $sheet = null) {
1718
$this->url = $url;
19+
$this->sheet = $sheet;
1820
}
1921

2022
public function setUrl($url) {
@@ -75,10 +77,15 @@ public function makeRequest($method = 'get', $data = []) {
7577
*/
7678
private function prepareQueryUrl() {
7779
$url = $this->url;
80+
81+
if ($this->sheet) {
82+
$this->queryParams['sheet'] = $this->sheet;
83+
}
84+
7885
if ($this->queryParams) {
7986
$url .= '/?';
8087
$url .= http_build_query($this->queryParams);
8188
$this->url = $url;
8289
}
8390
}
84-
}
91+
}

src/SheetDB.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class SheetDB
2020
* Sets SheetDB api_id
2121
* @param $api_id ID of API within SheetDB
2222
*/
23-
public function __construct($api_id) {
23+
public function __construct($api_id, $sheet = null) {
2424
$this->api_id = $api_id;
25-
$this->connection = new Connection($this->handlerUrl());
25+
$this->connection = new Connection($this->handlerUrl(), $sheet);
2626
}
2727

2828
/**
@@ -159,4 +159,4 @@ private function handlerUrl($append = '') {
159159
return self::BASE_URL . $this->api_id . $append;
160160
}
161161

162-
}
162+
}

0 commit comments

Comments
 (0)