承接 kylewlawrence/infinity-api-client-php 相关项目开发

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

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

kylewlawrence/infinity-api-client-php

最新稳定版本:v1.0.242

Composer 安装命令:

composer require kylewlawrence/infinity-api-client-php

包简介

Infinity API PHP SDK

README 文档

README

API Client Version

This is the first version of a community sponsored PHP SDK client for Infinity API.

API version support

This client only supports Infinity's API v2. Please see their API documentation for more information.

Requirements

  • PHP 8.1+

Installation

The Infinity API PHP SDK client can be installed using Composer.

Are you using this with Laravel? If so, use the Laravel wrapper.

Composer

To install run composer require kylewlawrence/infinity-api-client-php

Configuration

Configuration is done through an instance of KyleWLawrence\Infinity\Api\HttpClient. The block is mandatory and if not passed, an error will be thrown.

// load Composer
require 'vendor/autoload.php';

use KyleWLawrence\Infinity\Api\HttpClient as InfinityAPI;

$workspace = 1234; // replace this with your Infinity workspace ID
$bearer     = "6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv"; // replace this with your Infinity Personal Access/Bearer token

$client = new InfinityAPI($workspace);
$client->setAuth('bearer', ['bearer' => $bearer]);

Usage

Basic Operations

// Get all boards
$boards = $client->boards()->getAll();
print_r($boards);

// Create a new board
$newBoard = $client->boards()->create([
    'name' => 'Blah Blah',                          
    'description' => 'Bler bleman blope',                     
    'user_ids' => [1234, 1235, 12346],      
]);
print_r($newBoard);

// Update an item
$client->boards('PWefUeHA8Pd')->items('364019f5-0198-407b-931a-4f8ea51ecc28')->update(',[
    'folder_id' => 'U7MjUC5jNpM'
]);

// Delete an item value
$client->boards('PWefUeHA8Pd')->items(''364019f5-0198-407b-931a-4f8ea51ecc28'')->values()->delete('8b9fee67-600c-499f-ab19-04bd9092be4e');

// Get all workspaces
$workspaces = $client->workspaces()->getAll();
print_r($workspaces);

Discovering Methods & Classes

// Get the base methods/classes available
$client->getValidSubResrouces()

// The above example will output something like:
[
    "boards" => "KyleWLawrence\Infinity\Api\Resources\Core\Boards",
    "profile" => "KyleWLawrence\Infinity\Api\Resources\Core\Profile",
    "attachments" => "KyleWLawrence\Infinity\Api\Resources\Core\Attachments",
    "users" => "KyleWLawrence\Infinity\Api\Resources\Core\Users",
    "workspaces" => "KyleWLawrence\Infinity\Api\Resources\Core\Workspaces",
]

// Most available subresources are on the boards class, accessible by:
$client->boards()->getValidSubResources()

// These are methods/classes that can be chained to the client. For instance:
// For instance, "boards" => "KyleWLawrence\Infinity\Api\Resources\Core\Boards", can be used as $client->boards()

// To find the chained methods available to the class, now do:
$client->boards()->getRoutes()

// The above example will output something like:
[
    "getAll" => "boards",
    "get" => "board/{id}",
    "create" => "boards",
]

// Those routes can be compared with the Infinity documentation routes and run as chained methods such as the below command to get all sites:
$client->boards()->getAll()

Pagination

The Infinity API offers a way to get the next pages for the requests and is documented in the Infinity Developer Documentation.

The way to do this is to pass it as an option to your request.

$boards = $this->client->boards('PWefUeHA8Pd')->items()->getAll(['after' => '8b9fee67-600c-499f-ab19-04bd9092be4e', 'sort_by' => 'created_at', 'limit' => 100]);

Some of the allowed options include

  • sort_by
  • after
  • before
  • limit

Retrying Requests

Add the RetryHandler middleware on the HandlerStack of your GuzzleHttp\Client instance. By default KyleWLawrence\Infinity\Api\HttpClient retries:

  • timeout requests
  • those that throw Psr\Http\Message\RequestInterface\ConnectException:class
  • and those that throw Psr\Http\Message\RequestInterface\RequestException:class that are identified as ssl issue.

Available options

Options are passed on RetryHandler as an array of values.

  • max = 2 limit of retries
  • interval = 300 base delay between retries in milliseconds
  • max_interval = 20000 maximum delay value
  • backoff_factor = 1 backoff factor
  • exceptions = [ConnectException::class] Exceptions to retry without checking retry_if
  • retry_if = null callable function that can decide whether to retry the request or not

Contributing

Pull Requests are always welcome. I'll catch-up and develop the contribution guidelines soon. For the meantime, just open and issue or create a pull request.

Copyright and license

Copyright 2023-present Infinity

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固