承接 infamoustrey/smartsheet 相关项目开发

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

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

infamoustrey/smartsheet

Composer 安装命令:

composer require infamoustrey/smartsheet

包简介

An API for Smartsheet

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

This library serves as a convenience wrapper around the REST API that smartsheet exposes. It also uses the Collections library from the Illuminate library in lieu of arrays, so check that out if you are unfamiliar with it.

Table of Contents

Installation

The preferred method of installing this library is with Composer by running the following from your project root:

composer require infamoustrey/smartsheet

Usage

This library provides a fluent api for interacting with Smartsheet.

$smartsheetClient = new \Smartsheet\SmartsheetClient([ 'token' => 'yourapitoken' ]);

$smartsheetClient->getSheet('sheetid');

Client

The SmartsheetClient class is the entry point for the currently supported API surface.

$smartsheetClient = new \Smartsheet\SmartsheetClient([
    'token' => 'yourapitoken',
]);

$smartsheetClient->listSheets(); // Collection<Sheet>
$smartsheetClient->getSheet('4583173393803140'); // Sheet
$smartsheetClient->getRow('4583173393803140', '7813666446436228'); // Row
$smartsheetClient->getFolder('7116448184199044'); // Folder
$smartsheetClient->getWorkspace('7116448184199044'); // Workspace
$smartsheetClient->listWorkspaces(); // Collection<Workspace>
$smartsheetClient->listContacts(); // Collection<Contact>

Sheets

Fetch a list of sheets

$smartsheetClient = new \Smartsheet\SmartsheetClient([ 'token' => 'yourapitoken' ]);

$smartsheetClient->listSheets(); // Collection<Sheet>

Access a sheet, see the Sheet Object for a list of possible properties.

$smartsheetClient = new \Smartsheet\SmartsheetClient([ 'token' => 'yourapitoken' ]);

$sheet = $smartsheetClient->getSheet('4583173393803140');

// Access some fields
$sheet->getId(); // '4583173393803140'
$sheet->getName(); // 'sheet 1'

// Add some rows
$sheet->addRow([
    'ID' => "39424808324",
    'Transaction Desc' => "Toys",
    'Amount' => 754.23,
]);

Additional sheet operations:

$sheet = $smartsheetClient->getSheet('4583173393803140');

$sheet->getColumns(); // array
$sheet->getRows(); // Collection<Row>
$sheet->getColumnId('Primary'); // string

$sheet->addRows([
    ['Primary' => 'row 1', 'Status' => 'Open'],
    ['Primary' => 'row 2', 'Status' => 'Closed'],
]);

$sheet->updateRow('7813666446436228', [
    'Status' => 'Done',
]);

$sheet->updateRows([
    '7813666446436228' => ['Status' => 'Done'],
    '1122334455667788' => ['Status' => 'Queued'],
]);

$sheet->deleteRow('7813666446436228');
$sheet->deleteRows(['7813666446436228', '1122334455667788']);

$sheet->rename('Renamed Sheet');
$sheet->copyTo('Copied Sheet', '7116448184199044');
$sheet->copyRowsTo(['7813666446436228'], '9988776655443322');

$sheet->addColumn([
    'title' => 'Status',
    'type' => 'TEXT_NUMBER',
]);

$sheet->addColumns([
    ['title' => 'Status', 'type' => 'TEXT_NUMBER'],
    ['title' => 'Owner', 'type' => 'TEXT_NUMBER'],
]);

$sheet->shareSheet([
    [
        'email' => 'user@example.com',
        'accessLevel' => 'EDITOR',
    ],
]);

$sheet->getShares();

For replacing data in-place, the library also exposes:

$sheet->createRow(['Primary' => 'new row']);
$sheet->replaceFirstRow(['Primary' => 'updated first row']);
$sheet->replaceRows($rows, 'Primary');
$sheet->sync($rows, 'Primary');
$sheet->dropAllRows();
$sheet->dropAndReplace($rows);
$sheet->dropAllColumnsExcept(['Primary', 'Status']);

