surveymonkey 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +8 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +88 -0
- data/Rakefile +16 -0
- data/bin/console +16 -0
- data/bin/setup +7 -0
- data/lib/surveymonkey/client.rb +192 -0
- data/lib/surveymonkey/config.rb +10 -0
- data/lib/surveymonkey/logging.rb +41 -0
- data/lib/surveymonkey/version.rb +3 -0
- data/lib/surveymonkey.rb +48 -0
- data/surveymonkey.gemspec +33 -0
- metadata +173 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bcc8b046283c6458cefb32ba467347378219a96b
|
4
|
+
data.tar.gz: 5c193620b02c368f19bf86c2030d1fc8da6e03bc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: da13f7310d7db4eb8eefcd2c4c37dd89a8afd7aeaf67b94e1c9b45cdffe3a7894db6322bd2b33d334b47b6a467fc2973fd364c962c3f2ecc35fd4c4c9c6b0fe9
|
7
|
+
data.tar.gz: 2715e724f7aaaffbae8b85731b2d2a300df2af2329d2b6dac58f0994865cb913a84498d6f1654f93b91330f9ec7ae6e1d33a90a1b8ff6a15bb13e3001fb5011e
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p451
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Steve Huff
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# Surveymonkey [![Build Status](https://travis-ci.org/hakamadare/rubygem-surveymonkey.svg?branch=master)](https://travis-ci.org/hakamadare/rubygem-surveymonkey)
|
2
|
+
|
3
|
+
This is a client for the SurveyMonkey [RESTful API](http://developer.surveymonkey.com).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'surveymonkey'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install surveymonkey
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Authentication
|
24
|
+
|
25
|
+
The SurveyMonkey API is built on [Mashery](http://www.mashery.com/) 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.
|
26
|
+
|
27
|
+
Your API key is bound to a particular "application"; once you're logged into the SurveyMonkey developer site, you can create applications.
|
28
|
+
|
29
|
+
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](https://developer.surveymonkey.com/mashery/guide_oauth).
|
30
|
+
|
31
|
+
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._
|
32
|
+
```console
|
33
|
+
$ export SURVEYMONKEY_APIKEY=XXXXXXXXXXX
|
34
|
+
$ export SURVEYMONKEY_ACCESSTOKEN=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
|
35
|
+
```
|
36
|
+
|
37
|
+
Alternately, you can pass them as arguments to `Surveymonkey::Client`, _e.g._
|
38
|
+
```ruby
|
39
|
+
sm = Surveymonkey::Client.new api_key: 'XXXXXXXXXXXX', access_token: 'YYYYYYYYYYYYYYYYYYYY'
|
40
|
+
```
|
41
|
+
|
42
|
+
### API Methods
|
43
|
+
|
44
|
+
The SurveyMonkey API methods are documented [here](https://developer.surveymonkey.com/), under "API Methods". They are implemented as class methods, which you call like so:
|
45
|
+
```ruby
|
46
|
+
[1] pry(main)> Surveymonkey.get_user_details
|
47
|
+
=> {"status"=>0,
|
48
|
+
"data"=>
|
49
|
+
{"user_details"=>
|
50
|
+
{"username"=>"XXXXXX", "is_paid_account"=>true, "is_enterprise_user"=>false}}}
|
51
|
+
```
|
52
|
+
|
53
|
+
To pass parameters to an API method, pass a hash like so:
|
54
|
+
```ruby
|
55
|
+
[2] pry(main)> Surveymonkey.get_survey_list({"page_size" => 5, "order_asc" => true})
|
56
|
+
=> {"status"=>0,
|
57
|
+
"data"=>
|
58
|
+
{"surveys"=>
|
59
|
+
[{"survey_id"=>"XXXXXXXX"},
|
60
|
+
{"survey_id"=>"XXXXXXXX"},
|
61
|
+
{"survey_id"=>"XXXXXXXX"},
|
62
|
+
{"survey_id"=>"XXXXXXXX"},
|
63
|
+
{"survey_id"=>"XXXXXXXX"}],
|
64
|
+
"page"=>1,
|
65
|
+
"page_size"=>5}}
|
66
|
+
```
|
67
|
+
|
68
|
+
API method responses are parsed into Ruby data structures; do with them as you think best.
|
69
|
+
|
70
|
+
## Development
|
71
|
+
|
72
|
+
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.
|
73
|
+
|
74
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
75
|
+
|
76
|
+
## To Do
|
77
|
+
|
78
|
+
* validate API method parameters client-side rather than server-side
|
79
|
+
* more unit tests
|
80
|
+
* better exception handling
|
81
|
+
|
82
|
+
## Contributing
|
83
|
+
|
84
|
+
1. Fork it ( https://github.com/hakamadare/surveymonkey/fork )
|
85
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
86
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
87
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
88
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require "rubygems/tasks"
|
4
|
+
|
5
|
+
# Default directory to look in is `/specs`
|
6
|
+
# Run with `rake spec`
|
7
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
8
|
+
task.rspec_opts = ['--color', '--format', 'documentation']
|
9
|
+
end
|
10
|
+
|
11
|
+
task :default => :spec
|
12
|
+
|
13
|
+
# RubyGems tasks
|
14
|
+
Gem::Tasks.new do |tasks|
|
15
|
+
tasks.console.command = "pry"
|
16
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
|
5
|
+
# set API credentials in env
|
6
|
+
ENV['SURVEYMONKEY_APIKEY'] = 'aaaaaabbbbbbccccccdddddd' unless ENV.member?('SURVEYMONKEY_APIKEY')
|
7
|
+
ENV['SURVEYMONKEY_ACCESSTOKEN'] = 'aaaaaabbbbbbccccccddddddaaaaaabbbbbbccccccddddddaaaaaabbbbbbccccccddddddaaaaaabbbbbbccccccddddddaaaaaabbbbbbccccccddddddaaaaaabbbbbb' unless ENV.member?('SURVEYMONKEY_ACCESSTOKEN')
|
8
|
+
|
9
|
+
require "surveymonkey"
|
10
|
+
|
11
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
12
|
+
# with your gem easier. You can also use a different console, if you like.
|
13
|
+
|
14
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
15
|
+
require "pry"
|
16
|
+
Pry.start
|
data/bin/setup
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
require "httparty"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
require "surveymonkey/logging"
|
5
|
+
|
6
|
+
class Surveymonkey::Client
|
7
|
+
include HTTParty
|
8
|
+
|
9
|
+
$log.debug("Defined Surveymonkey::Client.")
|
10
|
+
|
11
|
+
# constants
|
12
|
+
Baseuri = 'https://api.surveymonkey.net'
|
13
|
+
|
14
|
+
Api_methods = {
|
15
|
+
'create_flow' => {
|
16
|
+
'path' => '/v2/batch/create_flow',
|
17
|
+
},
|
18
|
+
'send_flow' => {
|
19
|
+
'path' => '/v2/batch/send_flow',
|
20
|
+
},
|
21
|
+
'create_collector' => {
|
22
|
+
'path' => '/v2/collectors/create_collector',
|
23
|
+
},
|
24
|
+
'get_survey_list' => {
|
25
|
+
'path' => '/v2/surveys/get_survey_list',
|
26
|
+
},
|
27
|
+
'get_survey_details' => {
|
28
|
+
'path' => '/v2/surveys/get_survey_details',
|
29
|
+
},
|
30
|
+
'get_collector_list' => {
|
31
|
+
'path' => '/v2/surveys/get_collector_list',
|
32
|
+
},
|
33
|
+
'get_respondent_list' => {
|
34
|
+
'path' => '/v2/surveys/get_respondent_list',
|
35
|
+
},
|
36
|
+
'get_responses' => {
|
37
|
+
'path' => '/v2/surveys/get_responses',
|
38
|
+
},
|
39
|
+
'get_response_counts' => {
|
40
|
+
'path' => '/v2/surveys/get_response_counts',
|
41
|
+
},
|
42
|
+
'get_template_list' => {
|
43
|
+
'path' => '/v2/templates/get_template_list',
|
44
|
+
},
|
45
|
+
'get_user_details' => {
|
46
|
+
'path' => '/v2/user/get_user_details',
|
47
|
+
},
|
48
|
+
}
|
49
|
+
|
50
|
+
# public methods
|
51
|
+
attr_reader :baseuri, :api_key
|
52
|
+
attr_accessor :access_token
|
53
|
+
|
54
|
+
def api_call(api_method, method_params = {}, api_key = self.api_key, access_token = self.access_token)
|
55
|
+
begin
|
56
|
+
$log.debug(sprintf("%s: calling '%s'\n", __method__, api_method))
|
57
|
+
|
58
|
+
the_api_method = _api_method(api_method)
|
59
|
+
|
60
|
+
body = _api_method_params(method_params)
|
61
|
+
|
62
|
+
path = the_api_method.fetch('path')
|
63
|
+
|
64
|
+
http_method = the_api_method.fetch('method', 'post')
|
65
|
+
|
66
|
+
$log.debug(sprintf("%s: %s '%s' '%s'\n", __method__, http_method, path, body))
|
67
|
+
|
68
|
+
http_headers = _http_headers(access_token)
|
69
|
+
$log.debug(sprintf("%s: http_headers: '%s'\n", __method__, http_headers.inspect))
|
70
|
+
|
71
|
+
request_uri = _request_uri(path, api_key)
|
72
|
+
|
73
|
+
$log.debug(sprintf("%s: ready to make request for '%s'\n", __method__, api_method))
|
74
|
+
response = self.class.send(http_method.to_sym, request_uri, body: body, headers: http_headers)
|
75
|
+
|
76
|
+
$log.debug(sprintf("%s: response class %s\n", __method__, response.class))
|
77
|
+
$log.debug(sprintf("%s: response code %i\n", __method__, response.code))
|
78
|
+
$log.debug(sprintf("%s: response headers '%s'\n", __method__, response.headers.inspect))
|
79
|
+
|
80
|
+
response.parsed_response
|
81
|
+
|
82
|
+
rescue KeyError => e
|
83
|
+
$log.error(sprintf("%s: no such method '%s': %s\n", __method__, http_method, e.message))
|
84
|
+
raise e
|
85
|
+
rescue Exception => e
|
86
|
+
$log.error(sprintf("%s: %s\n", __method__, e.message))
|
87
|
+
raise
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def initialize(*args)
|
92
|
+
begin
|
93
|
+
param_hash = args.shift || {}
|
94
|
+
@baseuri = param_hash.fetch('baseuri', Baseuri)
|
95
|
+
@access_token = param_hash.fetch('access_token', _from_env('SURVEYMONKEY_ACCESSTOKEN'))
|
96
|
+
@api_key = param_hash.fetch('api_key', _from_env('SURVEYMONKEY_APIKEY'))
|
97
|
+
|
98
|
+
self.class.logger $log, :debug
|
99
|
+
|
100
|
+
$log.debug(sprintf("%s: setting base_uri to '%s'\n", __method__, @baseuri))
|
101
|
+
self.class.base_uri @baseuri
|
102
|
+
|
103
|
+
$log.debug(sprintf("%s: setting headers'\n", __method__))
|
104
|
+
the_headers = {
|
105
|
+
"Content-Type" => "application/json",
|
106
|
+
"Authorization" => sprintf("bearer %s", @access_token),
|
107
|
+
}
|
108
|
+
self.class.headers the_headers
|
109
|
+
rescue Exception => e
|
110
|
+
$log.error(sprintf("%s: %s\n", __method__, e.message))
|
111
|
+
raise
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# private methods
|
116
|
+
private
|
117
|
+
|
118
|
+
def _api_method(key, api_methods = Api_methods)
|
119
|
+
begin
|
120
|
+
$log.debug(sprintf("%s: fetching '%s' from api methods\n", __method__, key))
|
121
|
+
value = api_methods.fetch(key)
|
122
|
+
$log.debug(sprintf("%s: retrieved '%s'\n", __method__, value.inspect))
|
123
|
+
value
|
124
|
+
|
125
|
+
rescue KeyError => e
|
126
|
+
$log.error(sprintf("%s: '%s' not found in api methods\n", __method__, key))
|
127
|
+
raise e
|
128
|
+
rescue Exception => e
|
129
|
+
$log.error(sprintf("%s: %s\n", __method__, e.message))
|
130
|
+
raise
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def _http_headers(token)
|
135
|
+
begin
|
136
|
+
$log.debug(sprintf("%s: constructing http headers with token '%s'\n", __method__, token))
|
137
|
+
http_headers = {
|
138
|
+
"Content-Type" => "application/json",
|
139
|
+
"Authorization" => sprintf("bearer %s", token),
|
140
|
+
}
|
141
|
+
$log.debug(sprintf("%s: http headers: '%s'\n", __method__, http_headers))
|
142
|
+
http_headers
|
143
|
+
|
144
|
+
rescue Exception => e
|
145
|
+
$log.error(sprintf("%s: %s\n", __method__, e.message))
|
146
|
+
raise
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def _api_method_params(method_params)
|
151
|
+
begin
|
152
|
+
# TODO validate params against API spec
|
153
|
+
$log.debug(sprintf("%s: parsing api method params from '%s'\n", __method__, method_params))
|
154
|
+
the_params = JSON.generate(method_params || {}).to_s
|
155
|
+
$log.debug(sprintf("%s: parsed method params '%s'\n", __method__, the_params))
|
156
|
+
the_params
|
157
|
+
|
158
|
+
rescue Exception => e
|
159
|
+
$log.error(sprintf("%s: %s\n", __method__, e.message))
|
160
|
+
raise
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def _request_uri(path, api_key)
|
165
|
+
begin
|
166
|
+
$log.debug(sprintf("%s: generating request uri fragment from '%s' and '%s'\n", __method__, path, api_key))
|
167
|
+
request_uri = sprintf("%s?api_key=%s", path, api_key)
|
168
|
+
$log.debug(sprintf("%s: generated '%s'\n", __method__, request_uri))
|
169
|
+
request_uri
|
170
|
+
|
171
|
+
rescue Exception => e
|
172
|
+
$log.error(sprintf("%s: %s\n", __method__, e.message))
|
173
|
+
raise
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def _from_env(key)
|
178
|
+
begin
|
179
|
+
$log.debug(sprintf("%s: fetching '%s' from environment\n", __method__, key))
|
180
|
+
value = ENV.fetch(key)
|
181
|
+
$log.debug(sprintf("%s: retrieved '%s'\n", __method__, value))
|
182
|
+
value
|
183
|
+
|
184
|
+
rescue KeyError => e
|
185
|
+
$log.info(sprintf("%s: '%s' not found in environment\n", __method__, key))
|
186
|
+
rescue Exception => e
|
187
|
+
$log.error(sprintf("%s: %s\n", __method__, e.message))
|
188
|
+
raise
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Surveymonkey::Logging
|
2
|
+
# initialize logging
|
3
|
+
if ENV.member?('SURVEYMONKEY_LOGLEVEL')
|
4
|
+
Loglevel = ENV['SURVEYMONKEY_LOGLEVEL'].to_sym
|
5
|
+
else
|
6
|
+
Loglevel = :error
|
7
|
+
end
|
8
|
+
|
9
|
+
begin
|
10
|
+
# configure logging
|
11
|
+
Logging.color_scheme( 'bright',
|
12
|
+
:levels => {
|
13
|
+
:debug => :grey,
|
14
|
+
:info => :green,
|
15
|
+
:warn => :orange,
|
16
|
+
:error => :red,
|
17
|
+
:fatal => [:white, :on_red]
|
18
|
+
},
|
19
|
+
:date => :blue,
|
20
|
+
:logger => :cyan,
|
21
|
+
:message => :yellow
|
22
|
+
)
|
23
|
+
|
24
|
+
Logging.appenders.stderr(
|
25
|
+
'stderr',
|
26
|
+
:layout => Logging.layouts.pattern(
|
27
|
+
:pattern => '[%d] %-5l %c: %m\n',
|
28
|
+
:color_scheme => 'bright'
|
29
|
+
)
|
30
|
+
)
|
31
|
+
|
32
|
+
$log = Logging.logger['surveymonkey']
|
33
|
+
$log.add_appenders 'stderr'
|
34
|
+
|
35
|
+
$log.level = Loglevel
|
36
|
+
$log.debug("Configured logging to stderr.")
|
37
|
+
rescue Exception => e
|
38
|
+
$stderr.puts("Unable to configure logging: #{e.message}")
|
39
|
+
raise
|
40
|
+
end
|
41
|
+
end
|
data/lib/surveymonkey.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require "logging"
|
2
|
+
|
3
|
+
require "surveymonkey/version"
|
4
|
+
require "surveymonkey/logging"
|
5
|
+
|
6
|
+
module Surveymonkey
|
7
|
+
autoload :Client, "surveymonkey/client"
|
8
|
+
|
9
|
+
class << self
|
10
|
+
# Constants
|
11
|
+
|
12
|
+
# Public methods
|
13
|
+
def method_missing(method_name, *args)
|
14
|
+
begin
|
15
|
+
$log.debug(sprintf("%s: %s\n", __method__, 'enter'))
|
16
|
+
|
17
|
+
method_params = Hash(Array(args).shift) || {}
|
18
|
+
|
19
|
+
response = _client.send(:api_call, method_name.to_s, method_params)
|
20
|
+
response
|
21
|
+
|
22
|
+
rescue TypeError => e
|
23
|
+
$log.fatal(sprintf("%s: method parameters must be a hash\n"))
|
24
|
+
exit 1
|
25
|
+
rescue KeyError => e
|
26
|
+
$log.fatal(sprintf("%s: method '%s' not implemented\n"))
|
27
|
+
exit 1
|
28
|
+
rescue Exception => e
|
29
|
+
$log.error(sprintf("%s: %s\n", __method__, e.message))
|
30
|
+
raise
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Private methods
|
35
|
+
private
|
36
|
+
|
37
|
+
def _client
|
38
|
+
begin
|
39
|
+
@client = Surveymonkey::Client.new()
|
40
|
+
rescue Exception => e
|
41
|
+
$log.fatal(sprintf("%s: %s\n", "Unable to initialize REST client", e.message))
|
42
|
+
$log.debug(sprintf("%s: %s\n", __method__, e.message))
|
43
|
+
raise
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'surveymonkey/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "surveymonkey"
|
8
|
+
spec.version = Surveymonkey::VERSION
|
9
|
+
spec.authors = ["Steve Huff"]
|
10
|
+
spec.email = ["shuff@vecna.org"]
|
11
|
+
|
12
|
+
spec.summary = %q{Client for SurveyMonkey REST API}
|
13
|
+
spec.description = %q{Interact with SurveyMonkey's REST API. Requires an API token.}
|
14
|
+
spec.homepage = "http://developer.surveymonkey.com/"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.required_ruby_version = '>= 1.9.3'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", ">= 1.7"
|
25
|
+
spec.add_development_dependency "pry", "~> 0.10"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 2.4"
|
28
|
+
spec.add_development_dependency "rubygems-tasks", "~> 0.2"
|
29
|
+
|
30
|
+
spec.add_runtime_dependency "httparty", "~> 0.13"
|
31
|
+
spec.add_runtime_dependency "json", "~> 1.8"
|
32
|
+
spec.add_runtime_dependency "logging", "~> 2"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: surveymonkey
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Steve Huff
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubygems-tasks
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: httparty
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.13'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.13'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: json
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.8'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.8'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: logging
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '2'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '2'
|
125
|
+
description: Interact with SurveyMonkey's REST API. Requires an API token.
|
126
|
+
email:
|
127
|
+
- shuff@vecna.org
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- .gitignore
|
133
|
+
- .rspec
|
134
|
+
- .ruby-version
|
135
|
+
- .travis.yml
|
136
|
+
- CODE_OF_CONDUCT.md
|
137
|
+
- Gemfile
|
138
|
+
- LICENSE.txt
|
139
|
+
- README.md
|
140
|
+
- Rakefile
|
141
|
+
- bin/console
|
142
|
+
- bin/setup
|
143
|
+
- lib/surveymonkey.rb
|
144
|
+
- lib/surveymonkey/client.rb
|
145
|
+
- lib/surveymonkey/config.rb
|
146
|
+
- lib/surveymonkey/logging.rb
|
147
|
+
- lib/surveymonkey/version.rb
|
148
|
+
- surveymonkey.gemspec
|
149
|
+
homepage: http://developer.surveymonkey.com/
|
150
|
+
licenses:
|
151
|
+
- MIT
|
152
|
+
metadata: {}
|
153
|
+
post_install_message:
|
154
|
+
rdoc_options: []
|
155
|
+
require_paths:
|
156
|
+
- lib
|
157
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - '>='
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: 1.9.3
|
162
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
requirements: []
|
168
|
+
rubyforge_project:
|
169
|
+
rubygems_version: 2.0.14
|
170
|
+
signing_key:
|
171
|
+
specification_version: 4
|
172
|
+
summary: Client for SurveyMonkey REST API
|
173
|
+
test_files: []
|