承接 fulfillment/oms-api 相关项目开发

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

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

fulfillment/oms-api

最新稳定版本:0.1.2

Composer 安装命令:

composer require fulfillment/oms-api

包简介

A wrapper for Fulfillment's OMS API

README 文档

README

A PHP library that wraps Fulfillment's OMS API for easy use

Example

use Fulfillment\OMS;
use Fulfillment\OMS\Models\Request;

$apiWrapper = new OmsClient(__DIR__); //instantiate OMS with a configuration file or array of settings

$newOrder = new Order($orderData); //create a new Request\Order

/*
 * 1. Validate the order
 * 2. Make a POST request to /orders
 * 3. Parse the returned api response into a new Response\Order object
 */
$createdOrder = $apiWrapper->orders->createOrder($newOrder);

Installation

composer require fulfillment/oms-api

Configuration

Configuration needed is simple:

  • USERNAME - Email address for your account
  • PASSWORD - Password for your account
  • CLIENT_ID - Client Id for your merchant
  • CLIENT_SECRET - Client secret for your merchant
  • ACCESS_TOKEN - If already created, an access token for your merchant
  • API_ENDPOINT - The end point for the fulfillment api services you are using (https://api.fulfillment.com)

Optional Configurations:

  • JSON_ONLY - Defaults to false. If set to true all responses will be returned as pure JSON as it is from the server.

There are two ways to configure OMS API

Use dotenv

Use a .env file compatible with fantastic phpdotenv library. Simply specify the absolute path to the folder containing your .env file as an argument in the OMS constructor.

$apiWrapper = new OmsClient('absolute/path/to/a/folder')

An example file called .env.example can be found in the root directory.

Use an array

Alternatively, create an array with key/values matching the above specified configuration and pass it as an argument in the OMS constructor.

$apiWrapper = new OmsClient($yourConfigurationArray)

Usage

Working With Models

Models (plain PHP classes) are used by the wrapper to facilitate easy building, validation, and parsing of api data. There are two types of models:

Request Models

Found at Fulfillment\OMS\Models\Request these are the models that are used when making any request that requires data (such as a POST or PUT request). Currenty you will need to use the implemented models to make these type of requests. They differ slightly from the other type (Response model) because they do not require as much data as is returned from the api.

Example

$newOrder = new Order($myOrderData);
$order = $apiWrapper->orders->createOrder($newOrder);

Response Models

Found at Fulfillment\OMS\Models\Response these are the models that response json is parsed in to. They inherit from Request models and so can be reused to make requests.

Example

$returnedOrder = $apiWrapper->orders->getOrder($orderId);

Model Validation

By default all models are validated before a request is sent (in the case of a POST or PUT request). A descriptive error will be thrown if a model has any validation failures. Eventually this will be a configurable option.

Roadmap

There's still lots to do, check the issues section to see what is being worked on or make a request.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-13