Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/softwarepunt/psinfoodservice-api-client
Unofficial PHP API Client for PS in foodservice Web API (PS-API)
https://github.com/softwarepunt/psinfoodservice-api-client
api foodbook php psapi psinfoodservice
Last synced: about 1 month ago
JSON representation
Unofficial PHP API Client for PS in foodservice Web API (PS-API)
- Host: GitHub
- URL: https://github.com/softwarepunt/psinfoodservice-api-client
- Owner: SoftwarePunt
- License: mit
- Created: 2021-07-13T02:26:08.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-02-06T13:25:34.000Z (11 months ago)
- Last Synced: 2024-11-13T01:11:17.653Z (about 1 month ago)
- Topics: api, foodbook, php, psapi, psinfoodservice
- Language: PHP
- Homepage:
- Size: 210 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# psinfoodservice-api-client
***Unofficial* PHP API Client for PS in foodservice Web API (PS-API)**[![PHPUnit](https://github.com/SoftwarePunt/psinfoodservice-api-client/actions/workflows/phpunit.yml/badge.svg)](https://github.com/SoftwarePunt/psinfoodservice-api-client/actions/workflows/phpunit.yml)
[![Version](http://poser.pugx.org/softwarepunt/psinfoodservice-api-client/version)](https://packagist.org/packages/softwarepunt/psinfoodservice-api-client)This library helps you interact with the PS-API, version 6.
🌍 PS in foodservice
https://psinfoodservice.nl/
📕 API documentation
https://webapi.psinfoodservice.com/V6/prod/Home/EN
📦 Composer package
softwarepunt/psinfoodservice-api-client
⚠ **Heads up - Limited scope:** this library currently only supports retrieving product information. PRs for other API features are welcome. :)
## Installation
### Requirements
- PHP 8.2+
- with extensions: curl, simplexml
- [Composer](https://getcomposer.org/)### Setup
Use Composer to add the package as a dependency to your project:```shell
composer require softwarepunt/psinfoodservice-api-client
```## Usage
### Getting started
To begin, include the Client and set your credentials and options.🔒 If you do not have credentials yet, [contact PS in foodservice](https://webapi.psinfoodservice.com/V6/prod/Home/EN) to request them first.
```php
setUsername("[email protected]");
$client->setPassword("************");
$client->setTimeout(30);
```All implemented API routes will match the URL structure, for example:
```php
// Example of structure - the code route for "api/Product/Search" call:
$client->product()->search();
```### Searching for products
You can search for a product by providing parameters. You must select one "product set" at minimum; for example: all public products.You will typically use this to find a specific product, for example:
```php
use SoftwarePunt\PSAPI\Models\Params\ProductSearchParams;$searchParams = new ProductSearchParams();
$searchParams->ShowAllProductSet = true;
$searchParams->ShowSubscribedProductSet = true; // must be set to explicitly include private data
$searchParams->FilterOnEan = "1213456789125";$products = $client->product()->search($searchParams);
$product = $products->product[0];
echo $product->summary->name; // PS Citroensnoepje 20g
```☝ The objects returned by this library are based on the API's actual XML response structure. They are fully type-hinted and have docblocks where available.
## Development
### Generating entity types
This project contains a tool that can generate or update entities from the XSD file provided by PS. All classes in `src/Models/Entities` are generated using this tool. You can use it as follows:To use it, manually run the CLI script from the project directory:
```shell
php cli/xsdgen.php path/to/PS_XSD.xsd
```You can download the latest XSD via the documentation page:
https://webapi.psinfoodservice.com/V6/prod/Documentation/Xsd