From ab68606aee5293ebb9c7d3ef746130141eed0e56 Mon Sep 17 00:00:00 2001 From: Sebastian Hopfe Date: Sun, 3 Nov 2013 02:01:31 +0100 Subject: [PATCH 1/6] PHP Shorttags entfernt --- Basecamp.class.php | 2 +- Basecamp/Attachment.php | 3 ++- Basecamp/Object.php | 3 ++- Basecamp/Person.php | 3 ++- Basecamp/Project.php | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Basecamp.class.php b/Basecamp.class.php index 2ec8f32..b5586b9 100644 --- a/Basecamp.class.php +++ b/Basecamp.class.php @@ -1,4 +1,4 @@ - Date: Thu, 3 Apr 2014 20:11:12 -0500 Subject: [PATCH 2/6] Add 403 check. Cleanup debug --- Basecamp.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Basecamp.class.php b/Basecamp.class.php index b5586b9..2fea352 100644 --- a/Basecamp.class.php +++ b/Basecamp.class.php @@ -621,12 +621,15 @@ function _makeAuthenticatedRequest($resource,$params=array(),$method='GET',$head if ( $http_code == 401 ) { $response = json_encode(array('error_code'=>401,'error'=>'Unauthorized Access')); - } + } elseif ( $http_code == 403 ) { + $response = json_encode(array('error_code'=>403,'error'=>'Forbidden')); + } if ( $this->debug ) { print_r(curl_getinfo($ch)); - print $header; - print $response; + print "Header: $header\n"; + print "Params: ".print_r($params,1); + print "Response: $response\n"; } if ( $returnRawResponse ) return $response; From 38016c34a8ee14bc5c43f01424f979e7dd638cb7 Mon Sep 17 00:00:00 2001 From: "Aaron J. Rubin" Date: Thu, 3 Apr 2014 20:12:21 -0500 Subject: [PATCH 3/6] Add new star api calls to main class and project --- Basecamp.class.php | 14 ++++++++++++++ Basecamp/Project.php | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/Basecamp.class.php b/Basecamp.class.php index 2fea352..90934f7 100644 --- a/Basecamp.class.php +++ b/Basecamp.class.php @@ -537,8 +537,22 @@ function updateMilestone($source,$sourceid,$id,$summary='',$description='',$star function deleteMilestone($source,$sourceid,$id) { return $this->_makeAuthenticatedRequest($this->getAccountURL("$source/$sourceid/calendar_events/$id.json"),null,'DELETE'); + } + + //- mark Stars + + function getStars() { + return $this->_makeAuthenticatedRequest($this->getAccountURL('stars.json')); } + function starProject($projectid) { + return $this->_makeAuthenticatedRequest($this->getAccountURL("projects/$projectid/star.json"),json_encode(array('project_id'=>$projectid)),'POST'); + } + + function unStarProject($projectid) { + return $this->_makeAuthenticatedRequest($this->getAccountURL("projects/$projectid/star.json"),null,'DELETE'); + } + //- makeArray function _makeArray($arg) { if ( $arg && !is_array($arg) ) return array($arg); diff --git a/Basecamp/Project.php b/Basecamp/Project.php index c53635a..a2d8674 100644 --- a/Basecamp/Project.php +++ b/Basecamp/Project.php @@ -213,6 +213,15 @@ function unArchive($id) { function delete() { return $this->_basecamp->deleteProject($this->id); } + + function star() { + return $this->_basecamp->starProject($this->id); + } + + function unstar() { + return $this->_basecamp->unStarProject($this->id); + } + } ?> \ No newline at end of file From d0e53edc2ed6ca6832d4de5b6c68cd09b16ecbe5 Mon Sep 17 00:00:00 2001 From: Joben Ilagan Date: Sun, 25 May 2014 20:56:45 +0800 Subject: [PATCH 4/6] Modified getProjects call to support limit and offset parameters. --- Basecamp.class.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Basecamp.class.php b/Basecamp.class.php index 90934f7..c81491e 100644 --- a/Basecamp.class.php +++ b/Basecamp.class.php @@ -85,11 +85,13 @@ function getAccountURL($target) { } return "$this->account/$target"; } - + //- mark Projects - function getProjects() { - return $this->_makeAuthenticatedRequest($this->getAccountURL('projects.json')); + //- jilagan: Modified to support limit and offset parameters, since default only allows for + // 25 entries at a time and with offset = 0 + function getProjects($limit=25, $offset=0) { + return $this->_makeAuthenticatedRequest($this->getAccountURL('projects.json?limit=' . $limit . '&offset=' . $offset)); } function getProject($id,$native=false) { From 9e0988028ea4cfb1c7b3c0f3d4b61d0fbd05fe44 Mon Sep 17 00:00:00 2001 From: Kev Swindells Date: Thu, 29 May 2014 14:08:20 +0100 Subject: [PATCH 5/6] Actually create an attachment on Basecamp when creating a comment - previously the request just silently failed --- Basecamp.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Basecamp.class.php b/Basecamp.class.php index c81491e..706fadd 100644 --- a/Basecamp.class.php +++ b/Basecamp.class.php @@ -405,7 +405,8 @@ function createComment($project,$on,$id,$comment,$subscribers='',$attachmentName if ( $attachmentName ) { if ( $isFilename ) { - //createAttachment and get token + $attachment = $this->createAttachment($tokenOrFilename); + $token = $attachment->token; } else $token = $tokenOrFilename; $args['attachments'] = array(new Basecamp_Attachment($token,$attachmentName)); } From 1b4192f1cc2fb57d2aeea252e44433b37065c7d7 Mon Sep 17 00:00:00 2001 From: Kshitij Date: Thu, 4 Sep 2014 17:16:56 +0530 Subject: [PATCH 6/6] Handling errors for Too Many Requests and Identical Request conditions --- Basecamp.class.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Basecamp.class.php b/Basecamp.class.php index 706fadd..b7ffe55 100644 --- a/Basecamp.class.php +++ b/Basecamp.class.php @@ -640,7 +640,13 @@ function _makeAuthenticatedRequest($resource,$params=array(),$method='GET',$head $response = json_encode(array('error_code'=>401,'error'=>'Unauthorized Access')); } elseif ( $http_code == 403 ) { $response = json_encode(array('error_code'=>403,'error'=>'Forbidden')); - } + } + elseif ( $http_code == 429 ) { + $response = json_encode(array('error_code'=>429,'error'=>'Too Many Requests')); + } + elseif ( $http_code == 422 ) { + $response = json_encode(array('error_code'=>422,'error'=>'Identical Record Created Within Last 5 Mins')); + } if ( $this->debug ) { print_r(curl_getinfo($ch));