Download the PHP package chargemap/ocpi-protocol without Composer
On this page you can find all versions of the php package chargemap/ocpi-protocol. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download chargemap/ocpi-protocol
More information about chargemap/ocpi-protocol
Files in chargemap/ocpi-protocol
Package ocpi-protocol
Short Description Library to handle OCPI. Compatible with PSRs. Uses JsonSchema to validate payloads.
License MIT
Informations about the package ocpi-protocol
OCPI Protocol
Library to handle OCPI. Compatible with PSRs.
Functionality
Library provides OCPI request/response classes for eMSP interfaces, models, factories and errors. Listing requests/responses are also supported for GET routes. The responses need a corresponding request to be constructed. It is required to ensure the presence and validity of offset and limit request headers and X-Total-Count, X-Limit and Link response headers. So it is quite easy to construct valid listing response or get the next request.
eMSP interface
Respond to CPO
Each request and response class correspond to an eMSP interface route. Request classes must be instantiated by providing PSR-7 compatible request (got from CPO). Internally, it extracts the authorization token from headers, and validates the body (if necessary) against json schema. Then, it constructs corresponding model class using the factories. The model is accessible via a getter.
Response classes must be instantiated with a model instance, even if it's not used (e.g. in Post/Put/Patch responses). It can be converted to PSR-7 compatible response instance using getResponseInterface method.
Use of listing request/response
Request the CPO
This part provides an API SDK to request the CPO. To use it, you need to instantiate the OcpiClient with OcpiConfiguration and needed endpoints. Then you can perform the requests like that:
Listing request/response
Common
Errors
Each error class corresponds to an OCPI error code. It can be converted to the PSR-7 response instance just like any response class. It ensures correct HTTP error code as well as OCPI status code.
Errors are supposed to be thrown and caught by a middleware/listener and then transformed to the response.
Models
Models fetched from request's/response's json body correspond to the OCPI objects. The exception to the rule is Partial[Class] classes, that are used in PATCH routes. They have the same but nullable properties as their corresponding [Class].
All versions of ocpi-protocol with dependencies
ext-json Version *
ext-mbstring Version *
psr/log Version ^1.1
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.0
php-http/discovery Version ^1.7
myclabs/php-enum Version ^1.7
justinrainbow/json-schema Version ^5.2