定制 zibios/wrike-php-library 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

zibios/wrike-php-library

最新稳定版本:v1.0.0

Composer 安装命令:

composer require zibios/wrike-php-library

包简介

Wrike PHP Library, generic implementation.

README 文档

README

Introduction

This is generic library for Wrike (online project management software) REST API.

This package contains general documentation for all features. This package is decoupled from unnecessary dependencies and can't be used without additional HTTP Client plugin.

Versions

Major Version Wrike API PHP Compatibility Initial release Support
V3 V4 PHP 7.1, PHP 7.2, TBD October, 2018 TBD
V2 V4 PHP 5.5, PHP 5.6, PHP 7.0, PHP 7.1 October, 2018 Support ends on October, 2019
V1 V3 PHP 5.5, PHP 5.6, PHP 7.0, PHP 7.1 February, 2018 Support ends on February, 2019

Project status

General

Packagist License Packagist Downloads Packagist Version Packagist Version Libraries.io

CII Best Practices SensioLabsInsight Codacy Badge Code Climate Maintainability

Branch 'master'

Scrutinizer Code Quality Scrutinizer Build Status Scrutinizer Code Coverage Travis Build Status StyleCI Coverage Status

Installation

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

$ composer require zibios/wrike-php-library "^3.0"

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Contribution

To try it yourself clone the repository:

git clone git@github.com:zibios/wrike-php-library.git
cd wrike-php-library

and install dependencies with composer:

composer install

Run PHPUnit tests:

./vendor/bin/phpunit

Usage

All operations are immutable and stateless.

/**
 * Resources access methods
 */
$api = ApiFactory::create(<PermanentToken>); // @see zibios/wrike-php-sdk

$api->account()->getAll();
$api->account()->updateDefault($params);

$api->attachments()->getAll();
$api->attachments()->getAllForFolder($folderId);
$api->attachments()->getAllForTask($taskId);
$api->attachments()->getById($attachmentId);
$api->attachments()->getByIds([$attachmentId]);
$api->attachments()->update($attachmentId, $params);
$api->attachments()->uploadForFolder($attachmentId, $params);
$api->attachments()->uploadForTask($attachmentId, $params);
$api->attachments()->delete($attachmentId);
$api->attachments()->download($attachmentId);
$api->attachments()->downloadPreview($attachmentId);
$api->attachments()->getPublicUrl($attachmentId);

$api->colors()->getAll();

$api->comments()->getAll();
$api->comments()->getAllForFolder($folderId);
$api->comments()->getAllForTask($taskId);
$api->comments()->getById($commentId);
$api->comments()->getByIds([$commentId]);
$api->comments()->update($commentId, $params);
$api->comments()->createForFolder($folderId, $params);
$api->comments()->createForTask($taskId, $params);
$api->comments()->delete($commentId);

$api->contacts()->getAll();
$api->contacts()->getById($contactId);
$api->contacts()->getByIds([$contactId]);
$api->contacts()->update($contactId, $params);

$api->customFields()->getAll();
$api->customFields()->getById($customFieldId);
$api->customFields()->getByIds([$customFieldId]);
$api->customFields()->update($customFieldId, $params);
$api->customFields()->create($params);

$api->dependencies()->getAllForTask($taskId);
$api->dependencies()->getById($dependencyId);
$api->dependencies()->getByIds([$dependencyId]);
$api->dependencies()->update($dependencyId, $params);
$api->dependencies()->createForTask($taskId, $params);
$api->dependencies()->delete($dependencyId);

$api->folders()->getAll();
$api->folders()->getAllForFolder($folderId);
$api->folders()->getById($folderId);
$api->folders()->getByIds([$folderId]);
$api->folders()->update($folderId, $params);
$api->folders()->createForFolder($folderId, $params);
$api->folders()->copy($folderId, $params);
$api->folders()->delete($folderId);

$api->groups()->getAll();
$api->groups()->getById($groupId);
$api->groups()->update($groupId, $params);
$api->groups()->create($params);
$api->groups()->delete($groupId);

