Skip to content

Commit d4ba549

Browse files
authored
Merge pull request #10 from ollywarren/master
Added in support for Custom Fields
2 parents 2867799 + 58aa5df commit d4ba549

File tree

1 file changed

+149
-0
lines changed

1 file changed

+149
-0
lines changed

src/Asana.php

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,40 @@ public function addTaskAttachment($taskId, $file)
173173
]);
174174
}
175175

176+
/**
177+
* getAllAttachments
178+
*
179+
* Gets a List of all available Attachments.
180+
*
181+
* @param $taskId
182+
*
183+
* @return null|string
184+
* @author Olly Warren, Big Bite Creative
185+
* @package Torann\LaravelAsana
186+
* @version 1.0
187+
*/
188+
public function getAllAttachments($taskId)
189+
{
190+
return $this->curl->get("tasks/{$taskId}/attachments");
191+
}
192+
193+
/**
194+
* getSingleAttachment
195+
*
196+
* Gets a Single Attachment based on a file id.
197+
*
198+
* @param $attachmentId
199+
*
200+
* @return null|string
201+
* @author Olly Warren, Big Bite Creative
202+
* @package Torann\LaravelAsana
203+
* @version 1.0
204+
*/
205+
public function getSingleAttachment($attachmentId)
206+
{
207+
return $this->curl->get("attachments/{$attachmentId}");
208+
}
209+
176210
/**
177211
* Returns the projects associated to the task.
178212
*
@@ -621,4 +655,119 @@ public function getErrors()
621655
{
622656
return $this->curl->getErrors();
623657
}
658+
659+
/**
660+
* getCustomFields
661+
*
662+
* Returns tall custom fields for a workspace
663+
*
664+
* @param $workspaceId
665+
*
666+
* @return null|string
667+
* @author Olly Warren https://github.com/ollywarren
668+
* @version 1.0
669+
*/
670+
public function getCustomFields($workspaceId)
671+
{
672+
return $this->curl->get("workspaces/{$workspaceId}/custom_fields");
673+
}
674+
675+
/**
676+
* getCustomField
677+
*
678+
* Returns the full details on the custom field passed in.
679+
*
680+
* @param $fieldId
681+
*
682+
* @return null|string
683+
* @author Olly Warren https://github.com/ollywarren
684+
* @version 1.0
685+
*/
686+
public function getCustomField($fieldId)
687+
{
688+
return $this->curl->get("custom_fields/{$fieldId}");
689+
}
690+
691+
/**
692+
* createWebhook
693+
*
694+
* Creates a webhook with asana based
695+
* Requires the resource to link with (Workspace, Project)
696+
* and a Target URL for your API/Application.
697+
*
698+
* Note: Will send a handshake to your Application with a
699+
* X-Security-Header that must be returned with a 200
700+
* Response to verify the webhook creation. Asana may then
701+
* follow up with a "heartbeat" request that will contain an
702+
* empty "events" JSON object and a X-Signature-Header.
703+
*
704+
* @param $resourceId
705+
* @param $targetUrl
706+
*
707+
* @return null|string
708+
* @author Olly Warren https://github.com/ollywarren
709+
* @version 1.0
710+
*/
711+
public function createWebhook($resourceId, $targetUrl)
712+
{
713+
//Define the Data array to include in the request
714+
$data = [
715+
'data' => [
716+
'resource' => $resourceId,
717+
'target' => $targetUrl
718+
]
719+
];
720+
721+
return $this->curl->post("webhooks", $data);
722+
}
723+
724+
/**
725+
* getWebhook
726+
*
727+
* Gets the full details for a Webhook.
728+
*
729+
* @param $webhookId
730+
*
731+
* @return null|string
732+
* @author Olly Warren https://github.com/ollywarren
733+
* @version 1.0
734+
*/
735+
public function getWebhook($webhookId)
736+
{
737+
return $this->curl->get("webhooks/{$webhookId}");
738+
}
739+
740+
/**
741+
* getWebhooks
742+
*
743+
* Gets all the webhooks for a workspace
744+
*
745+
* @param $workspaceId
746+
*
747+
* @return null|string
748+
* @author Olly Warren https://github.com/ollywarren
749+
* @version 1.0
750+
*/
751+
public function getWebhooks($workspaceId)
752+
{
753+
return $this->curl->get("webhooks?workspace={$workspaceId}");
754+
}
755+
756+
757+
758+
/**
759+
* deleteWebhook
760+
*
761+
* Removes a webhook from Asana.
762+
*
763+
* @param $webhookId
764+
*
765+
* @return null|string
766+
* @author Olly Warren https://github.com/ollywarren
767+
* @version 1.0
768+
*/
769+
public function deleteWebhook($webhookId)
770+
{
771+
return $this->curl->delete("webhooks/{$webhookId}");
772+
}
624773
}

0 commit comments

Comments
 (0)