zibios / wrike-php-library
Wrike PHP Library, generic implementation.
Installs: 7 212
Dependents: 3
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 15
Open Issues: 4
Requires
- php: >=5.5
- psr/http-message: ^1.0
Requires (Dev)
- phpunit/phpunit: >=4.0,<6.0
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.
- For general purpose please check full configured Wrike PHP SDK - recommended for most users.
- For Symfony Framework please check full configured Wrike bundle based on this library
- For none standard purposes please check:
- this generic Wrike PHP Library
- HTTP Client plugin based on guzzlehttp/guzzle package
- response transformer plugin based on jms/serializer package
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
Branch 'master'
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
Package general architecture inspired by mpclarkson/freshdesk-php-library
License
This bundle is available under the MIT license.