Skip to content

Commit

Permalink
New methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
eskrano committed Jul 15, 2020
1 parent 234412e commit 8fd5bc1
Show file tree
Hide file tree
Showing 5 changed files with 238 additions and 3 deletions.
2 changes: 0 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

# Quickbase REST API PHP library

###Available methods

[Quickbase](https://quickbase.com)

[REST API Documentation](https://developer.quickbase.com/)
Expand Down
10 changes: 10 additions & 0 deletions src/QuickbaseRest/QuickbaseREST.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Eskrano\QuickbaseRest\Interfaces\SectionInterface;
use Eskrano\QuickbaseRest\Sections\Records;
use Eskrano\QuickbaseRest\Sections\Tables;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\RequestOptions;
Expand Down Expand Up @@ -123,6 +124,15 @@ public function records(): Records
return $this->getSection(Records::class);
}

/**
* @return Tables
* @throws \Exception
*/
public function tables(): Tables
{
return $this->getSection(Tables::class);
}


public function query(string $method, string $action, array $body, array $query_params = []): ResponseInterface
{
Expand Down
43 changes: 42 additions & 1 deletion src/QuickbaseRest/Sections/Apps.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,46 @@

class Apps extends AbstractSection
{
//todo implement
/**
* Create new app
* @see https://developer.quickbase.com/operation/createApp
* @param string $name
* @param string $description
* @param bool $assign_token
* @param array $variables
* @return \Psr\Http\Message\ResponseInterface
*/
public function createApp(
string $name,
string $description,
bool $assign_token = true,
array $variables = []
)
{
return $this->client->query(
'POST',
'apps',
[
'name' => $name,
'description' => $description,
'assignToken' => $assign_token,
'variables' => $variables
]
);
}

/**
* Get app info
* @see https://developer.quickbase.com/operation/getApp
* @param string $app_id
* @return \Psr\Http\Message\ResponseInterface
*/
public function getApp(string $app_id)
{
return $this->client->query(
'GET',
'apps/'.$app_id,
[]
);
}
}
66 changes: 66 additions & 0 deletions src/QuickbaseRest/Sections/Reports.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace Eskrano\QuickbaseRest\Sections;

class Reports extends AbstractSection
{
/**
* Table reports (all reports)
* @see https://developer.quickbase.com/operation/getTableReports
* @param string $table_id
* @return \Psr\Http\Message\ResponseInterface
*/
public function tableReports(string $table_id)
{
return $this->client->query(
'GET',
'reports',
[],
[
'tableId' => $table_id
],
);
}

/**
* Get report
* @see https://developer.quickbase.com/operation/getReport
* @param string $table_id
* @param int $report_id
* @return \Psr\Http\Message\ResponseInterface
*/
public function getReport(string $table_id, int $report_id)
{
return $this->client->query(
'GET',
'reports/' . $report_id,
[],
[
'tableId' => $table_id
],
);
}

/**
* Run report
* @see https://developer.quickbase.com/operation/runReport
* @param string $table_id
* @param int $report_id
* @param int $skip
* @param int $top
* @return \Psr\Http\Message\ResponseInterface
*/
public function runReport(string $table_id, int $report_id, int $skip = 0, int $top = 100)
{
return $this->client->query(
'GET',
'reports/' . $report_id,
[],
[
'tableId' => $table_id,
'skip' => $skip,
'top' => $top,
],
);
}
}
120 changes: 120 additions & 0 deletions src/QuickbaseRest/Sections/Tables.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?php

namespace Eskrano\QuickbaseRest\Sections;

class Tables extends AbstractSection
{

/**
* Create table
*
* @param string $app_id
* @param string $table_name
* @param string $description
* @param string $single_record_name
* @param string $plural_record_name
* @return \Psr\Http\Message\ResponseInterface
*/
public function create(
string $app_id,
string $table_name,
string $description,
string $single_record_name,
string $plural_record_name
)
{
$create = [
'name' => $table_name,
'description' => $description,
'singleRecordName' => $single_record_name,
'pluralRecordName' => $plural_record_name
];


return $this->client->query(
'POST',
'tables',
$create,
[
'appId' => $app_id,
]
);
}

/**
* Get all tables from the APP
*
* @param string $app_id
* @return \Psr\Http\Message\ResponseInterface
*/
public function getTablesFromApp(string $app_id)
{
return $this->client->query(
'GET',
'tables',
[],
[
'appId' => $app_id
]
);
}

/**
* Get one table info
*
* @param string $app_id
* @param string $table_id
* @return \Psr\Http\Message\ResponseInterface
*/
public function getTable(string $app_id, string $table_id)
{
return $this->client->query(
'GET',
'tables/' . $table_id,
[],
[
'appId' => $app_id
]
);
}

/**
* Update table
*
* @param string $app_id
* @param string $table_id
* @param array $update
* @return \Psr\Http\Message\ResponseInterface
*/
public function updateTable(string $app_id, string $table_id, array $update)
{
$update_final = [
'name' => $update['table_name'],
'description' => $update['description'],
'singleRecordName' => $update['single_record_name'],
'pluralRecordName' => $update['plural_record_name'],
];

return $this->client->query(
'POST',
'tables/' . $table_id,
$update_final,
[
'appId' => $app_id,
]
);
}


public function deleteTable(string $app_id, string $table_id)
{
return $this->client->query(
'DELETE',
'tables/' . $table_id,
[],
[
'appId' => $app_id
]
);
}
}

0 comments on commit 8fd5bc1

Please sign in to comment.