2

I am integrating Active Colab with my Magento site. I have successfully created a new task using API but I want to complete this task using API.

So what I want to do is if I complete the task in Active Collab that task automatically be completed on my website (all task list is shown on my site too.) And if I complete a task from my site it will be completed in Active Collab.

Above functionality, I want to implement using Active Collab API.

So if there is anyone who can help me to solve this problem thank you in advance.

if($status == 1){$complete = false;} /*open status*/
if($status == 3){$complete = true;}  /*closed status*/

try {
    $res = API::call('projects/60/tasks/176/put', null, array(
    'task[is_completed]' => $_POST['is_completed'], /*$complete used here*/         
    ));
    //$GLOBALS['$myValue'] = $res['permalink']; 
    //echo $GLOBALS['$myValue'];
    echo 'Ticket Updated Successfully.';  
    
    
} catch(AppException $e) {
  print $e->getMessage() . '<br><br>';
  // var_dump($e->getServerResponse()); (need more info?)
} // try 

I have changed some code for the update task as a complete that is below so please check and let me know if there is any wrong code.

try {
    $res = API::call('projects/60/tasks/176/put', null, array(
    'task[is_on]' => 1,     
    ));
    echo 'Ticket Updated Successfully.';        
} catch(AppException $e) {
  print $e->getMessage() . '<br><br>';
}
s.abbaasi
  • 952
  • 6
  • 14
Dhaval
  • 1,393
  • 5
  • 29
  • 55
  • I'm voting to close this question as off-topic because Stack Overflow is a [programming-related](http://stackoverflow.com/help/on-topic) Q&A site. Your question is not about programming. Perhaps you should post it on http://magento.stackexchange.com instead? – Enigmativity Apr 28 '16 at 01:16
  • 1
    Tasks are completed by sending `PUT` request to `/api/v1/complete/task/:task_id`. Figuring out how to trigger it when someone completes a task in your website is something that someone else will need to help you out with (I'm Active Collab dev, but don't have any experience with Magento). – Ilija Apr 28 '16 at 07:45
  • @llija Thanks for your comment. I think I need to do it myself. – Dhaval Apr 28 '16 at 10:05
  • @llija I have edited my post and add code for complete task.Can you check and let me know does it right or not? – Dhaval Apr 28 '16 at 10:08
  • Are you using Active Collab 4 or Active Collab 5? They have different API-s. – Ilija Apr 28 '16 at 12:43
  • @llija I am using version 4. – Dhaval Apr 28 '16 at 12:49
  • @llija I have changed and edit post so please check last code for update task as completed and let me know does it wrong because it's not working – Dhaval Apr 28 '16 at 13:51

1 Answers1

1

To complete a task in Active Collab 4 via API, you need to send POST request to /projects/:project_id/tasks/:task_id/complete route. Your example uses Active Collab PHP SDK, so here's an example:

API::call('projects/60/tasks/176/complete', null, [
    'submitted' => 'submitted',
]);

Documentation about complete command can be found here:

https://help-classic.activecollab.com/books/api/complete.html

More info about task routes and task context is available here:

https://help-classic.activecollab.com/books/api/tasks.html

Ilija
  • 4,105
  • 4
  • 32
  • 46
  • @llija Thanks brother for this answer. Now I am able to apply my code. – Dhaval Apr 29 '16 at 06:08
  • @llija If I close task in Active Collab and it should close in my website(all task is also shown in my website with status) too.For this functionality what I need to do? – Dhaval Apr 29 '16 at 06:38
  • 1
    In Active Collab 5, you would create a webhook and handle it somewhere. Active Collab 4 does not have a webhook, so you can poll data periodically to see if there are any recently completed tasks, or develop a module that fires an event when that happens: https://help-classic.activecollab.com/books/developing-activecollab-module/index.html – Ilija Apr 29 '16 at 10:38