Summary field helpers:

$sheet->addSummaryField('Total', '=COUNT([Primary]:[Primary])');
$sheet->getSummaryFields();
$sheet->getSummaryFieldByName('Total');
$sheet->updateSummaryField([
    'id' => 123,
    'title' => 'Total',
    'formula' => '=COUNT([Primary]:[Primary])',
]);
$sheet->updateSummaryFieldByName('Total', [
    'title' => 'Total',
    'formula' => '=COUNT([Primary]:[Primary])',
]);
$sheet->deleteSummaryField('123');
$sheet->deleteSummaryFields(['123', '456']);
$sheet->deleteAllSummaryFields();

Rows

Rows can be fetched directly from the client or from a sheet collection.

$row = $smartsheetClient->getRow('4583173393803140', '7813666446436228');

$row->getId();
$row->getSheet(); // Sheet
$row->getCells(); // Collection<Cell>
$row->getCell('Primary'); // Cell|null

$row->addAttachmentLink([
    'attachmentType' => 'LINK',
    'name' => 'Project Docs',
    'description' => 'External project documentation',
    'url' => 'https://example.com/docs',
]);

$row->addAttachment('/path/to/file.pdf');
$row->delete();

Workspace

Fetch a workspace and access its properties. See the Workspace Object for a list of possible properties.

$smartsheetClient = new \Smartsheet\SmartsheetClient([ 'token' => 'yourapitoken' ]);

$workspace = $smartsheetClient->getWorkspace('7116448184199044'); // \Smartsheet\Resources\Workspace

$workspace->getId(); // '7116448184199044'
$workspace->getName(); // 'New workspace'
$workspace->getSheets(); // array

// Fetch a sheet by name
$workspace->getSheet('sheet name'); // Sheet

// Create a sheet with some columns
$workspace->createSheet('sheet name', [
    [
        "title" => "Primary",
        "type" => "TEXT_NUMBER",
        "primary" => true
    ]
]);

Folder

Fetch a folder and access its properties. See the Folder Object for a list of possible properties.

$smartsheetClient = new \Smartsheet\SmartsheetClient([ 'token' => 'yourapitoken' ]);

$folder = $smartsheetClient->getFolder('7116448184199044'); // Folder

// Access some fields
$folder->getId(); // '7116448184199044'
$folder->get('name'); // 'Projects'
$folder->getPermaLink(); // 'https://app.smartsheet.com/...'
$folder->getSheets(); // array

$sheet = $folder->getSheet('sheet name');

$folder->createSheet('sheet name');
$folder->createSheets([
    'sheet one',
    'sheet two',
]);

Contacts

Fetch account contacts:

$contacts = $smartsheetClient->listContacts(); // Collection<Contact>

Generic Resource Helpers

All resource objects extend Smartsheet\Resources\Resource, which provides a few helpers for accessing raw payload data:

$sheet = $smartsheetClient->getSheet('4583173393803140');

$sheet->getData(); // full API payload as an array
$sheet->get('permalink'); // a single field from the payload
$sheet->toJSON(); // payload encoded as JSON

Issues

Use this repository's issue tracker to resolve issues and ask questions.

Roadmap

Full api coverage! There's a lot missing, if you see something missing then put in a PR! Your help is appreciated!

Contributing

Feel free to submit a PR, just be sure to explain what you are trying to fix/add when submitting it. If you do decide to add functionality, it must be covered by a test. See the contribution guide for more info.

To run the tests simply run:

./vendor/bin/phpunit

Static analysis can be run with:

vendor/bin/phpstan analyse src tests --memory-limit 1G

infamoustrey/smartsheet 适用场景与选型建议

infamoustrey/smartsheet 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 29.33k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2020 年 01 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「http」 「client」 「library」 「smartsheet」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 infamoustrey/smartsheet 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 infamoustrey/smartsheet 我们能提供哪些服务?
定制开发 / 二次开发

基于 infamoustrey/smartsheet 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 10
  • Watchers: 4
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-20