Skip to content

Commit

Permalink
Merge pull request #15 from realifetech/add-audience-device-client
Browse files Browse the repository at this point in the history
Add Audience Device Client
  • Loading branch information
tomrutherford-livestyled authored Jan 12, 2021
2 parents 10b08b0 + 74ca5cf commit 7f8deb0
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
19 changes: 19 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,25 @@ public function findAll($filters = [], $pageSize = 10, $page = 1)
->getContents(), true);
}

/**
* @param string $path
*
* @return array
* @throws EntityFetchException
*/
public function getByGivenPath(string $path): array
{
try {
$response = $this->httpClient->get($path, [
'headers' => $this->getHeaders(),
]);
} catch (BadResponseException $e) {
throw new EntityFetchException($e->getMessage(), $e->getCode(), $e);
}

return json_decode($response->getBody()->getContents(), true);
}

/**
* @param bool $patch
* @return array
Expand Down
31 changes: 31 additions & 0 deletions src/RelationClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace LiveStyled;

use LogicException;

abstract class RelationClient extends Client
{
/**
* @param $id
* @param $data
*
* @return void
*/
public function update($id, $data)
{
throw new LogicException('Relation entry cannot be updated');
}

/**
* @param $id
* @param array $filters
*
* @return mixed
*/
public function find($id, $filters = [])
{
throw new LogicException('Relation entry cannot be found by id');
}

}
4 changes: 2 additions & 2 deletions src/UserManagement/AudienceDeviceClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

namespace LiveStyled\UserManagement;

use LiveStyled\Client;
use LiveStyled\CrudClient;
use LiveStyled\RelationClient;

class AudienceDeviceClient extends Client implements CrudClient
class AudienceDeviceClient extends RelationClient implements CrudClient
{
protected function getPath()
{
Expand Down

0 comments on commit 7f8deb0

Please sign in to comment.