PHP Класс Asana

Read Asana API documentation for fully use this class http://developer.asana.com/documentation/ Copyright 2012 Ajimix Licensed under the Apache License 2.0 Author: Ajimix [github.com/ajimix] Version: 1.0
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$advDebug
$debug
$fastAPI
$responseCode
$timeout Use Asana fast API version, currently in open beta: https://asana.com/developers/feed/asana-fast-api-open-beta

Открытые методы

Метод Описание
__construct ( array $options ) Class constructor.
addAttachmentToTask ( string $taskId, array $data = [] ) : string Add attachment to a task
addFollowersToTask ( string $taskId, array $followerIds ) : string Adds followers to a task
addProjectToTask ( string $taskId, string $projectId, array $opts = [] ) : string Adds a project to task. If successful, will return success and an empty data block.
addTagToTask ( string $taskId, string $tagId ) : string Adds a tag to a task. If successful, will return success and an empty data block.
commentOnProject ( string $projectId, string $text = '' ) : string Adds a comment to a project The comment will be authored by the authorized user, and timestamped when the server receives the request.
commentOnTask ( string $taskId, string $text = '' ) : string Adds a comment to a task.
createProject ( array $data ) : string Function to create a project.
createSubTask ( string $parentId, array $data, array $opts = [] ) : string Creates a subtask in the parent task ID
createTag ( string $name, array $data, array $opts = [] ) : string This method creates a new tag and returns its full record.
createTask ( array $data, array $opts = [] ) : string Creates a task.
createTeam ( string $organizationId, array $data ) : string Function to create a team in an Organization.
createWebhook ( string $resourceId, string $target ) : string Creates a webhook.
deleteProject ( string $projectId ) : string Deletes a project.
deleteTask ( string $taskId ) : string Deletes a task.
deleteWebhook ( string $webhookId ) : string This method permanently removes a webhook.
getAttachment ( string $attachmentId, array $opts = [] ) : string Returns single attachment information
getData ( ) : object, Decodes the response and returns as an object, array.
getMyTeams ( string $organizationId ) : string Returns all teams the logged in user is associated with
getProject ( string $projectId, array $opts = [] ) : string Returns the full record for a single project.
getProjectSections ( string $projectId, array $opts = [] ) : string Returns the list of sections associated with the project.
getProjectStories ( string $projectId, array $opts = [] ) : string Returns the list of stories associated with the project.
getProjectTasks ( string $projectId, array $opts = [] ) : string Returns all unarchived tasks of a given project
getProjects ( boolean $archived = false, string $opt_fields = '' ) Returns the projects in all workspaces containing archived ones or not.
getProjectsForTask ( string $taskId, array $opts = [] ) : string Returns the projects associated to the task.
getProjectsInTeam ( string $teamId, boolean $archived = false, array $opts = [] ) : string Returns the projects in provided workspace containing archived ones or not.
getProjectsInWorkspace ( string $workspaceId, boolean $archived = false, array $opts = [] ) : string Returns the projects in provided workspace containing archived ones or not.
getSingleStory ( string $storyId, array $opts = [] ) : string Returns the full record for a single story.
getSubTasks ( string $taskId, array $opts = [] ) : string Returns sub-task information
getTag ( string $tagId, array $opts = [] ) : string Returns the full record for a single tag.
getTags ( ) : string Returns the full record for all tags in all workspaces.
getTask ( string $taskId, array $opts = [] ) : string Returns task information
getTaskAttachments ( string $taskId, array $opts = [] ) : string Returns task attachments information
getTaskStories ( string $taskId, array $opts = [] ) : string Returns the list of stories associated with the object.
getTaskTags ( string $taskId, array $opts = [] ) : string Returns a compact list of tags associated with the object.
getTasksByFilter ( array $filter = ['assignee' => '', 'project' => '', 'workspace' => ''], array $opts = [] ) : string Returns task by a given filter.
getTasksWithTag ( string $tagId, array $opts = [] ) : string Returns the list of all tasks with this tag. Tasks can have more than one tag at a time.
getTeamsInOrganization ( string $organizationId ) : string Returns all teams in an Organization.
getUserInfo ( string $userId = null, array $opts = [] ) : string Returns the full user record for a single user.
getUsers ( array $opts = [] ) : string Returns the user records for all users in all workspaces you have access.
getWebhook ( string $webhookId ) : string Returns the full record for the given webhook.
getWebhooks ( string $workspaceId, string $resource = null, array $opts = [] ) : string Returns the compact representation of all webhooks your app has registered for the authenticated user in the given workspace.
getWorkspaceTags ( string $workspaceId ) : string Returns tags of all workspace.
getWorkspaceTasks ( string $workspaceId, string $assignee = 'me', array $opts = [] ) : string Returns tasks of all workspace assigned to someone.
getWorkspaceTypeahead ( string $workspaceId, string $type, string $query, string $count = 1, array $opts = [] ) : string Returns search for objects from a single workspace.
getWorkspaceUsers ( string $workspaceId ) : string Returns users of all workspace.
getWorkspaces ( array $opts = [] ) : string Returns all the workspaces.
hasError ( ) : boolean Checks for errors in the response.
moveTaskWithinProject ( string $projectId, string $taskToMove, string $taskReference, boolean $insertAfter = true ) : string Moves a task within a project relative to another task. This should let you take a task and move it below or above another task as long as they are within the same project.
removeFollowersFromTask ( string $taskId, array $followerIds ) : string Removes followers from a task
removeProjectToTask ( string $taskId, string $projectId ) : string Removes project from task. If successful, will return success and an empty data block.
removeTagFromTask ( string $taskId, string $tagId ) : string Removes a tag from a task. If successful, will return success and an empty data block.
setReturnType ( integer $type ) : Asana Set the return type.
updateProject ( string $projectId, array $data ) : string This method modifies the fields of a project provided in the request, then returns the full updated record.
updateTag ( string $tagId, array $data ) : string Modifies the fields of a tag provided in the request, then returns the full updated record.
updateTask ( string $taskId, array $data ) : string Updates a task
updateTaskParent ( string $taskId, string $parentId, array $opts = [] ) : string Updated the parent from a task.
updateWorkspace ( $workspaceId, array $data = ['name' => ''] ) : string Currently the only field that can be modified for a workspace is its name (as Asana API says).

Приватные методы

Метод Описание
askAsana ( string $url, string $data = null, integer $method = ASANA_METHOD_GET ) : string This function communicates with Asana REST API.

Описание методов

__construct() публичный Метод

Class constructor.
public __construct ( array $options )
$options array Array of options containing an apiKey OR a personalAccessToken OR an accessToken. Just one of them. Can be also an string if you want to use an apiKey.

addAttachmentToTask() публичный Метод

Add attachment to a task
public addAttachmentToTask ( string $taskId, array $data = [] ) : string
$taskId string
$data array (src of file, mymetype, finalFilename) See, Uploading an attachment to a task function comments for proper parameter info.
Результат string JSON or null

addFollowersToTask() публичный Метод

Adds followers to a task
public addFollowersToTask ( string $taskId, array $followerIds ) : string
$taskId string
$followerIds array Array of follower ids
Результат string JSON or null

addProjectToTask() публичный Метод

Adds a project to task. If successful, will return success and an empty data block.
public addProjectToTask ( string $taskId, string $projectId, array $opts = [] ) : string
$taskId string
$projectId string
$opts array Array of options to pass (insert_after, insert_before, section) (@see https://asana.com/developers/api-reference/tasks#projects)
Результат string JSON or null

addTagToTask() публичный Метод

Adds a tag to a task. If successful, will return success and an empty data block.
public addTagToTask ( string $taskId, string $tagId ) : string
$taskId string
$tagId string
Результат string JSON or null

commentOnProject() публичный Метод

Adds a comment to a project The comment will be authored by the authorized user, and timestamped when the server receives the request.
public commentOnProject ( string $projectId, string $text = '' ) : string
$projectId string
$text string
Результат string JSON or null

commentOnTask() публичный Метод

The comment will be authored by the authorized user, and timestamped when the server receives the request.
public commentOnTask ( string $taskId, string $text = '' ) : string
$taskId string
$text string
Результат string JSON or null

createProject() публичный Метод

Function to create a project.
public createProject ( array $data ) : string
$data array Array of data for the project following the Asana API documentation. Example: array( "workspace" => "1768", "name" => "Foo Project!", "notes" => "This is a test project" )
Результат string JSON or null

createSubTask() публичный Метод

Creates a subtask in the parent task ID
public createSubTask ( string $parentId, array $data, array $opts = [] ) : string
$parentId string The id of the parent task.
$data array Array of data for the task following the Asana API documentation. Example: array( "name" => "Hello World!", "notes" => "This is a task for testing the Asana API :)", "assignee" => "176822166183", "followers" => array( "37136", "59083" ) )
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

createTag() публичный Метод

This method creates a new tag and returns its full record.
public createTag ( string $name, array $data, array $opts = [] ) : string
$name string Tag name
$data array An array containing either workspace or organization and the id. Example: array("workspace" => "3242349871");
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

createTask() публичный Метод

For assign or remove the task to a project, use the addProjectToTask and removeProjectToTask.
public createTask ( array $data, array $opts = [] ) : string
$data array Array of data for the task following the Asana API documentation. Example: array( "workspace" => "1768", "name" => "Hello World!", "notes" => "This is a task for testing the Asana API :)", "assignee" => "176822166183", "followers" => array( "37136", "59083" ) )
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

createTeam() публичный Метод

Function to create a team in an Organization.
public createTeam ( string $organizationId, array $data ) : string
$organizationId string
$data array Array of data for the task following the Asana API documentation. Example: array("name" => "Team Name")
Результат string JSON or null

createWebhook() публичный Метод

Creates a webhook.
public createWebhook ( string $resourceId, string $target ) : string
$resourceId string A resource ID to subscribe to. The resource can be a task or project.
$target string The URL to receive the HTTP POST.
Результат string JSON or null

deleteProject() публичный Метод

Deletes a project.
public deleteProject ( string $projectId ) : string
$projectId string
Результат string Empty if success

deleteTask() публичный Метод

Deletes a task.
public deleteTask ( string $taskId ) : string
$taskId string
Результат string Empty if success

deleteWebhook() публичный Метод

This method permanently removes a webhook.
public deleteWebhook ( string $webhookId ) : string
$webhookId string The webhook to delete.
Результат string JSON or null

getAttachment() публичный Метод

Returns single attachment information
public getAttachment ( string $attachmentId, array $opts = [] ) : string
$attachmentId string
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getData() публичный Метод

Decodes the response and returns as an object, array.
public getData ( ) : object,
Результат object,

getMyTeams() публичный Метод

Returns all teams the logged in user is associated with
public getMyTeams ( string $organizationId ) : string
$organizationId string
Результат string JSON or null

getProject() публичный Метод

Returns the full record for a single project.
public getProject ( string $projectId, array $opts = [] ) : string
$projectId string
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getProjectSections() публичный Метод

Sections are tasks whose names end with a colon character : . For instance sections will be included in query results for tasks and be represented with the same fields. The memberships property of a task contains the project/section pairs a task belongs to when applicable.
public getProjectSections ( string $projectId, array $opts = [] ) : string
$projectId string
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getProjectStories() публичный Метод

As usual with queries, stories are returned in compact form. However, the compact form for stories contains more information by default than just the ID. There is presently no way to get a filtered set of stories.
public getProjectStories ( string $projectId, array $opts = [] ) : string
$projectId string
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getProjectTasks() публичный Метод

Returns all unarchived tasks of a given project
public getProjectTasks ( string $projectId, array $opts = [] ) : string
$projectId string
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getProjects() публичный Метод

Returns the projects in all workspaces containing archived ones or not.
public getProjects ( boolean $archived = false, string $opt_fields = '' )
$archived boolean Return archived projects or not
$opt_fields string Return results with optional parameters

getProjectsForTask() публичный Метод

Returns the projects associated to the task.
public getProjectsForTask ( string $taskId, array $opts = [] ) : string
$taskId string
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getProjectsInTeam() публичный Метод

Returns the projects in provided workspace containing archived ones or not.
public getProjectsInTeam ( string $teamId, boolean $archived = false, array $opts = [] ) : string
$teamId string
$archived boolean Return archived projects or not
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getProjectsInWorkspace() публичный Метод

Returns the projects in provided workspace containing archived ones or not.
public getProjectsInWorkspace ( string $workspaceId, boolean $archived = false, array $opts = [] ) : string
$workspaceId string
$archived boolean Return archived projects or not
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getSingleStory() публичный Метод

Returns the full record for a single story.
public getSingleStory ( string $storyId, array $opts = [] ) : string
$storyId string
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getSubTasks() публичный Метод

Returns sub-task information
public getSubTasks ( string $taskId, array $opts = [] ) : string
$taskId string
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getTag() публичный Метод

Returns the full record for a single tag.
public getTag ( string $tagId, array $opts = [] ) : string
$tagId string
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getTags() публичный Метод

Returns the full record for all tags in all workspaces.
public getTags ( ) : string
Результат string JSON or null

getTask() публичный Метод

Returns task information
public getTask ( string $taskId, array $opts = [] ) : string
$taskId string
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getTaskAttachments() публичный Метод

Returns task attachments information
public getTaskAttachments ( string $taskId, array $opts = [] ) : string
$taskId string
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getTaskStories() публичный Метод

As usual with queries, stories are returned in compact form. However, the compact form for stories contains more information by default than just the ID. There is presently no way to get a filtered set of stories.
public getTaskStories ( string $taskId, array $opts = [] ) : string
$taskId string
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getTaskTags() публичный Метод

Returns a compact list of tags associated with the object.
public getTaskTags ( string $taskId, array $opts = [] ) : string
$taskId string
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getTasksByFilter() публичный Метод

For now (limited by Asana API), you may limit your query either to a specific project or to an assignee and workspace NOTE: As Asana API says, if you filter by assignee, you MUST specify a workspaceId and viceversa.
public getTasksByFilter ( array $filter = ['assignee' => '', 'project' => '', 'workspace' => ''], array $opts = [] ) : string
$filter array The filter with optional values. array( "assignee" => "", "project" => 0, "workspace" => 0 )
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getTasksWithTag() публичный Метод

Returns the list of all tasks with this tag. Tasks can have more than one tag at a time.
public getTasksWithTag ( string $tagId, array $opts = [] ) : string
$tagId string
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getTeamsInOrganization() публичный Метод

Returns all teams in an Organization.
public getTeamsInOrganization ( string $organizationId ) : string
$organizationId string
Результат string JSON or null

getUserInfo() публичный Метод

Call it without parameters to get the users info of the owner of the API key.
public getUserInfo ( string $userId = null, array $opts = [] ) : string
$userId string
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getUsers() публичный Метод

Returns the user records for all users in all workspaces you have access.
public getUsers ( array $opts = [] ) : string
$opts array Array of options to pass to the API (@see https://asana.com/developers/api-reference/users) Example: Returning additional fields with 'opt_fields' getUsers(['opt_fields' => 'name,email,photo,workspaces'])
Результат string JSON or null

getWebhook() публичный Метод

Returns the full record for the given webhook.
public getWebhook ( string $webhookId ) : string
$webhookId string The webhook to get.
Результат string JSON or null

getWebhooks() публичный Метод

Returns the compact representation of all webhooks your app has registered for the authenticated user in the given workspace.
public getWebhooks ( string $workspaceId, string $resource = null, array $opts = [] ) : string
$workspaceId string The workspace to query for webhooks in.
$resource string Optional: Only return webhooks for the given resource.
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getWorkspaceTags() публичный Метод

Returns tags of all workspace.
public getWorkspaceTags ( string $workspaceId ) : string
$workspaceId string The id of the workspace
Результат string JSON or null

getWorkspaceTasks() публичный Метод

Note: As Asana API says, you must specify an assignee when querying for workspace tasks.
public getWorkspaceTasks ( string $workspaceId, string $assignee = 'me', array $opts = [] ) : string
$workspaceId string The id of the workspace
$assignee string Can be "me" or user ID
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getWorkspaceTypeahead() публичный Метод

Returns search for objects from a single workspace.
public getWorkspaceTypeahead ( string $workspaceId, string $type, string $query, string $count = 1, array $opts = [] ) : string
$workspaceId string The id of the workspace
$type string The type of object to look up. You can choose from one of the following: project, user, task, and tag. Note that unlike other endpoints, the types listed here are in singular form. Using multiple types is not yet supported.
$query string The value to look up
$count string The number of results to return with a minimum of 1 and a maximum of 100. The default is 1 if this parameter is omitted. If there are fewer results found than requested, all will be returned
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

getWorkspaceUsers() публичный Метод

Returns users of all workspace.
public getWorkspaceUsers ( string $workspaceId ) : string
$workspaceId string The id of the workspace
Результат string JSON or null

getWorkspaces() публичный Метод

Returns all the workspaces.
public getWorkspaces ( array $opts = [] ) : string
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

hasError() публичный Метод

Checks for errors in the response.
public hasError ( ) : boolean
Результат boolean

moveTaskWithinProject() публичный Метод

Moves a task within a project relative to another task. This should let you take a task and move it below or above another task as long as they are within the same project.
public moveTaskWithinProject ( string $projectId, string $taskToMove, string $taskReference, boolean $insertAfter = true ) : string
$projectId string the project $taskReference is in and optionally $taskToMove is already in ($taskToMove will be added to the project if it's not already there)
$taskToMove string the task that will be moved (and possibly added to $projectId
$taskReference string the task that indicates a position for $taskToMove
$insertAfter boolean true to insert after $taskReference, false to insert before
Результат string JSON or null

removeFollowersFromTask() публичный Метод

Removes followers from a task
public removeFollowersFromTask ( string $taskId, array $followerIds ) : string
$taskId string
$followerIds array Array of follower ids
Результат string JSON or null

removeProjectToTask() публичный Метод

Removes project from task. If successful, will return success and an empty data block.
public removeProjectToTask ( string $taskId, string $projectId ) : string
$taskId string
$projectId string
Результат string JSON or null

removeTagFromTask() публичный Метод

Removes a tag from a task. If successful, will return success and an empty data block.
public removeTagFromTask ( string $taskId, string $tagId ) : string
$taskId string
$tagId string
Результат string JSON or null

setReturnType() публичный Метод

Set the return type.
public setReturnType ( integer $type ) : Asana
$type integer Return type defined in the constants.
Результат Asana

updateProject() публичный Метод

This method modifies the fields of a project provided in the request, then returns the full updated record.
public updateProject ( string $projectId, array $data ) : string
$projectId string
$data array An array containing fields to update, see Asana API if needed. Example: array("name" => "Test", "notes" => "It's a test project");
Результат string JSON or null

updateTag() публичный Метод

Modifies the fields of a tag provided in the request, then returns the full updated record.
public updateTag ( string $tagId, array $data ) : string
$tagId string
$data array An array containing fields to update, see Asana API if needed. Example: array("name" => "Test", "notes" => "It's a test tag");
Результат string JSON or null

updateTask() публичный Метод

Updates a task
public updateTask ( string $taskId, array $data ) : string
$taskId string
$data array See, createTask function comments for proper parameter info.
Результат string JSON or null

updateTaskParent() публичный Метод

Updated the parent from a task.
public updateTaskParent ( string $taskId, string $parentId, array $opts = [] ) : string
$taskId string The task to update
$parentId string The id of the new parent task.
$opts array Array of options to pass (@see https://asana.com/developers/documentation/getting-started/input-output-options)
Результат string JSON or null

updateWorkspace() публичный Метод

This method returns the complete updated workspace record.
public updateWorkspace ( $workspaceId, array $data = ['name' => ''] ) : string
$data array Example: array("name" => "Test");
Результат string JSON or null

Описание свойств

$advDebug публичное свойство

public $advDebug

$debug публичное свойство

public $debug

$fastAPI публичное свойство

public $fastAPI

$responseCode публичное свойство

public $responseCode

$timeout публичное свойство

Use Asana fast API version, currently in open beta: https://asana.com/developers/feed/asana-fast-api-open-beta
public $timeout