$api->ids()->getAll($params); // $params required

$api->invitations()->getAll();
$api->invitations()->update($invitationId, $params);
$api->invitations()->create($params);
$api->invitations()->delete($invitationId);

$api->tasks()->getAll();
$api->tasks()->getAllForFolder($folderId);
$api->tasks()->getById($taskId);
$api->tasks()->getByIds([$taskId]);
$api->tasks()->update($taskId, $params);
$api->tasks()->createForFolder($folderId, $params);
$api->tasks()->delete($taskId);

$api->timelogs()->getAll();
$api->timelogs()->getAllForFolder($folderId);
$api->timelogs()->getAllForTask($taskId);
$api->timelogs()->getAllForContact($contactId);
$api->timelogs()->getAllForTimelogCategory($timelogCategoryId);
$api->timelogs()->getById($timelogId);
$api->timelogs()->update($timelogId, $params);
$api->timelogs()->createForTask($taskId, $params);
$api->timelogs()->delete($timelogId);

$api->timelogCategories()->getAll();

$api->users()->getById($userId);
$api->users()->update($userId, $params);

$api->version()->getAll();

$api->workflows()->getAll();
$api->workflows()->update($workflowId, $params);
$api->workflows()->create($params);
/**
 * Params normalizer
 */
$params = $api->normalizeParams([
    'foo' => 'test',
    'bar' => ['test' => 'test'],
]);

// Array
// (
//     [foo] => test
//     [bar] => {"test":"test"}
// )
/**
 * Basic API usage
 */
$params = $api->normalizeParams([
    'fields' => ['metadata'],
    'metadata' => ['key' => 'importantMetadataKey'],
]);
$allContacts = $api->contacts()->getAll($params);

$params = $api->normalizeParams([
    'metadata' => [
        [
            'key' => 'metadataKey',
            'value' => 'metadataValue',
        ]
    ],
]);
$updatedContact = $api->contacts()->update($contactId, $params);
/**
 * Upload Attachment Request require two params: resource and name
 */
$params = $api->normalizeParams([
    'resource' => fopen(__FILE__, 'rb'),
    'name' => 'name.png',
]);
$updatedContact = $api->attachments()->uploadForFolder($folderId, $params);
$updatedContact = $api->attachments()->uploadForTask($taskId, $params);

/**
 * Download Attachment Requests returns none transformed Psr\Http\Message\ResponseInterface
 */
$response = $api->attachments()->download($attachmentId);
$response = $api->attachments()->downloadPreview($attachmentId);
/**
 * Advanced API usage
 *
 * $api->recreateForNew*() - returns new Api instance
 */
$api = ApiFactory::create(<PermanentToken>); // @see zibios/wrike-php-sdk

$newApi = $api->recreateForNewAccessToken(<PermanentToken>);

$responseTransformer = new RawResponseTransformer();
$newApi = $api->recreateForNewResponseTransformer($responseTransformer);

$apiExceptionTransformer = new RawExceptionTransformer();
$newApi = $api->recreateForNewApiExceptionTransformer($apiExceptionTransformer);

Response transformers

Response can be returned in various formats according to used response transformer

Transformer Response Comment
PsrResponseTransformer Psr\Http\Message\ResponseInterface PSR response
PsrBodyTransformer Psr\Http\Message\StreamInterface PSR response body
StringBodyTransformer JSON string PSR response body casted to JSON string
ArrayBodyTransformer array PSR response body casted to array
ResponseModelTransformer ResponseModelInterface check Response transformer plugin
ResourceModelTransformer ResourceModelInterface check Response transformer plugin

ENUM's

Zibios\WrikePhpLibrary\Enum\Api

  • RequestMethodEnum
  • RequestPathFormatEnum
  • ResourceMethodEnum
  • ResponseFormatEnum

