public function getAll()
 {
     $base = API::getBaseUrl();
     $async = new AsyncRequest([new Request($base . "todolists.json"), new Request($base . "todolists/completed.json"), new Request($base . "todolists/trashed.json")]);
     $async->performRequests();
     return ['active' => $async->requests[0]->response->body, 'completed' => $async->requests[1]->response->body, 'trashed' => $async->requests[2]->response->body];
 }
Beispiel #2
0
 /**
  * Get Projects
  * https://github.com/basecamp/bcx-api/blob/master/sections/projects.md#get-projects
  * Returns an array of 'active', 'drafts', 'archived' projects.
  * @return array
  */
 public function getAll()
 {
     // Endpoints
     $endPoints = ['projects.json', 'projects/drafts.json', 'projects/archived.json'];
     // Declare an array to hold requests.
     $requests = [];
     // Get the base url.
     $baseUrl = API::getBaseUrl();
     // Loop through the urls
     foreach ($endPoints as $endPoint) {
         $requests[] = new Request($baseUrl . $endPoint);
     }
     // Perform requests.
     $async = new AsyncRequest($requests);
     $async->performRequests();
     return ['active' => $async->requests[0]->response->body, 'drafts' => $async->requests[1]->response->body, 'archived' => $async->requests[2]->response->body];
 }
Beispiel #3
0
 /**
  * @param $endpoint
  * @param $args
  * @param $method
  * @return Response
  * @throws \Exception
  */
 protected static function auto($endpoint, $args, $method)
 {
     $request = new self(API::getBaseUrl() . $endpoint, $args, $method);
     $request->performRequest();
     if (!$request->response->httpCode == 200) {
         throw new \Exception('CURL ERROR: ' . $request->response->error['message']);
     }
     return $request->response;
 }