2017 © Pedro Peláez
 

library sprintly-php

Sprintly API wrapper for PHP 5.4+

image

dugan/sprintly-php

Sprintly API wrapper for PHP 5.4+

  • Thursday, December 11, 2014
  • by mikedugan
  • Repository
  • 4 Watchers
  • 3 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Sprintly-PHP

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

This is a library that wraps the Sprint.ly API for PHP 5.4+., (*2)

API Status: (:heavy_check_mark: Complete, :interrobang: In Progress, :x: Todo), (*3)

"CRUD" should be interpreted as:, (*4)

Create resource, delete resource, retrieve all of resource, retrieve 1+ resource, update resource, (*5)

:heavy_check_mark: Product CRUD, (*6)

:heavy_check_mark: Product People CRUD, (*7)

:heavy_check_mark: Product Item CRUD, (*8)

:heavy_check_mark: Perform lightweight queries of a product's items, (*9)

:heavy_check_mark: Retrieve children of an item, (*10)

Quickstart

This package requires Composer, (*11)

composer require "dugan/sprintly-php": "dev-master"
composer update
$service = new \Dugan\Sprintly\SprintlyService('myemail@example.net', 'mySprintlyAuthKey');
$products = $service->getProductsRepository()->all();
foreach($products as $product) {
    echo $product->getName()."\n";
}



## How it Works Under the hood, we use the Guzzle library to consume the Sprintly [API](https://sprintly.uservoice.com/knowledgebase/topics/15784-api) Top level entities can be accessed using the wrapper methods in `Dugan\Sprintly\SprintlyService`, or you can use the service to retrieve the individual repositories and work with them. ### Authenticating Sprintly's API uses HTTP auth with an email address and Auth token which you can retrieve from their website. All API methods require authentication, and several require you to have administrator status on a given product. How to instantiate the API with your credentials: `$service = \Dugan\Sprintly\SprintlyService::instance($myEmail, $myAuthkey);` All examples after this will assume `$service` has already been instantiated with your credentials. Since the SprintlyService implements the Singleton pattern, we can avoid having to repeatedly instantiate it when it is needed in different places. To retrieve an existing instance, simply call: `\Dugan\Sprintly\SprintlyService::instance()` ### Common Functionality Instead of repeating the following code snippets several times, I will let it suffice to say that most repositories implement the two following methods, used in 3 different ways. We'll demonstrate with the PeopleRepository, but the same methods will exist on other repositories. To retrieve all of a resource (the index): `$service->getPeopleRepository()->all()` To retrieve a single resource (the GET): `$service->getPeopleRepository()->get($id)` To retrieve a collection of resources, but not all of them: `$service->getPeopleRepository()->get([$firstId, $secondId])` Note this will execute multiple HTTP requests, so when working with more than a couple resources, it is often more efficient to retrieve all resources and filter them locally. There are also wrapper methods for retrieving an entity's repository through the service: `$service->products()->get($id)` `$service->items()->all()` etc ### Products The Product is top-level entity in Sprintly. It has items, people, attachments, tags, etc related to it, which can all be accessed through the API. ##### Retrieve all products: *Using SprintlyService* `$service->getAllProducts()` Returns an array of `\Dugan\Sprintly\Entities\Product` ##### Retrieve a single product: *Using SprintlyService* `$service->getProduct($id)` Returns an instance of `\Dugan\Sprintly\Entities\Product` Retrieve a collection of products (but not all of them!): *Using SprintlyService* `$service->getProduct([$firstId, $secondId])` *Using ProductsRepository* `$service->getProductsRepository()->get([$firstId, $secondId])` Returns an array of `\Dugan\Sprintly\Entities\Product` <<<<<<< HEAD The returned product will have several properties on it which are available for your use:
$product->getName(); $product->getCreatedBy(); $product->getId(); $product->getCreatedAt(); $product->getWebhook();

The webhook is especially useful if you want to integrate Sprintly with GitHub or Bitbucket for closing items via commit messages. ### The Product ID Most of the entities represented by the Sprintly API are only accessible in the context of a product. Unless otherwise noted, from here on out you should assume all code examples are preceded by: `$service->setProductId($productId)` This will allow the service to automatically inject the product ID into the appropriate repositories before returning them back to you. Note that the SprintlyService is a singleton, and will therefore retain the last product ID set on it until you set another product ID on it. ### Users In the Sprintly verbiage, users are called people and person. The API wrapper reflects this. You can only retrieve people in the context of a product. To invite a user to a product:
$user = new \Dugan\Sprintly\Entities\Person(); $user->setFirstName('Mike'); $user->setLastName('Dugan'); $user->setEmail('foo@bar.com'); $invitedUser = $service->people()->invite($user);

### Items Items are the stories, tasks, defects, etc that belong to a product. Again, these can only be retrieved in the context of a product. To create a new item:
$item = new \Dugan\Sprintly\Entities\Item(); $item->setTitle('Something broke'); $item->setAssignedTo($myUserId); $item->setTags('major,bug'); $service->items()->create($item);

To retrieve an item's children:
$item = $service->items()->get($itemId); $children = $service->items()->children($item);

Annotations

Attachments

Comments

Tags

The Versions

11/12 2014

dev-master

9999999-dev

Sprintly API wrapper for PHP 5.4+

  Sources   Download

MIT

The Requires

 

The Development Requires

api sprintly

11/12 2014

v0.0.4

0.0.4.0

Sprintly API wrapper for PHP 5.4+

  Sources   Download

MIT

The Requires

 

The Development Requires

api sprintly

07/11 2014

v0.0.3

0.0.3.0

Sprintly API wrapper for PHP 5.4+

  Sources   Download

MIT

The Requires

 

The Development Requires

api sprintly

04/11 2014

v0.0.2

0.0.2.0

Sprintly API wrapper for PHP 5.4+

  Sources   Download

MIT

The Requires

 

The Development Requires

api sprintly

04/11 2014

v0.0.1-beta

0.0.1.0-beta

Sprintly API wrapper for PHP 5.4+

  Sources   Download

MIT

The Requires

 

The Development Requires

api sprintly