Class: Qualaroo::Client
Class Attribute Summary collapse
-
.api_key ⇒ Object
Returns the value of attribute api_key.
-
.api_secret ⇒ Object
Returns the value of attribute api_secret.
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_secret ⇒ Object
Returns the value of attribute api_secret.
Class Method Summary collapse
Instance Method Summary collapse
- #all_responses(nudge_id, query = {}, options = {}) ⇒ Object
-
#initialize(api_key, api_secret) ⇒ Client
constructor
A new instance of Client.
- #responses(nudge_id, query = {}, options = {}) ⇒ Object
Constructor Details
#initialize(api_key, api_secret) ⇒ Client
Returns a new instance of Client.
12 13 14 15 16 17 |
# File 'lib/qualaroo.rb', line 12 def initialize(api_key, api_secret) @auth = { username: api_key || self.class.api_key || ENV['QUALAROO_API_KEY'], password: api_secret || self.class.api_secret || ENV['QUALAROO_API_SECRET'] } end |
Class Attribute Details
.api_key ⇒ Object
Returns the value of attribute api_key.
37 38 39 |
# File 'lib/qualaroo.rb', line 37 def api_key @api_key end |
.api_secret ⇒ Object
Returns the value of attribute api_secret.
37 38 39 |
# File 'lib/qualaroo.rb', line 37 def api_secret @api_secret end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
10 11 12 |
# File 'lib/qualaroo.rb', line 10 def api_key @api_key end |
#api_secret ⇒ Object
Returns the value of attribute api_secret.
10 11 12 |
# File 'lib/qualaroo.rb', line 10 def api_secret @api_secret end |
Class Method Details
.method_missing(sym, *args, &block) ⇒ Object
39 40 41 |
# File 'lib/qualaroo.rb', line 39 def method_missing(sym, *args, &block) new(api_key, api_secret).send(sym, *args, &block) end |
Instance Method Details
#all_responses(nudge_id, query = {}, options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/qualaroo.rb', line 24 def all_responses(nudge_id, query={}, ={}) offset = 0 all_responses = [] while (page_responses = responses(nudge_id, query.merge(offset: offset), )) && page_responses.any? all_responses += page_responses offset += 500 end all_responses end |
#responses(nudge_id, query = {}, options = {}) ⇒ Object
19 20 21 22 |
# File 'lib/qualaroo.rb', line 19 def responses(nudge_id, query={}, ={}) .merge!(basic_auth: @auth, query: query) self.class.get("/nudges/#{nudge_id}/responses.json", ) end |