Skip to content

Commit

Permalink
Added Task methods to Services_Capsule
Browse files Browse the repository at this point in the history
Services_Capsule was missing the Task methods of the CapsuleCRM API
These methods have been added with this patch, although they have not
been thoroghly debugged.

The magical getter functions in Services_Capsule and Services_Capsule_Common
have been updated to include Task cases

The following Files have been added:

 - Capsule/Task.php: includes functions for getting, listing, completing,
   re-opening, updating and deleting tasks

 - Capsule/Party/Task.php: includes functions for listing and adding
   tasks by party

 - Capsule/Opportunity/Task.php: includes function for listing and
   adding tasks by opportunity

 - Capsule/Kase/Task.php: includes funstions for listing and adding
   tasks by case

STILL NEED TO ADD:

 - function to add unattached tasks.  syntax seems wrong at
   @link  http://capsulecrm.com/help/page/api_task
  • Loading branch information
beckskis committed Jul 13, 2010
1 parent 2d759d9 commit d9b2ebb
Show file tree
Hide file tree
Showing 6 changed files with 576 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Services/Capsule.php
Expand Up @@ -99,6 +99,8 @@ public function __get($section)
case 'Kase':
case 'Resource':
case 'Person':
case 'Organization':
case 'Task':

if (!isset($this->sections[$section])) {
$classname = 'Services_Capsule_' .$section;
Expand Down
1 change: 1 addition & 0 deletions Services/Capsule/Common.php 100755 → 100644
Expand Up @@ -121,6 +121,7 @@ public function __get($section)
case 'Opportunity':
case 'Customfield':
case 'Milestone':
case 'Task':

$currentModule = ucfirst(strtolower($this->moduleName));

Expand Down
115 changes: 115 additions & 0 deletions Services/Capsule/Kase/Task.php
@@ -0,0 +1,115 @@
<?php
/**
* +-----------------------------------------------------------------------+
* | Copyright (c) 2010, David Coallier & echolibre ltd |
* | All rights reserved. |
* | |
* | Redistribution and use in source and binary forms, with or without |
* | modification, are permitted provided that the following conditions |
* | are met: |
* | |
* | o Redistributions of source code must retain the above copyright |
* | notice, this list of conditions and the following disclaimer. |
* | o Redistributions in binary form must reproduce the above copyright |
* | notice, this list of conditions and the following disclaimer in the |
* | documentation and/or other materials provided with the distribution.|
* | o The names of the authors may not be used to endorse or promote |
* | products derived from this software without specific prior written |
* | permission. |
* | |
* | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
* | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
* | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
* | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
* | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
* | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
* | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
* | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* | |
* +-----------------------------------------------------------------------+
* | Author: David Coallier <david@echolibre.com> |
* +-----------------------------------------------------------------------+
*
* PHP version 5
*
* @category Services
* @package Services_Capsule
* @author David Coallier <david@echolibre.com>
* @copyright echolibre ltd. 2009-2010
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @link http://github.com/davidcoallier/Services_Capsule
* @version GIT: $Id$
*/

/**
* Services_Capsule
*
* @category Services
* @package Services_Capsule
* @author David Coallier <david@echolibre.com>
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @link http://github.com/davidcoallier/Services_Capsule
* @link http://capsulecrm.com/help/page/javelin_api_opportunity
* @version Release: @package_version@
*/
class Services_Capsule_Kase_Task extends Services_Capsule_Common
{
/**
* Get case Tasks
*
* Retrieve a list of tasks for a case.
*
* @link /api/kase/{id}/tasks
* @throws Services_Capsule_RuntimeException
*
* @param double $kaseId The kase to retrieve the tasks from.
* @return stdClass A stdClass object containing the information from
* the json-decoded response from the server.
*/
public function getAll($kaseId)
{
$url = '/' . (double)$kaseId . '/tasks';
$response = $this->sendRequest($url);

return $this->parseResponse($response);
}

/**
* Add a task to a case
*
* Create a new task attached to a case
*
* Example of input:
*
* <?php
* $fields = array(
* 'description' => 'descrition of task',
* 'dueDateTime' => '2010-04-21T15:00:00Z',
* ...
* );
* ?>
*
* @link /api/kase/{kase-id}/task
* @throws Services_Capsule_RuntimeException
*
* @param double $kaseId The case to add the task to.
* @param array $fields An array of fields to create the task with.
*
* @return mixed bool|stdClass A stdClass object containing the information from
* the json-decoded response from the server.
*/
public function add($kaseId, $fields)
{
$url = '/' . (double)$kaseId . '/task';
$task = array('task' => $fields);

$response = $this->sendRequest(
$url, HTTP_Request2::METHOD_POST, json_encode($task)
);

return $this->parseResponse($response);
}
}
115 changes: 115 additions & 0 deletions Services/Capsule/Opportunity/Task.php
@@ -0,0 +1,115 @@
<?php
/**
* +-----------------------------------------------------------------------+
* | Copyright (c) 2010, David Coallier & echolibre ltd |
* | All rights reserved. |
* | |
* | Redistribution and use in source and binary forms, with or without |
* | modification, are permitted provided that the following conditions |
* | are met: |
* | |
* | o Redistributions of source code must retain the above copyright |
* | notice, this list of conditions and the following disclaimer. |
* | o Redistributions in binary form must reproduce the above copyright |
* | notice, this list of conditions and the following disclaimer in the |
* | documentation and/or other materials provided with the distribution.|
* | o The names of the authors may not be used to endorse or promote |
* | products derived from this software without specific prior written |
* | permission. |
* | |
* | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
* | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
* | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
* | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
* | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
* | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
* | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
* | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* | |
* +-----------------------------------------------------------------------+
* | Author: David Coallier <david@echolibre.com> |
* +-----------------------------------------------------------------------+
*
* PHP version 5
*
* @category Services
* @package Services_Capsule
* @author David Coallier <david@echolibre.com>
* @copyright echolibre ltd. 2009-2010
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @link http://github.com/davidcoallier/Services_Capsule
* @version GIT: $Id$
*/

/**
* Services_Capsule
*
* @category Services
* @package Services_Capsule
* @author David Coallier <david@echolibre.com>
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @link http://github.com/davidcoallier/Services_Capsule
* @link http://capsulecrm.com/help/page/javelin_api_opportunity
* @version Release: @package_version@
*/
class Services_Capsule_Opportunity_Task extends Services_Capsule_Common
{
/**
* Get opportunity Tasks
*
* Retrieve a list of tasks for an opportunity.
*
* @link /api/opportunity/{id}/tasks
* @throws Services_Capsule_RuntimeException
*
* @param double $opportunityId The opportunity to retrieve the tasks from.
* @return stdClass A stdClass object containing the information from
* the json-decoded response from the server.
*/
public function getAll($opportunityId)
{
$url = '/' . (double)$opportunityId . '/tasks';
$response = $this->sendRequest($url);

return $this->parseResponse($response);
}

/**
* Add a task to an opportunity
*
* Create a new task attached to an opportunity
*
* Example of input:
*
* <?php
* $fields = array(
* 'description' => 'descrition of task',
* 'dueDateTime' => '2010-04-21T15:00:00Z',
* ...
* );
* ?>
*
* @link /api/opportunity/{opportunity-id}/task
* @throws Services_Capsule_RuntimeException
*
* @param double $opportunityId The oppID to add the task to.
* @param array $fields An array of fields to create the task with.
*
* @return mixed bool|stdClass A stdClass object containing the information from
* the json-decoded response from the server.
*/
public function add($opportnuityId, $fields)
{
$url = '/' . (double)$opportunityId . '/task';
$task = array('task' => $fields);

$response = $this->sendRequest(
$url, HTTP_Request2::METHOD_POST, json_encode($task)
);

return $this->parseResponse($response);
}
}
117 changes: 117 additions & 0 deletions Services/Capsule/Party/Task.php
@@ -0,0 +1,117 @@
<?php
/**
* +-----------------------------------------------------------------------+
* | Copyright (c) 2010, David Coallier & echolibre ltd |
* | All rights reserved. |
* | |
* | Redistribution and use in source and binary forms, with or without |
* | modification, are permitted provided that the following conditions |
* | are met: |
* | |
* | o Redistributions of source code must retain the above copyright |
* | notice, this list of conditions and the following disclaimer. |
* | o Redistributions in binary form must reproduce the above copyright |
* | notice, this list of conditions and the following disclaimer in the |
* | documentation and/or other materials provided with the distribution.|
* | o The names of the authors may not be used to endorse or promote |
* | products derived from this software without specific prior written |
* | permission. |
* | |
* | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
* | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
* | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
* | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
* | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
* | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
* | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
* | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* | |
* +-----------------------------------------------------------------------+
* | Author: David Coallier <david@echolibre.com> |
* +-----------------------------------------------------------------------+
*
* PHP version 5
*
* @category Services
* @package Services_Capsule
* @author David Coallier <david@echolibre.com>
* @copyright echolibre ltd. 2009-2010
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @link http://github.com/davidcoallier/Services_Capsule
* @version GIT: $Id$
*/

/**
* Services_Capsule
*
* @category Services
* @package Services_Capsule
* @author David Coallier <david@echolibre.com>
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
* @link http://github.com/davidcoallier/Services_Capsule
* @link http://capsulecrm.com/help/page/javelin_api_party
* @version Release: @package_version@
*/
class Services_Capsule_Party_Task extends Services_Capsule_Common
{

/**
* Get a list of party tasks
*
* This method returns a list of tasks associated
* to a particular party.
*
* @link /api/party/{party-id}/tasks
* @throws Services_Capsule_RuntimeException
*
* @param double $partyId The party to retrieve the tasks from.
* @return stdClass A stdClass object containing the information from
* the json-decoded response from the server.
*/
public function getAll($partyId)
{
$url = '/' . (double)$partyId . '/tasks';
$response = $this->sendRequest($url);

return $this->parseResponse($response);
}

/**
* Add a task to a party
*
* Create a new task attached to this person or organisation
*
* Example of input:
*
* <?php
* $fields = array(
* 'description' => 'descrition of task',
* 'dueDateTime' => '2010-04-21T15:00:00Z',
* ...
* );
* ?>
*
* @link /api/party/{party-id}/task
* @throws Services_Capsule_RuntimeException
*
* @param double $partyId The party/org to add the task to.
* @param array $fields An array of fields to create the opp with.
*
* @return mixed bool|stdClass A stdClass object containing the information from
* the json-decoded response from the server.
*/
public function add($partyId, $fields)
{
$url = '/' . (double)$partyId . '/task';
$task = array('task' => $fields);

$response = $this->sendRequest(
$url, HTTP_Request2::METHOD_POST, json_encode($task)
);

return $this->parseResponse($response);
}
}

0 comments on commit d9b2ebb

Please sign in to comment.