oilstone / api-commerce-layer-integration
A Commerce Layer integration package for garethhudson07/api
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/oilstone/api-commerce-layer-integration
Requires
- php: ^8.1
- garethhudson07/api: ^9.5
- guzzlehttp/guzzle: ^7.8
- nesbot/carbon: ^3.10
- psr/log: ^1.1|^2.0|^3.0
- psr/simple-cache: ^1.0|^2.0|^3.0
Requires (Dev)
- laravel/framework: ^11.0
- oilstone/api-resource-loader: ^5.3
This package is auto-updated.
Last update: 2025-11-11 12:26:06 UTC
README
This package provides the foundations for integrating the garethhudson07/api toolkit with the Commerce Layer platform. It includes an HTTP client, query builder, and repository abstraction tailored to Commerce Layer's JSON:API compliant endpoints.
Highlights
- A dedicated HTTP client (
Clients\\CommerceLayer) that encapsulates authentication, logging, and error handling for Commerce Layer requests. - A fluent query builder (
Query) capable of compiling Commerce Layer filter, include, sorting, and pagination parameters. - A repository abstraction (
Repository) that applies default constraints, manages caching, and exposes CRUD helpers for Commerce Layer resources. - Lightweight record and collection helpers for working with JSON:API responses.
- Optional PSR-16 caching support via the
Cache\\QueryCacheHandlerutility.
The package is intentionally lightweight so it can act as the starting point for bespoke integrations. Additional bridges (for example to the API pipeline or resource loader packages) can be layered on using the same methodology throughout this codebase.
Installation
Install the package via Composer:
composer require oilstone/api-commerce-layer-integration
Usage
use GuzzleHttp\Client as HttpClient; use Oilstone\ApiCommerceLayerIntegration\Clients\CommerceLayer; use Oilstone\ApiCommerceLayerIntegration\Repository; $http = new HttpClient(); $client = new CommerceLayer($http, 'https://your-organization.commercelayer.io/api', 'your-access-token'); $repository = (new Repository('orders')) ->setClient($client) ->setDefaultIncludes(['customer', 'line_items']); $orders = $repository->get([ ['status', '=', 'placed'], ['number', 'like', 'UK%'], ]); $firstOrder = $repository->find('order-id-123');
Testing
composer validate find src -name "*.php" -print0 | xargs -0 -n1 php -l
License
The MIT License (MIT). Please see License File for more information.