定制 acendy/acendy-api-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

acendy/acendy-api-client

最新稳定版本:1.0.0

Composer 安装命令:

composer require acendy/acendy-api-client

包简介

Acendy API Client

README 文档

README

The Acendy API Client is a PHP library for interacting with the Acendy API.

For detailed API specifications, refer to the official documentation at http://mystoreapi.docs.apiary.io.

Getting Started

To use the Acendy API Client, you need an API token for authentication. Follow these steps:

  1. Obtain an API Token: Log in to https://auth.mystore.no/login and generate an API token. This token authenticates all requests made through the client.
  2. Review the API Docs: Visit http://mystoreapi.docs.apiary.io for comprehensive details on endpoints, authentication, and request/response formats.
  3. Set up the client: Use the token, your store's unique identifier, and the API base URL to initialize the client (see Installation and Usage Examples below).

Installation

composer require acendy/acendy-api-client

Using the library requires a PSR-18 compatible HTTP Client like GuzzleHTTP. If you don't have one, install Guzzle + PSR-7:

composer require guzzlehttp/guzzle guzzlehttp/psr7

Usage examples

Below are examples demonstrating how to use the Acendy API Client. These assume you have Guzzle installed.

Initializing the Client

Instantiate the AcendyApiClient with your API credentials and HTTP dependencies:

require_once __DIR__ . '/vendor/autoload.php';

use Acendy\Api\Client\AcendyApiClient;

use GuzzleHttp\Client;
use GuzzleHttp\Psr7\HttpFactory;

$client = new AcendyApiClient(
    baseURL: 'https://api.mystore.no/',
    token: 'your-api-token',
    storeName: 'your-store-name',
    httpClient: new Client(),
    requestFactory: new HttpFactory(),
    streamFactory: new HttpFactory()
);

Simple example: get all customers

Retrieve a list of all customers without additional parameters:

$customers = $client->customers()->getAllCustomers();
print_r($customers);

Simple example: get customer by id

Retrieve a single customer:

$customer = $client->customers()->getCustomerById('123456');
print_r($customer);

Basic example: get orders with pagination

Fetch orders with basic pagination using the QueryParameters class:

use Acendy\Api\Client\QueryParameters;

$queryParams = new QueryParameters(
    pageNumber: 1,
    pageSize: 5
);
$paginatedOrders = $client->orders()->getAllOrders($queryParams);
print_r($paginatedOrders);

Advanced example: Get orders with full query parameters

Perform a complex query on customers with filters, sorting, includes, and field selection:

use Acendy\Api\Client\QueryParameters;

$queryParams = new QueryParameters(
    pageNumber: 1,
    pageSize: 50,
    filters: [
        'customer.id' => '123456',
        'order-status.id' => '1',
        'currency' => 'NOK'
    ],
    sort: ['-created_at'],
    include: ['customer', 'order-status', 'order-products'],
    fields: ['customer_address_name', 'currency', 'created_at'],
);

$orders = $client->orders()->getAllOrders($queryParams);
print_r($orders);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-08