From f12e387103b0d710b3742db0660f829d78396916 Mon Sep 17 00:00:00 2001 From: Olly Warren Date: Mon, 22 May 2017 14:49:36 +0100 Subject: [PATCH 1/4] Added in support for Custom Fields Added in support for making a get request to retrieve all custom fields from a Workspace and also to get detials of a specific custom field --- src/Asana.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/Asana.php b/src/Asana.php index 62540e7..133de8b 100644 --- a/src/Asana.php +++ b/src/Asana.php @@ -620,4 +620,36 @@ public function getErrors() { return $this->curl->getErrors(); } + + /** + * getCustomFields + * + * Returns tall custom fields for a workspace + * + * @param $workspaceId + * + * @return null|string + * @author Olly Warren https://github.com/ollywarren + * @version 1.0 + */ + public function getCustomFields($workspaceId) + { + return $this->curl->get("workspaces/{$workspaceId}/custom_fields"); + } + + /** + * getCustomField + * + * Returns the full details on the custom field passed in. + * + * @param $fieldId + * + * @return null|string + * @author Olly Warren https://github.com/ollywarren + * @version 1.0 + */ + public function getCustomField($fieldId) + { + return $this->curl->get("custom_fields/{$fieldId}"); + } } From a56517bda21e92c0648b876e79c7ed930711f73e Mon Sep 17 00:00:00 2001 From: Olly Warren Date: Fri, 26 May 2017 14:50:35 +0100 Subject: [PATCH 2/4] Webhook impleentation Added in the ability to create, get and delete webhooks. --- src/Asana.php | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/src/Asana.php b/src/Asana.php index 133de8b..c1d4152 100644 --- a/src/Asana.php +++ b/src/Asana.php @@ -652,4 +652,69 @@ public function getCustomField($fieldId) { return $this->curl->get("custom_fields/{$fieldId}"); } + + /** + * createWebhook + * + * Creates a webhook with asana based + * Requires the resource to link with (Workspace, Project) + * and a Target URL for your API/Application. + * + * Note: Will send a handshake to your Application with a + * X-Security-Header that must be returned with a 200 + * Repsonse to verify the webhook creation. Asana may then + * follow up with a "heartbeat" request that will contain an + * empty "events" JSON object and a X-Signature-Header. + * + * @param $resourceId + * @param $targetUrl + * + * @return null|string + * @author Olly Warren https://github.com/ollywarren + * @version 1.0 + */ + public function createWebhook($resourceId, $targetUrl) + { + //Define the Data array to include in the request + $data = [ + 'data' => [ + 'resource' => $resourceId, + 'target' => $targetUrl + ] + ]; + + return $this->curl->post("webhooks", $data); + } + + /** + * getWebhook + * + * Gets the full details for a Webhook. + * + * @param $webhookId + * + * @return null|string + * @author Olly Warren https://github.com/ollywarren + * @version 1.0 + */ + public function getWebhook($webhookId) + { + return $this->curl->get("webhooks/{$webhookId}"); + } + + /** + * deleteWebhook + * + * Removes a webhook from Asana. + * + * @param $webhookId + * + * @return null|string + * @author Olly Warren https://github.com/ollywarren + * @version 1.0 + */ + public function deleteWebhook($webhookId) + { + return $this->curl->delete("webhooks/{$webhookId}"); + } } From 00553b1f31c04d1d1a130beafea3a303b2c4ec55 Mon Sep 17 00:00:00 2001 From: Olly Warren Date: Wed, 31 May 2017 14:59:11 +0100 Subject: [PATCH 3/4] Implemented getting a alist of webhooks for a given workspace --- src/Asana.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Asana.php b/src/Asana.php index c1d4152..9e00e22 100644 --- a/src/Asana.php +++ b/src/Asana.php @@ -662,7 +662,7 @@ public function getCustomField($fieldId) * * Note: Will send a handshake to your Application with a * X-Security-Header that must be returned with a 200 - * Repsonse to verify the webhook creation. Asana may then + * Response to verify the webhook creation. Asana may then * follow up with a "heartbeat" request that will contain an * empty "events" JSON object and a X-Signature-Header. * @@ -702,6 +702,24 @@ public function getWebhook($webhookId) return $this->curl->get("webhooks/{$webhookId}"); } + /** + * getWebhooks + * + * Gets all the webhooks for a workspace + * + * @param $workspaceId + * + * @return null|string + * @author Olly Warren https://github.com/ollywarren + * @version 1.0 + */ + public function getWebhooks($workspaceId) + { + return $this->curl->get("webhooks?workspace={$workspaceId}"); + } + + + /** * deleteWebhook * From 58aa5df1d762ef3b3c32a3fb9efce5d6058e4079 Mon Sep 17 00:00:00 2001 From: Olly Warren Date: Wed, 19 Jul 2017 14:31:17 +0100 Subject: [PATCH 4/4] File Attachment methods implemented --- src/Asana.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/Asana.php b/src/Asana.php index 9e00e22..1d9ef4f 100644 --- a/src/Asana.php +++ b/src/Asana.php @@ -172,6 +172,40 @@ public function addTaskAttachment($taskId, $file) ]); } + /** + * getAllAttachments + * + * Gets a List of all available Attachments. + * + * @param $taskId + * + * @return null|string + * @author Olly Warren, Big Bite Creative + * @package Torann\LaravelAsana + * @version 1.0 + */ + public function getAllAttachments($taskId) + { + return $this->curl->get("tasks/{$taskId}/attachments"); + } + + /** + * getSingleAttachment + * + * Gets a Single Attachment based on a file id. + * + * @param $attachmentId + * + * @return null|string + * @author Olly Warren, Big Bite Creative + * @package Torann\LaravelAsana + * @version 1.0 + */ + public function getSingleAttachment($attachmentId) + { + return $this->curl->get("attachments/{$attachmentId}"); + } + /** * Returns the projects associated to the task. *