Git Product home page Git Product logo

mashery-rb's Introduction

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"'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.