承接 tamkeen-tms/rest-client 相关项目开发

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

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

tamkeen-tms/rest-client

Composer 安装命令:

composer require tamkeen-tms/rest-client

包简介

PHP REST client for Tamkeen's API (tamkeentms.com)

README 文档

README

What is this?

This is the official PHP client for Tamkeen's REST API. You can use this in your PHP applications to communicate with Tamkeen. Before you start you need to acquire an the "Tenant id" and the secret auth "key"; you can find this info under Administration > API.

Installation

You can require this library into your project using composer, via the following command:

composer require tamkeen-tms/rest-client

Next, you will be able to use it inside your project through the namespace Tamkeen

How it works

This library merely sends requests to Tamkeen's API endpoints. So, you need to know what endpoints are available and how to pick the correct one! A list of the endpoints are available on Tamkeen's website.

Creating a client

Before sending requests you need to initiate a new "Client" instance, and pass it the "Tenant" and authorization key. Through this client you will be able to make the requests. Each "Request" must be made through a "Client". You can instantiate multiple clients to make requests to multiple copies of the application!

$client = new Tamkeen\Client([tenant], [secret key]) // New client instance

Sending a request

Using the created client you can now send new requests, for example:

$request = new Tamkeen\Request($client, 'GET', 'branches'); // Create the request
$response = $request->send();

You need to call ->send(), which will send the request to the application and return the response. The response will be in JSON format.

Examples:

Here is an example for fetching the branches list:

try{
    $request = $client->request('get', 'branches'); // Create the request
    $response = $request->send(); // Send it, returns the response

}catch(RequestException $e){
    /**
    * Possible error messages include:
    * tenant_not_identified: The tenant id was not provided, or invalid
    * api_disabled: API is disabled for the tenant. (Contact the support team to enable it).
    * api_key_missing: The authentication key missing.
    * api_key_invalid: The authentication key is invalid.
    * api_error: An error happened at the API's level; server error (500).
    **/
}

The $response in this case would return:

{
    "branches": [{
        "id": 1,
        "name": "Headquarters",
        "code": "HQ"
        "currency": "USD"
    }]
}

For any further questions please feel free to create a new issue here.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-05-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固