承接 mallgroup/mpapi-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

mallgroup/mpapi-client

Composer 安装命令:

composer require mallgroup/mpapi-client

包简介

PHP Client for Mall marketplace API

README 文档

README

License PHPStan Psalm

Mall Marketplace API Client

Description

MPAPI client is a tool created to help Internet Mall, a. s. partners easily manage article catalogue, deliveries, orders etc. using Mall Marketplace API.

Requirements

  • 64bit version of PHP 7.4 or PHP 8
  • Guzzle 7

Installation

To install the client using Composer run following command in your repository

composer require mallgroup/mpapi-client

Implementation

Info

Client consists of one main client and multiple, separate, domain clients.

The main client groups all domain clients under one object, for easier implementation, but every domain client can be initialized and used by itself.

Every client provides an interface that SHOULD be used as parameter types in code, instead of client classes themselves (i.e., use MpApiClientInterface $client or BrandsClientInterface $client instead of MpApiClient $client or BrandsClient $client).

When initializing the client, you MUST provide

  1. an authenticator implementing AuthMiddlewareInterface
    • currently, only ClientIdAuthenticator, which accepts my-client-id, is provided
    • in the future, new authenticators will be released (i.e., OAuth)
  2. name of the app using the API
    • it is sent with every request to Mall API for easier request identification and debugging of reported issues
    • please provide a simple, yet meaningful name, i.e., MyAppName CRM or MyAppName Order sync instead of a random string

Examples

There are 2 main ways to initialize the client

1. Using MpApiClient with default config

<?php declare(strict_types=1);

use MpApiClient\Common\Authenticators\ClientIdAuthenticator;
use MpApiClient\MpApiClient;
use MpApiClient\MpApiClientOptions;

require 'vendor/autoload.php';

// 1. Initialize client options with request authenticator
$options = new MpApiClientOptions(
    new ClientIdAuthenticator('my-client-id')
);

// 2. Initialize MP API Client
$client = MpApiClient::createFromOptions('my-app-name', $options);

// 3. Get brand client
$brandClient = $client->brand();

2. Using MpApiClient (or any other domain client) with custom http client

  • every domain client can be initialized this way as a standalone client
  • when initializing a custom http client, handler stack with AuthMiddlewareInterface MUST be provided!
<?php declare(strict_types=1);

use GuzzleHttp\Client;
use GuzzleHttp\Handler\CurlHandler;
use GuzzleHttp\HandlerStack;
use MpApiClient\Brand\BrandClient;
use MpApiClient\Common\Authenticators\ClientIdAuthenticator;
use MpApiClient\MpApiClient;
use MpApiClient\MpApiClientOptions;

require 'vendor/autoload.php';

// 1. Initialize request authenticator
$authenticator = new ClientIdAuthenticator('my-client-id');

// 2. Create custom Guzzle http client with authenticator middleware

// 2.1 Create CurlHandler stack and Guzzle http client manually
$handler      = new CurlHandler();
$handlerStack = HandlerStack::create($handler);
$handlerStack->push($authenticator->getHandler());

$httpClient = new Client(
    [
        'base_uri'        => 'https://mpapi.mallgroup.com/v1/',
        'timeout'         => 10,
        'allow_redirects' => true,
        'handler'         => $handlerStack,
    ]
);

// 2.2. Create Guzzle client using MpApiClientOptions object
$options = new MpApiClientOptions($authenticator);
$options->setTimeout(30);

$httpClient = new Client($options->getGuzzleOptionsArray());

// 3. Create MpApiClient and BrandClient using custom Guzzle client
$client      = new MpApiClient($httpClient, 'my-app-name')
$brandClient = new BrandClient($httpClient, 'my-app-name')

Examples for all client domains

List of custom Exceptions thrown in this client can be found here

⚠ Warning

  • client does not include support for deprecated endpoints that will be changed, replaced or removed in the future (i.e., /v1/deliveries or /v1/gifts)

ℹ Known missing or incomplete features

  • Support for /v2/transports endpoints

mallgroup/mpapi-client 适用场景与选型建议

mallgroup/mpapi-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 128.46k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2016 年 08 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 mallgroup/mpapi-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mallgroup/mpapi-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 mallgroup/mpapi-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 128.46k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 4
  • Forks: 16
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2016-08-18