namespace Zibios\WrikePhpLibrary\Enum

  • AttachmentPreviewSizeEnum
  • AttachmentTypeEnum
  • CustomFieldAggregationEnum
  • CustomFieldCurrencyEnum
  • CustomFieldInheritanceTypeEnum
  • CustomFieldTypeEnum
  • CustomStatusColorEnum
  • DependencyRelationTypeEnum
  • InvitationStatusEnum
  • LegacyEntityTypeEnum
  • OptionalFieldEnum
  • ProjectStatusEnum
  • RescheduleModeEnum
  • ScopeEnum
  • SubscriptionTypeEnum
  • TaskDatesTypeEnum
  • TaskImportanceEnum
  • TaskStatusEnum
  • TreeScopeEnum
  • UserRoleEnum
  • UserTypeEnum
  • WeekDayEnum

Breaking Changes

V2.x due to changes in Wrike API V4

Request Replacement / Description
$api->getAccountResource()->getAll(); Now returns only one (current) account
$api->getAccountResource()->getById($accountId); Removed
$api->getAccountResource()->update($accountId, $params); $api->getAccountResource()->updateDefault($params);
$api->getAttachmentResource()->getAllForAccount($accountId); $api->getAttachmentResource()->getAll();
$api->getCommentResource()->getAllForAccount($accountId); $api->getCommentResource()->getAll();
$api->getContactResource()->getAllForAccount($accountId); $api->getContactResource()->getAll();
$api->getCustomFieldResource()->getAllForAccount($accountId); $api->getCustomFieldResource()->getAll();
$api->getCustomFieldResource()->createForAccount($accountId, $params); $api->getCustomFieldResource()->create($params);
$api->getFolderResource()->getAllForAccount($accountId); $api->getFolderResource()->getAll();
$api->getGroupResource()->getAllForAccount($accountId); $api->getGroupResource()->getAll();
$api->getGroupResource()->createForAccount($accountId, $params); $api->getGroupResource()->create($params);
$api->getInvitationResource()->getAllForAccount($accountId); $api->getInvitationResource()->getAll();
$api->getInvitationResource()->createForAccount($accountId, $params); $api->getInvitationResource()->create($params);
$api->getTaskResource()->getAllForAccount($accountId); $api->getTaskResource()->getAll();
$api->getTimelogResource()->getAllForAccount($accountId); $api->getTimelogResource()->getAll();
$api->getWorkflowResource()->getAllForAccount($accountId); $api->getWorkflowResource()->getAll();
$api->getWorkflowResource()->createForAccount($accountId, $params); $api->getWorkflowResource()->create($params);

V3.x due to refactoring for PHP >=7.1

  • ArrayTransformer for Client JSON response is removed, only PSR response is accepted
  • Strict types for method params and responses
Deprecated methods New methods
$api->getAccountResource(); $api->account();
$api->getAttachmentResource(); $api->attachments();
$api->getColorResource(); $api->colors();
$api->getCommentResource(); $api->comments();
$api->getContactResource(); $api->contacts();
$api->getCustomFieldResource(); $api->customFields();
$api->getDependencyResource(); $api->dependencies();
$api->getFolderResource(); $api->folders();
$api->getGroupResource(); $api->groups();
$api->getIdResource(); $api->ids();
$api->getInvitationResource(); $api->invitations();
$api->getTaskResource(); $api->tasks();
$api->getTimelogResource(); $api->timelogs();
$api->getTimelogCategoryResource(); $api->timelogCategories();
$api->getUserResource(); $api->users();
$api->getVersionResource(); $api->version();
$api->getWorkflowResource(); $api->workflows();

Reference

Internal

Full configured Wrike PHP SDK

Full configured Symfony bundle based on Wrike PHP SDK

Response transformer plugin for Wrike PHP Library

HTTP Client plugin for Wrike PHP Library

External

Official Wrike API Documentation

PSR Naming Conventions

Package general architecture inspired by mpclarkson/freshdesk-php-library

License

This bundle is available under the MIT license.

zibios/wrike-php-library 适用场景与选型建议

zibios/wrike-php-library 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.37k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2017 年 02 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 zibios/wrike-php-library 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 7.37k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 20
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 2
  • Forks: 15
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-02-07