opero-crm/erli-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

opero-crm/erli-api

最新稳定版本:v0.0.20

Composer 安装命令:

composer require opero-crm/erli-api

包简介

Manual PHP client for the Erli marketplace shop API (OperoCRM).

README 文档

README

Manual PHP SDK for the Erli shop API, maintained for OperoCRM. All documented HTTP operations from the public OpenAPI spec are implemented as typed methods; requests are associative arrays matching the JSON schemas, while responses are returned as model objects (see the API reference).

Requirements

  • PHP 8.1+
  • Extensions: curl, json, mbstring

Install

composer require opero-crm/erli-api

Usage (plain PHP)

Set environment variables (or populate $_ENV before constructing the client). The HTTP layer reads them from BaseApi (see lib/Api/BaseApi.php).

VariablePurposeDefault
ERLI_API_HOSTAPI base URLhttps://erli.pl/svc/shop-api
ERLI_API_TOKENBearer token(empty)
ERLI_API_USER_AGENTUser-Agent headeropero-crm/erli-api (PHP)
use OperoCRM\ErliApi\ErliApiClient;

$_ENV['ERLI_API_TOKEN'] = $token;
$_ENV['ERLI_API_HOST'] = 'https://sandbox.erli.dev/svc/shop-api';

$client = new ErliApiClient(
    token: $token, // required if not present in ERLI_API_TOKEN
    userAgent: 'my-app/1.0', // optional
    baseUrl: 'https://sandbox.erli.dev/svc/shop-api', // optional
);

$shop = $client->me();
$hits = $client->products()->search([
    // body must match OpenAPI schema ProductSearch
]);

$firstProductArray = $hits[0]->toArray();

Errors (non-2xx or invalid JSON) throw OperoCRM\ErliApi\ApiException with HTTP code and decoded body when available.

Client accessors

ErliApiClient methodAPI groupCoverage
me()ShopGET /me
shop()Shopsame via ShopApi::me()
products()Productsearch, batch update, CRUD, discounts
orders()Ordersearch, get, update, status
payments()Paymentpayments, operations, payouts
priceLists()Delivery price listsCRUD + list + details
shipping()Shippingparcels, external parcels, posting points, pickup protocols
dictionary()Dictionariesattachments, attributes, categories, delivery, responsible entities
hooks()Hookslist, run, save, delete
inbox()Inboxunread, search, mark-read
billing()Billingshop + company entries/rebates
campaigns()Campaignscampaigns summary
commission()Commissioncommission estimate

Use hooks()->getHooks() for GET /hooks. Other hook helpers: runCheckBuyability, runProductsNeedSync, save, delete.

Return types

Client methods now return model instances (or lists of models), for example:

  • me() returns Shop
  • products()->search() returns list<Product>
  • orders()->search() returns list<Order>
  • payments()->searchPayments() returns list<Payment>
  • inbox()->getUnread() returns list<Message>

If you need raw payloads (for logging, caching, or custom serialization), call toArray() on the returned model.

$payment = $client->payments()->getPayment('payment-id');
$payload = $payment->toArray();

Models (OperoCRM\ErliApi\Model)

DTOs in lib/Model/ are maintained in this repository (not produced from the vendor OpenAPI file, which can disagree with the live API). Use Model::fromArray() / toArray() and BaseModel::mapFromList() where types help; API client methods still accept plain array request payloads.

Notable types include Discount, Message, PriceList, ShippingMethod, Category, Attribute, DeliveryMethod, Vendor, ResponsibleSchema, Attachment, PostingPoint, Parcel, PickupProtocols / PickupProtocol, ExternalParcel, Payment, Payout, Transaction, CheckBuyabilityResult, and aliases such as ProductProductResponse, ShopShopResponse.

BillingApi currently returns JsonObjectResponse because billing payload shapes are not fully normalized yet; use ->toArray() to read raw keys.

Laravel

The service provider and facade are registered via Composer extra.laravel.

You can configure the client in config/services.php:

'erli_api' => [
    'token' => env('ERLI_API_TOKEN'),
    'user_agent' => env('ERLI_API_USER_AGENT'),
    'base_url' => env('ERLI_API_HOST'),
],

token is expected for authenticated calls. user_agent and base_url are optional; if omitted, environment/default values are used.

use OperoCRM\ErliApi\Laravel\Facades\ErliApi;

$rows = ErliApi::orders()->search([
    // OrderSearch
]);

Query parameters

GET /products/{externalId} supports repeated fields query keys. Pass a list of strings:

$client->products()->get('sku-123', ['name', 'stock', 'price']);

Repeated list parameters (e.g. fields) are encoded as repeated keys (fields=name&fields=stock), not http_build_query()’s fields[0]= style. Booleans in query strings use 0 / 1.

统计信息

  • 总下载量: 40
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固