Skip to content

Commit

Permalink
Updates changelog and readme, adds remaining xibo api endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Wimmie committed Jan 28, 2021
1 parent de7be69 commit 957b3eb
Show file tree
Hide file tree
Showing 34 changed files with 1,393 additions and 53 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

All notable changes to `laravel-xibo-api` will be documented in this file.

## 1.0.0 - 202X-XX-XX
## 0.1.0 - 2021-01-28

- initial release
- adds basics for the wrapper
26 changes: 6 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
# A Laravel package for using the Xibo api

[![Latest Version on Packagist](https://img.shields.io/packagist/v/wimmie/laravel-xibo-api.svg?style=flat-square)](https://packagist.org/packages/wimmie/laravel-xibo-api)
[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/wimmie/laravel-xibo-api/run-tests?label=tests)](https://github.com/wimmie/laravel-xibo-api/actions?query=workflow%3ATests+branch%3Amaster)
[![Total Downloads](https://img.shields.io/packagist/dt/wimmie/laravel-xibo-api.svg?style=flat-square)](https://packagist.org/packages/wimmie/laravel-xibo-api)


This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

## Support us

[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/package-laravel-xibo-api-laravel.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/package-laravel-xibo-api-laravel)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
A wrapper for the Xibo api, see https://xibo.org.uk/manual/api/ as well.

## Installation

Expand All @@ -23,13 +14,6 @@ You can install the package via composer:
composer require wimmie/laravel-xibo-api
```

You can publish and run the migrations with:

```bash
php artisan vendor:publish --provider="Wimmie\XiboApi\XiboApiServiceProvider" --tag="migrations"
php artisan migrate
```

You can publish the config file with:
```bash
php artisan vendor:publish --provider="Wimmie\XiboApi\XiboApiServiceProvider" --tag="config"
Expand All @@ -39,14 +23,17 @@ This is the contents of the published config file:

```php
return [
'url' => env('XIBO_URL', ''),
'client_id' => env('XIBO_CLIENT_ID', ''),
'client_secret' => env('XIBO_CLIENT_SECRET', ''),
];
```

## Usage

```php
$laravel-xibo-api = new Wimmie\XiboApi();
echo $laravel-xibo-api->echoPhrase('Hello, Wimmie!');
$xiboApi = new Wimmie\XiboApi();
echo $xiboApi->misc()->about();
```

## Testing
Expand All @@ -70,7 +57,6 @@ Please review [our security policy](../../security/policy) on how to report secu
## Credits

- [Willem](https://github.com/wimmie)
- [All Contributors](../../contributors)

## License

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
],
"require": {
"php": "^7.4|^8.0",
"illuminate/contracts": "^8.0",
"ext-curl": "*",
"ext-json": "*"
"ext-json": "*",
"illuminate/contracts": "^8.0",
"spatie/laravel-ray": "^1.9"
},
"require-dev": {
"orchestra/testbench": "^6.0",
"phpunit/phpunit": "^9.3"
},
"autoload": {
"psr-4": {
"Wimmie\\XiboApi\\": "src",
"Wimmie\\XiboApi\\Database\\Factories\\": "database/factories"
"Wimmie\\XiboApi\\": "src"
}
},
"autoload-dev": {
Expand Down
6 changes: 4 additions & 2 deletions src/Categories/CategoryWithCrud.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public function add(array $data)
* @param array $data
* @return mixed
*/
public function edit(int $id, array $data) {
public function edit(int $id, array $data)
{
$url = $this->xiboApi->generateUrl($this->name, null, $id);
return $this->xiboApi->sendRequest($url, XiboApi::REQUEST_PUT, $data);
}
Expand All @@ -46,7 +47,8 @@ public function edit(int $id, array $data) {
* @param int $id
* @return mixed
*/
public function delete(int $id) {
public function delete(int $id)
{
$url = $this->xiboApi->generateUrl($this->name, null, $id);
return $this->xiboApi->sendRequest($url, XiboApi::REQUEST_DELETE);
}
Expand Down
2 changes: 0 additions & 2 deletions src/Categories/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
namespace Wimmie\XiboApi\Categories;


use Wimmie\XiboApi\XiboApi;

class Command extends CategoryWithCrud
{
/**
Expand Down
36 changes: 36 additions & 0 deletions src/Categories/Dataset.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,40 @@ class Dataset extends CategoryWithCrud
* @inheritdoc
*/
protected string $name = 'dataset';

/**
* Copy DataSet
* @param int $id
* @param array $data
* @return mixed
*/
public function copy(int $id, array $data)
{
$url = $this->xiboApi->generateUrl($this->name, 'copy', $id);
return $this->xiboApi->sendRequest($url, XiboApi::REQUEST_POST, $data);
}

/**
* Import CSV
* @param int $id
* @param array $data
* @return mixed
*/
public function importCsv(int $id, array $data)
{
$url = $this->xiboApi->generateUrl($this->name, 'import', $id);
return $this->xiboApi->sendRequest($url, XiboApi::REQUEST_POST, $data);
}

/**
* Import JSON
* @param int $id
* @param string $json
* @return mixed
*/
public function importJson(int $id, string $json)
{
$url = $this->xiboApi->generateUrl($this->name, 'importjson', $id);
return $this->xiboApi->sendRequest($url, XiboApi::REQUEST_POST, null, null, $json);
}
}
21 changes: 21 additions & 0 deletions src/Categories/DatasetColumn.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php


namespace Wimmie\XiboApi\Categories;


use Wimmie\XiboApi\XiboApi;

class DatasetColumn extends CategoryWithCrud
{
/**
* @inheritdoc
*/
protected string $name = 'dataset/{datasetId}/column';

public function __construct(XiboApi $xiboApi, int $datasetId)
{
$this->name = str_replace('{datasetId}', $datasetId, $this->name);
parent::__construct($xiboApi);
}
}
65 changes: 65 additions & 0 deletions src/Categories/DatasetData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php


namespace Wimmie\XiboApi\Categories;


use Wimmie\XiboApi\XiboApi;

class DatasetData extends Category
{
/**
* @inheritdoc
*/
protected string $name = 'dataset/data/{datasetId}';

public function __construct(XiboApi $xiboApi, int $datasetId)
{
$this->name = str_replace('{datasetId}', $datasetId, $this->name);
parent::__construct($xiboApi);
}

/**
* Search
* @return mixed
*/
public function get()
{
$url = $this->xiboApi->generateUrl($this->name);
return $this->xiboApi->sendRequest($url, XiboApi::REQUEST_GET);
}

/**
* Add
* @param array $data
* @return mixed
*/
public function add(array $data)
{
$url = $this->xiboApi->generateUrl($this->name);
return $this->xiboApi->sendRequest($url, XiboApi::REQUEST_POST, $data);
}

/**
* Edit
* @param int $id
* @param array $data
* @return mixed
*/
public function edit(int $id, array $data)
{
$url = $this->xiboApi->generateUrl($this->name, null, $id);
return $this->xiboApi->sendRequest($url, XiboApi::REQUEST_PUT, $data);
}

/**
* Delete
* @param int $id
* @return mixed
*/
public function delete(int $id)
{
$url = $this->xiboApi->generateUrl($this->name, null, $id);
return $this->xiboApi->sendRequest($url, XiboApi::REQUEST_DELETE);
}
}
21 changes: 21 additions & 0 deletions src/Categories/DatasetRss.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php


namespace Wimmie\XiboApi\Categories;


use Wimmie\XiboApi\XiboApi;

class DatasetRss extends CategoryWithCrud
{
/**
* @inheritdoc
*/
protected string $name = 'dataset/{datasetId}/rss';

public function __construct(XiboApi $xiboApi, int $datasetId)
{
$this->name = str_replace('{datasetId}', $datasetId, $this->name);
parent::__construct($xiboApi);
}
}
2 changes: 0 additions & 2 deletions src/Categories/DayPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
namespace Wimmie\XiboApi\Categories;


use Wimmie\XiboApi\XiboApi;

class DayPart extends CategoryWithCrud
{
/**
Expand Down
89 changes: 89 additions & 0 deletions src/Categories/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,93 @@ class Display extends Category
* @inheritdoc
*/
protected string $name = 'display';

/**
* Search
* @param array|null $parameters
* @return mixed
*/
public function search(array $parameters = null)
{
$url = $this->xiboApi->generateUrl($this->name, null, null, $parameters);
return $this->xiboApi->sendRequest($url, XiboApi::REQUEST_GET);
}

/**
* Edit
* @param int $id
* @param array $data
* @return mixed
*/
public function edit(int $id, array $data)
{
$url = $this->xiboApi->generateUrl($this->name, null, $id);
return $this->xiboApi->sendRequest($url, XiboApi::REQUEST_PUT, $data);
}

/**
* Delete
* @param int $id
* @return mixed
*/
public function delete(int $id)
{
$url = $this->xiboApi->generateUrl($this->name, null, $id);
return $this->xiboApi->sendRequest($url, XiboApi::REQUEST_DELETE);
}

/**
* Request Screen Shot
* @param int $id
* @return mixed
*/
public function requestScreenshot(int $id)
{
$url = $this->xiboApi->generateUrl($this->name, 'requestscreenshot', $id);
return $this->xiboApi->sendRequest($url, XiboApi::REQUEST_PUT);
}

/**
* Issue WOL
* @param int $id
* @return mixed
*/
public function wol(int $id)
{
$url = $this->xiboApi->generateUrl($this->name, 'wol', $id);
return $this->xiboApi->sendRequest($url, XiboApi::REQUEST_POST);
}

/**
* Toggle authorised
* @param int $id
* @return mixed
*/
public function toggleAuthorised(int $id)
{
$url = $this->xiboApi->generateUrl($this->name, 'authorise', $id);
return $this->xiboApi->sendRequest($url, XiboApi::REQUEST_PUT);
}

/**
* Set Default Layout
* @param int $id
* @return mixed
*/
public function defaultLayout(int $id, array $data)
{
$url = $this->xiboApi->generateUrl($this->name, 'defaultlayout', $id);
return $this->xiboApi->sendRequest($url, XiboApi::REQUEST_PUT, $data);
}

/**
* Licence Check
* @param int $id
* @return mixed
*/
public function licenceCheck(int $id)
{
$url = $this->xiboApi->generateUrl($this->name, 'licencecheck', $id);
return $this->xiboApi->sendRequest($url, XiboApi::REQUEST_PUT);
}
}
12 changes: 12 additions & 0 deletions src/Categories/DisplayGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,16 @@ class DisplayGroup extends CategoryWithCrud
* @inheritdoc
*/
protected string $name = 'displaygroup';

/**
* Copy Display Group
* @param $id
* @param array $data
* @return mixed
*/
public function copy(int $id, array $data)
{
$url = $this->xiboApi->generateUrl($this->name, null, $id) . '/copy';
return $this->xiboApi->sendRequest($url, XiboApi::REQUEST_POST, $data);
}
}
Loading

0 comments on commit 957b3eb

Please sign in to comment.