Skip to content

Staplegun-US/intervals_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intervals API

By Staplegun

Description

This gem is a wrapper around the Intervals REST API which allows you to retrieve, create, update, and delete several different resources from their database. All API requests are made with the help of the HTTParty gem.

Usage

To begin, create an instance of your specific Intervals account using the account's API token. You can learn where to find that here.

intervals = IntervalsAPI::RequestHandler.new('your_token')

Now you're free to make your requests. The structure of a request looks like:

intervals.get(resource, query_options)

Request Arguments

resource

Type: String

The endpoint resource you are querying

query_options

Type: Hash Default: {}

A hash of options, such as filter options for a GET request, new object options for a POST request, etc.

Available keys (See in the examples how they're used):

  • query - Query parameters that you wish to pass, typically via GET requests
  • body - Data you wish to submit, typically via POST or PUT requests
  • headers - Request headers you wish to set

View the HTTParty gem to see more options about formatting your request, and view the Intervals documentation to learn about which resources are available to request.

Response

The response from Intervals API will contain all returned json data from Intervals in the form of a hash.

Request Type Examples

Get

# Retrieve all clients
response = intervals.get('/client/');
# Retrieve all active clients
response = intervals.get('/client/', query: {
  active: true
});

Post

# Create a task request
intervals.post('/request/', body: {
  personid:     5,
  projectid:    6,
  title:        'Just an average title'
})

Put

# Update a task request
intervals.put('/request/1/', body: {
  priorityid:   1,
  title:        "Here's an updated title"
})

Delete

# Delete a task request
intervals.delete('/request/1/')

TODO

Build a test suite to test the API. If anyone has a great way to test an authenticated third-party API, throw out some ideas.


Intervals API is licensed under the [GPL](http://www.gnu.org/licenses/gpl.html) license.

Staplegun

About

A RESTful wrapper around the Intervals API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages