First inital test commit
This commit is contained in:
35
src/GrocyClient.php
Normal file
35
src/GrocyClient.php
Normal 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user