Class: WuParty
Overview
:startdoc:
Defined Under Namespace
Classes: ConnectionError, Entity, Form, HTTPError, Report, User
Constant Summary collapse
- VERSION =
'1.2.3'
- ENDPOINT =
'https://%s.wufoo.com/api/v3'
- API_VERSION =
'3.0'
Class Method Summary collapse
-
.login(integration_key, email, password, account = nil) ⇒ Object
uses the Login API to fetch a user’s API key.
Instance Method Summary collapse
- #add_webhook(form_id, url, metadata = false, handshakeKey = "") ⇒ Object
-
#delete(method, options = {}) ⇒ Object
:nodoc:.
- #delete_webhook(form_id, webhook_hash) ⇒ Object
-
#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) ⇒ WuParty
constructor
Create a new WuParty object.
-
#post(method, options = {}) ⇒ Object
:nodoc:.
-
#put(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) ⇒ WuParty
Create a new WuParty object
109 110 111 112 113 |
# File 'lib/wuparty.rb', line 109 def initialize(account, api_key) @account = account @api_key = api_key @field_numbers = {} end |
Class Method Details
.login(integration_key, email, password, account = nil) ⇒ Object
uses the Login API to fetch a user’s API key
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/wuparty.rb', line 97 def self.login(integration_key, email, password, account = nil) result = self.post("https://wufoo.com/api/v3/login.json", { :body => { :integrationKey => integration_key, :email => email, :password => password, :subdomain => account }}) if result.is_a?(String) raise ConnectionError, result elsif result['HTTPCode'] raise HTTPError.new(result['HTTPCode'], result['Text']) else result end end |
Instance Method Details
#add_webhook(form_id, url, metadata = false, handshakeKey = "") ⇒ Object
143 144 145 |
# File 'lib/wuparty.rb', line 143 def add_webhook(form_id, url, = false, handshakeKey = "") put("forms/#{form_id}/webhooks", :body => {'url' => url, 'handshakeKey' => handshakeKey, 'metadata' => }) end |
#delete(method, options = {}) ⇒ Object
:nodoc:
170 171 172 |
# File 'lib/wuparty.rb', line 170 def delete(method, ={}) # :nodoc: handle_http_verb(:delete, method, ) end |
#delete_webhook(form_id, webhook_hash) ⇒ Object
147 148 149 |
# File 'lib/wuparty.rb', line 147 def delete_webhook(form_id, webhook_hash) delete("forms/#{form_id}/webhooks/#{webhook_hash}") end |
#form(form_id) ⇒ Object
Returns details about the specified form.
137 138 139 140 141 |
# File 'lib/wuparty.rb', line 137 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.
116 117 118 119 120 |
# File 'lib/wuparty.rb', line 116 def forms get(:forms)['Forms'].map do |details| Form.new(details['Url'], :party => self, :details => details) end end |
#get(method, options = {}) ⇒ Object
:nodoc:
158 159 160 |
# File 'lib/wuparty.rb', line 158 def get(method, ={}) # :nodoc: handle_http_verb(:get, method, ) end |
#post(method, options = {}) ⇒ Object
:nodoc:
162 163 164 |
# File 'lib/wuparty.rb', line 162 def post(method, ={}) # :nodoc: handle_http_verb(:post, method, ) end |
#put(method, options = {}) ⇒ Object
:nodoc:
166 167 168 |
# File 'lib/wuparty.rb', line 166 def put(method, ={}) # :nodoc: handle_http_verb(:put, method, ) end |
#report(report_id) ⇒ Object
Returns details about the specified report.
152 153 154 155 156 |
# File 'lib/wuparty.rb', line 152 def report(report_id) if r = get("reports/#{report_id}")['Reports'] Report.new(r.first['Url'], :party => self, :details => r.first) end end |