Class: WufooParty
Overview
:startdoc:
Defined Under Namespace
Classes: ConnectionError, Entity, Form, HTTPError, Report, User
Constant Summary collapse
- VERSION =
'1.0.1'
- ENDPOINT =
'https://%s.wufoo.com/api/v3'
- API_VERSION =
'3.0'
Instance Method Summary collapse
-
#form(form_id) ⇒ Object
Returns details about the specified form.
-
#forms ⇒ Object
Returns list of forms and details accessible by the user account.
-
#get(method, options = {}) ⇒ Object
:nodoc:.
-
#initialize(account, api_key) ⇒ WufooParty
constructor
Create a new WufooParty object.
-
#post(method, options = {}) ⇒ Object
:nodoc:.
-
#report(report_id) ⇒ Object
Returns details about the specified report.
-
#reports ⇒ Object
Returns list of reports and details accessible by the user account.
-
#users ⇒ Object
Returns list of users and details.
Constructor Details
#initialize(account, api_key) ⇒ WufooParty
Create a new WufooParty object
97 98 99 100 101 |
# File 'lib/wufoo_party.rb', line 97 def initialize(account, api_key) @account = account @api_key = api_key @field_numbers = {} end |
Instance Method Details
#form(form_id) ⇒ Object
Returns details about the specified form.
125 126 127 128 129 |
# File 'lib/wufoo_party.rb', line 125 def form(form_id) if f = get("forms/#{form_id}")['Forms'] Form.new(f.first['Url'], :party => self, :details => f.first) end end |
#forms ⇒ Object
Returns list of forms and details accessible by the user account.
104 105 106 107 108 |
# File 'lib/wufoo_party.rb', line 104 def forms get(:forms)['Forms'].map do |details| Form.new(details['Url'], :party => self, :details => details) end end |
#get(method, options = {}) ⇒ Object
:nodoc:
138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/wufoo_party.rb', line 138 def get(method, ={}) # :nodoc: .merge!(:basic_auth => {:username => @api_key}) url = "#{base_url}/#{method}.json" result = self.class.get(url, ) if result.is_a?(String) raise ConnectionError, result elsif result['HTTPCode'] raise HTTPError.new(result['HTTPCode'], result['Text']) else result end end |
#post(method, options = {}) ⇒ Object
:nodoc:
151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/wufoo_party.rb', line 151 def post(method, ={}) # :nodoc: .merge!(:basic_auth => {:username => @api_key}) url = "#{base_url}/#{method}.json" result = self.class.post(url, ) if result.is_a?(String) raise ConnectionError, result elsif result['HTTPCode'] raise HTTPError.new(result['HTTPCode'], result['Text']) else result end end |
#report(report_id) ⇒ Object
Returns details about the specified report.
132 133 134 135 136 |
# File 'lib/wufoo_party.rb', line 132 def report(report_id) if r = get("reports/#{report_id}")['Reports'] Form.new(r.first['Url'], :party => self, :details => r.first) end end |