Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Basecamp/Api/AbstractApi.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Basecamp\Api;

use Basecamp\Client;
Expand All @@ -24,7 +25,7 @@ public function __construct(Client $client)

final protected function get($resource, array $params = [])
{
$resource = empty($params) ? $resource : ($resource . (false === strpos($resource, '?') ? '?' : '&') . http_build_query($params, '', '&'));
$resource = empty($params) ? $resource : ($resource.(false === strpos($resource, '?') ? '?' : '&').http_build_query($params, '', '&'));

$response = $this->request(Request::METHOD_GET, $resource);

Expand Down Expand Up @@ -54,9 +55,9 @@ final protected function delete($resource)

private function request($method, $resource, $params = [])
{
$message = new Request($method, $resource, self::BASE_URL . $this->client->getAccountData()['accountId'] . self::API_VERSION);
$message = new Request($method, $resource, self::BASE_URL.$this->client->getAccountData()['accountId'].self::API_VERSION);
$message->setHeaders([
'User-Agent: ' . $this->client->getAccountData()['appName'],
'User-Agent: '.$this->client->getAccountData()['appName'],
'Content-Type: application/json',
]);

Expand All @@ -75,9 +76,9 @@ private function request($method, $resource, $params = [])
$bc->setTimeout($this->timeout);

if (!empty($this->client->getAccountData()['login']) && !empty($this->client->getAccountData()['password'])) {
$bc->setOption(CURLOPT_USERPWD, $this->client->getAccountData()['login'] . ':' . $this->client->getAccountData()['password']);
$bc->setOption(CURLOPT_USERPWD, $this->client->getAccountData()['login'].':'.$this->client->getAccountData()['password']);
} elseif (!empty($this->client->getAccountData()['token'])) {
$message->addHeader('Authorization: Bearer ' . $this->client->getAccountData()['token']);
$message->addHeader('Authorization: Bearer '.$this->client->getAccountData()['token']);
}

$bc->send($message, $response);
Expand Down Expand Up @@ -107,7 +108,7 @@ private function request($method, $resource, $params = [])
$data->message = '415 Unsupported Media Type';
break;
case 429:
$data->message = '429 Too Many Requests. ' . $response->getHeader('Retry-After');
$data->message = '429 Too Many Requests. '.$response->getHeader('Retry-After');
break;
case 500:
$data->message = '500 Hmm, that isn’t right';
Expand Down
29 changes: 15 additions & 14 deletions Basecamp/Api/Accesses.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Basecamp\Api;

/**
Expand All @@ -11,87 +12,87 @@ class Accesses extends AbstractApi
/**
* Get accesses to project.
*
* @param integer $projectId
* @param int $projectId
*
* @return array
*/
public function project($projectId)
{
$data = $this->get('/projects/' . $projectId . '/accesses.json');
$data = $this->get('/projects/'.$projectId.'/accesses.json');

return $data;
}

/**
* Grant access to project.
*
* @param integer $projectId
* @param int $projectId
* @param array $userIds
*
* @return object
*/
public function grantProject($projectId, array $userIds)
{
$data = $this->post('/projects/' . $projectId . '/accesses.json', $userIds);
$data = $this->post('/projects/'.$projectId.'/accesses.json', $userIds);

return $data;
}

/**
* Revoke access from project.
*
* @param integer $projectId
* @param integer $userId
* @param int $projectId
* @param int $userId
*
* @return object
*/
public function revokeProject($projectId, $userId)
{
$data = $this->delete('/projects/' . $projectId . '/accesses/' . $userId . '.json');
$data = $this->delete('/projects/'.$projectId.'/accesses/'.$userId.'.json');

return $data;
}

/**
* Get accesses to calendar.
*
* @param integer $calendarId
* @param int $calendarId
*
* @return array
*/
public function calendar($calendarId)
{
$data = $this->get('/calendars/' . $calendarId . '/accesses.json');
$data = $this->get('/calendars/'.$calendarId.'/accesses.json');

return $data;
}

/**
* Grant access to calendar.
*
* @param integer $calendarId
* @param int $calendarId
* @param array $userIds
*
* @return object
*/
public function grantCalendar($calendarId, array $userIds)
{
$data = $this->post('/calendars/' . $calendarId . '/accesses.json', $userIds);
$data = $this->post('/calendars/'.$calendarId.'/accesses.json', $userIds);

return $data;
}

/**
* Revoke access from calendar.
*
* @param integer $calendarId
* @param integer $userId
* @param int $calendarId
* @param int $userId
*
* @return object
*/
public function revokeCalendar($calendarId, $userId)
{
$data = $this->delete('/projects/' . $calendarId . '/accesses/' . $userId . '.json');
$data = $this->delete('/projects/'.$calendarId.'/accesses/'.$userId.'.json');

return $data;
}
Expand Down
11 changes: 6 additions & 5 deletions Basecamp/Api/Attachments.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Basecamp\Api;

/**
Expand All @@ -23,28 +24,28 @@ public function all()
/**
* Get project's attachments.
*
* @param integer $projectId
* @param int $projectId
*
* @return array
*/
public function projectAll($projectId)
{
$data = $this->get('/projects/' . $projectId . '/attachments.json');
$data = $this->get('/projects/'.$projectId.'/attachments.json');

return $data;
}

/**
* Get attachment.
*
* @param integer $projectId
* @param integer $attachmentId
* @param int $projectId
* @param int $attachmentId
*
* @return object
*/
public function show($projectId, $attachmentId)
{
$data = $this->get('GET /projects/' . $projectId . '/attachments/' . $attachmentId . '.json');
$data = $this->get('GET /projects/'.$projectId.'/attachments/'.$attachmentId.'.json');

return $data;
}
Expand Down
15 changes: 8 additions & 7 deletions Basecamp/Api/Calendars.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace Basecamp\Api;

/**
Expand All @@ -9,7 +10,7 @@
class Calendars extends AbstractApi
{
/**
* Get calendars
* Get calendars.
*
* @return array
*/
Expand All @@ -23,13 +24,13 @@ public function all()
/**
* Get calendar.
*
* @param integer $calendarId
* @param int $calendarId
*
* @return object
*/
public function show($calendarId)
{
$data = $this->get('/calendars/' . $calendarId . '.json');
$data = $this->get('/calendars/'.$calendarId.'.json');

return $data;
}
Expand All @@ -51,28 +52,28 @@ public function create(array $params)
/**
* Update calendar.
*
* @param integer $calendarId
* @param int $calendarId
* @param array $params
*
* @return object
*/
public function update($calendarId, array $params)
{
$data = $this->put('/calendars/' . $calendarId . '.json', $params);
$data = $this->put('/calendars/'.$calendarId.'.json', $params);

return $data;
}

/**
* Delete calendar.
*
* @param integer $calendarId
* @param int $calendarId
*
* @return object
*/
public function remove($calendarId)
{
$data = $this->delete('/calendars/' . $calendarId . '.json');
$data = $this->delete('/calendars/'.$calendarId.'.json');

return $data;
}
Expand Down
Loading