glhd/linearavel

0.0.3 2024-06-26 21:04 UTC

This package is auto-updated.

Last update: 2024-09-05 18:13:09 UTC


README

Build Status Coverage Status Latest Stable Release MIT Licensed Follow @inxilpro on Twitter

Linearavel

Linearavel 是一个功能齐全的 Linear SDK,适用于 PHP 和 Laravel。

安装

composer require glhd/linearavel

使用

Linear 使用 GraphQL,这通常不太兼容 PHP 应用程序与 API 交互的方式。此包试图弥合这一差距——使 API 调用感觉流畅,同时仍然暴露 Linear API 的所有功能。

典型的 API 调用可能看起来像这样

$viewer = Linear::viewer() // "viewer" is the name of the GraphQL query
    ->with('organization', 'id', 'name') // `with` lets you quickly retrieve nested fields
    ->get('id', 'name', 'active', 'avatarUrl', 'timezone'); // `get` defines the fields to retrieve

调用 get() 将直接返回查询结果。您还可以调用 response() 来获取一个 LinearResponse——一个自定义的 Saloon 对象,该对象公开了诸如 status()headers() 等功能,并允许您将响应 resolve() 成一个完全类型化的 Linear 数据对象。

assert($viewer instanceof Glhd\Linearavel\Data\User);
assert($viewer->name === 'Chris Morrell');
assert($viewer->organization instanceof Glhd\Linearavel\Data\Organization);
assert($viewer->organization->name === 'InterNACHI');