trackmage/trackmage-sdk-php 问题修复 & 功能扩展

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

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

trackmage/trackmage-sdk-php

Composer 安装命令:

composer require trackmage/trackmage-sdk-php

包简介

TrackMage PHP SDK

README 文档

README

Trackmage - A tracking page for your store. Beautiful, branded, customizable.

TrackMage SDK for php

Total Downloads

TrackMage is your most automated shipment tracking tool ever. Discover the simple way to show your customers where their parcels are, provide support and get more great reviews

Getting Started

  1. Create a TrackMage account – First of all, you need to sign up for a TrackMage account and retrieve your clientId and clientSecret.
  2. Minimum requirements – To run the SDK you need to have installed PHP >= 5.6. We highly recommend using v7.2 or higher.
  3. Install the SDK – Using [Composer] is the recommended way to install the TrackMage SDK for PHP. The SDK is available on Packagist as the trackmage/trackmage-sdk-php package
    composer require trackmage/trackmage-sdk-php
    
  4. See the docs There are API documentation and the Swagger reference

Quick examples

Create a client

use TrackMage\Client\TrackMageClient;

$clientId = '<client-it>';
$clientSecret = '<client-secret>';
$client = new TrackMageClient($clientId, $clientSecret);

Posting a tracking number

$workspaceId = 100;

$response = $client->post('/shipments', ['json' => [
    'workspace' => '/workspaces/'.$workspaceId,
    'trackingNumber' => 'TN-1',
]]);
$shipment = TrackMageClient::item($response);

$response = $client->get('/workspaces/'.self::$workspaceId.'/shipments');
$shipments = TrackMageClient::collection($response);

Get workspaces list

$response = $client->get('/workspaces/'.$workspaceId.'/shipments');
$workspaces = TrackMageClient::collection($response);

Get carriers list

$response = $client->get('/public/carriers');
$carriers = TrackMageClient::collection($response);

Create webhook

Here is the webhook handler example that you need to make accessible on your side.

$workflow = [
    'type' => 'webhook',
    'period' => 'immediately',
    'title' => 'Webhook for testing',
    'workspace' => '/workspaces/<id>',
    'enabled' => true,
    'concurrency' => '1',
    'url' => 'http://acme.example',
    'authType' => 'basic',
    'username' => 'webhook_user',
    'password' => 'password',
    'notificationEmails' => [
        'test@email.com', 'test-2@email.com',
    ],
];
$response = $client->post('/workflows', ['json' => $workflow]);
$workflow = TrackMageClient::item($response);
$workflowId = $workflow['id'];

Tests

To run the unit tests:

composer update
./vendor/bin/phpunit

phpstan

vendor/bin/phpstan analyse -c phpstan.neon
vendor/bin/phpstan analyse -c phpstan-tests.neon

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固