Skip to content
This repository was archived by the owner on Dec 2, 2017. It is now read-only.

look/mashery-rb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Ruby library for the Mashery API.

Prerequisites

Install the gem dependencies (see gembundler.com if you aren’t familiar with Bundler):

$ bundle install

Calling methods from the command line

A set of Thor tasks are provided so that you can call API methods from the command line (read more about Thor at
http://github.com/wycats/thor).

The following examples assume you have Thor installed system-wide. If it’s local to your bundle, then replace
thor with bundle exec thor.

You can see all available Mashery tasks with this command:

$ thor list mashery

Environment

Before you can successfully call an API method, you must set these environment variables:

$ export MASHERY_SITE_ID=666
$ export MASHERY_API_KEY=cafebebedeadbeefcafebebedeadbeef
$ export MASHERY_SHARED_SECRET=blahblahblah

Querying objects

The Mashery API supports querying the following types of objects: members, applications, keys, services, and roles.

To perform a query, construct a Query object for the type of object you want to query:

query = Mashery::Query.new('members')
members = query.fetch_all

The fetch_all method will automatically paginate through the results for you. You can also control this yourself with the page parameter and execute:

query = Mashery::Query.new('members', :page => 2)
result = query.execute
items = result['items']

(Or, use the items method, which combines execute and result['items'] — however, this does not return result set metadata, like current page and total pages.)

The default will return all fields (e.g., SELECT * FROM members). To control this, specify the :fields parameter.

To control which records are returned, specify the :where parameter.

query = Mashery::Query.new('members', :where => 'username = "Jeff"'

About

Ruby library for the Mashery API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages