forward-force/daxko-api-sdk 问题修复 & 功能扩展

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

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

forward-force/daxko-api-sdk

Composer 安装命令:

composer require forward-force/daxko-api-sdk

包简介

PHP Wrapper around Daxko API

README 文档

README

This is a wrapper around Daxko API. The API is very minimal, so this implementation is fairly simple.

Installation

Install via composer as follows:

composer require forward-force/daxko-api-sdk

Usage

Authentication

Daxko client relies on the access_token returned by auth request to Daxko authentication endpoint to access the API.

Requesting access_token using Daxko client:

$apiToken = \ForwardForce\Daxko\Daxko::getToken(
    '<client_id>',
    '<client_secret>',
    '<scope>',
    '<grant_type>'
);

The access_token returned by getToken can then be used to create a new client instance:

$daxkoClient = new \ForwardForce\Daxko\Daxko($apiToken['access_token']);

To avoid requesting a new token everytime a new client is needed, the token can be stored(encrypted) in some data store(Redis, Session, etc..).

Refreshing the access_token using refresh_token from a previous authentication

$apiToken = Daxko::refreshToken(
    '<client_id>',
    '<refresh_token>',
);

Daxko Classes

Get all classes for a given location and specific date range:

$classes = $daxkoClient->classes()
    ->all([
        'startDate' => '<2020-02-09>',
        'endDate' => '<2021-02-09>',
        'locationId' => '<5506>',
    ]);

Get a single class by ID:

$class = $daxkoClient->classes()->get('<class_id>');

Getting the value of a given field is as easy as accessing the class instance property:

$name = $class->name; // the actual class name

Handling errors

All Daxko entities inherit from DaxkoEntity class, which provide a hasErrors() and getErrors() method that can be used to verify if the client receive a successful response from the API:

$class = $daxkoClient->classes()->get('<class_id>');

 if ($class->hasErrors()) {
    var_dump($class->getErrors()));
}

Contributions

To run locally, you can use the docker container provided here. You can run it like so:

docker-compose up

Then you can ssh into the php-fpm container. Please note, you need to set your DAXKO API key and SECRET as environmental variables $DAXKO_TOKEN and $DAXKO_SECRET respectively. However, the secret is not needed at this time you could set it to anything.

xdebug is fully configured to work as cli, hookup your favorite IDE to it and debug away!

There is auto-generated documentation as to how to run this library on local, please take a look at phpdocker/README.md

If you find an issue, have a question, or a suggestion, please don't hesitate to open a github issue.

Acknowledgments

Thank you to phpdocker.io for making getting PHP environments effortless!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-02-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固