0.01
No release in over 3 years
Low commit activity in last 3 years
Interact with SurveyMonkey's REST API. Requires an API token.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.7
~> 2
~> 0.10
~> 10.0
~> 4
~> 2.4

Runtime

~> 0.13
~> 1.8
 Project Readme

Surveymonkey Build Status Gem Version

This is a client for the SurveyMonkey RESTful API.

Installation

Add this line to your application's Gemfile:

gem 'surveymonkey'

And then execute:

$ bundle

Or install it yourself as:

$ gem install surveymonkey

Usage

Authentication

The SurveyMonkey API is built on Mashery and works like other Mashery APIs. To access it, you'll need an API key and an access token; you'll be prompted to create these when you create a SurveyMonkey developer account.

Your API key is bound to a particular "application"; once you're logged into the SurveyMonkey developer site, you can create applications.

Access tokens are created via OAuth; you can either create one-off access tokens via the SurveyMonkey API console, or you can implement an OAuth flow of your own; there's more documentation here.

This gem requires that you specify both the API key and the access token at runtime. The access token can be changed between each API call; the API key is set once and then cannot be changed. Both of these can be read from environment variables, e.g.

$ export SURVEYMONKEY_APIKEY=XXXXXXXXXXX
$ export SURVEYMONKEY_ACCESSTOKEN=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

API Methods

The SurveyMonkey API methods are documented here, under "API Methods". They are implemented as class methods, which you call like so:

[1] pry(main)> Surveymonkey.get_user_details
=> {"status"=>0,
 "data"=>
  {"user_details"=>
    {"username"=>"XXXXXX", "is_paid_account"=>true, "is_enterprise_user"=>false}}}

To pass parameters to an API method, pass a hash like so:

[2] pry(main)> Surveymonkey.get_survey_list("page_size" => 5, "order_asc" => true)
=> {"status"=>0,
 "data"=>
  {"surveys"=>
    [{"survey_id"=>"XXXXXXXX"},
     {"survey_id"=>"XXXXXXXX"},
     {"survey_id"=>"XXXXXXXX"},
     {"survey_id"=>"XXXXXXXX"},
     {"survey_id"=>"XXXXXXXX"}],
   "page"=>1,
   "page_size"=>5}}

API method responses are parsed into Ruby data structures; do with them as you think best.

SurveyMonkey API responses include a status attribute. The possible values of this attribute are documented upstream; Surveymonkey::Client inspects each API response and raises a Surveymonkey::Error if the status code is other than 0.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install.

To Do

  • implement support for API v3
  • validate API method parameters client-side rather than server-side
  • more unit tests
  • better exception handling

Contributing

  1. Fork it ( https://github.com/hakamadare/surveymonkey/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Esteemed Contributors

  • @KazuyaMuroi
  • @cescue