softwarepunt/psinfoodservice-api-client
最新稳定版本:v1.1.0
Composer 安装命令:
composer require softwarepunt/psinfoodservice-api-client
包简介
Unofficial PHP API Client for PS in foodservice Web API (PS-API)
README 文档
README
Unofficial PHP API Client for PS in foodservice Web API (PS-API)
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
Setup
Use Composer to add the package as a dependency to your project:
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 to request them first.
<?php use SoftwarePunt\PSAPI\Client; require_once "vendor/autoload.php"; $client = new Client(); $client->setUsername("webapi@yourorg.ps"); $client->setPassword("************"); $client->setTimeout(30);
All implemented API routes will match the URL structure, for example:
// 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:
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:
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
统计信息
- 总下载量: 510
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-07-13