Class: WuParty
Defined Under Namespace
Classes: ConnectionError, HTTPError
Constant Summary collapse
- 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, handshake_key = '') ⇒ 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, domain: 'wufoo.com', account_prefix: nil) ⇒ 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, domain: 'wufoo.com', account_prefix: nil) ⇒ WuParty
Create a new WuParty object
48 49 50 51 52 53 54 |
# File 'lib/wuparty.rb', line 48 def initialize(account, api_key, domain: 'wufoo.com', account_prefix: nil) @account = account @api_key = api_key @domain = domain @account_prefix = account_prefix || @account @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
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/wuparty.rb', line 32 def self.login(integration_key, email, password, account = nil) result = post( 'https://wufoo.com/api/v3/login.json', body: { integrationKey: integration_key, email: email, password: password, subdomain: account } ) raise ConnectionError, result if result.is_a?(String) raise HTTPError.new(result['HTTPCode'], result['Text']) if result['HTTPCode'] result end |
Instance Method Details
#add_webhook(form_id, url, metadata = false, handshake_key = '') ⇒ Object
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/wuparty.rb', line 83 def add_webhook(form_id, url, = false, handshake_key = '') put( "forms/#{form_id}/webhooks", body: { 'url' => url, 'handshakeKey' => handshake_key, 'metadata' => } ) end |
#delete(method, options = {}) ⇒ Object
:nodoc:
116 117 118 |
# File 'lib/wuparty.rb', line 116 def delete(method, = {}) # :nodoc: handle_http_verb(:delete, method, ) end |
#delete_webhook(form_id, webhook_hash) ⇒ Object
94 95 96 |
# File 'lib/wuparty.rb', line 94 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.
78 79 80 81 |
# File 'lib/wuparty.rb', line 78 def form(form_id) return unless (f = get("forms/#{form_id}")['Forms']) Form.new(f.first['Url'], party: self, details: f.first) end |
#forms ⇒ Object
Returns list of forms and details accessible by the user account.
57 58 59 60 61 |
# File 'lib/wuparty.rb', line 57 def forms get(:forms)['Forms'].map do |details| Form.new(details['Url'], party: self, details: details) end end |
#get(method, options = {}) ⇒ Object
:nodoc:
104 105 106 |
# File 'lib/wuparty.rb', line 104 def get(method, = {}) # :nodoc: handle_http_verb(:get, method, ) end |
#post(method, options = {}) ⇒ Object
:nodoc:
108 109 110 |
# File 'lib/wuparty.rb', line 108 def post(method, = {}) # :nodoc: handle_http_verb(:post, method, ) end |
#put(method, options = {}) ⇒ Object
:nodoc:
112 113 114 |
# File 'lib/wuparty.rb', line 112 def put(method, = {}) # :nodoc: handle_http_verb(:put, method, ) end |
#report(report_id) ⇒ Object
Returns details about the specified report.
99 100 101 102 |
# File 'lib/wuparty.rb', line 99 def report(report_id) return unless (r = get("reports/#{report_id}")['Reports']) Report.new(r.first['Url'], party: self, details: r.first) end |
#reports ⇒ Object
Returns list of reports and details accessible by the user account.
64 65 66 67 68 |
# File 'lib/wuparty.rb', line 64 def reports get(:reports)['Reports'].map do |details| Report.new(details['Url'], party: self, details: details) end end |
#users ⇒ Object
Returns list of users and details.
71 72 73 74 75 |
# File 'lib/wuparty.rb', line 71 def users get(:users)['Users'].map do |details| User.new(details['Url'], party: self, details: details) end end |