First inital test commit

This commit is contained in:
Tim
2021-10-03 19:13:41 +02:00
commit c823696937
14 changed files with 1560 additions and 0 deletions

35
src/GrocyClient.php Normal file
View File

@ -0,0 +1,35 @@
<?php
namespace Ardent\GrocyApi;
class GrocyClient
{
private Client $client;
public function __construct(string $host, string $apikey)
{
$this->client = new Client($host, $apikey);
}
private function getObjects(string $object, array $query = [], $order = null, $limit = null, $offset = null)
{
return $this->client->get($object, compact('order', 'limit', 'offset'));
}
private function getObject(string $object, int $id)
{
return $this->client->get(sprintf('%s/%s', $object, $id));
}
public function getAllProducts()
{
return $this->getObjects('products');
}
public function getProduct(int $id)
{
$this->getObject('products', $id);
}
}