What is this?
A NodeJS library to talk to Target Process 3's API.
How do I use it?
In your NodeJS program, add:
var tp =domain: // your domain here; eg: 'fullscreen.tpondemand.com'username: // your username; eg: 'paul@fullscreen.net'password: // your passwordversion: // Optional API version - defaults to 1protocol: // Optional protocol - defaults to https
Methods
tp()
or tp([Entity name])
Returns a TargetProcess request object. Can optionally set an entity to request.
tp.get(Entity Name)
Tells the TargetProcess object to request the given entity. An entity can be one of the following:
- Context
- Projects
- Features
- Releases
- Iterations
- Requests
- CustomFields
- Bugs
- Tasks
- TestCases
- Times
- Impediments
- Assignments
- Attachments
- Comments
- UserStories
- Roles
- GeneralUsers
- EntityStates
Example - fetch a list of roles
tp.take(n)
Tells the TargetProcess object to request n
of the requested entities
Example - fetch 5 tasks:
tp.context(acid)
Retrieve list of entities for specific projects (via Acid)
Example - fetch 5 tasks of the project with the context 123456:
tp.where(search expression)
Applies a search filter to the TargetProcess request.
Example, find open tasks:
More info on Target Process filters can be found here: https://dev.targetprocess.com/docs/sorting-and-filters
tp.pluck(list, of, properties)
Instructs the Target Process object to only include the listed properties in the response object:
Example, fetch the name and description from these tasks:
tp.sortBy(field)
Tells the Target Process request to sort on the given field
Example, fetch a list of tasks by priority:
or sort by descending order:
tp.append(list, of, properties)
Instructs the Target Process request to get additional information about Entity
Example, get number of bugs, tasks and comments associated with those user stories:
tp.then(handlerFunction)
Executes the Target Process request. Your callback will be called with an error object and the result of your request.
Example, fetch a list of tasks:
tp.thenEntities(handlerFunction)
Thin wrapper around tp.then
, but instead of returning (err, data)
it returns (err, entities)
where entities is an array of entity objects.
Example, fetch a list of Entities
// Move all open tasks to 'Planned'
Nested JSON objects
It may happen that the following code:
will return a lot of nested JSON objects:
my tasks [
The returned object tasks
here is a JavaScript object. In order to convert it into JSON string, use JSON.stringify()
:
and now it returns:
my tasks [{"ResourceType":"Task","Id":3631,"Project":{"ResourceType":"Project","Id":4026,"Process":{"Id":5,"Name":"AIScrum"}},"CustomFields":[{"Name":"Component","Type":"DropDown","Value":null},{"Name":"trac","Type":"Number","Value":null},{"Name":"Job","Type":"DropDown","Value":null},{"Name":"Resolution","Type":"DropDown","Value":null},{"Name":"Domain","Type":"DropDown","Value":null}]}]