From d5606fdf74e7c3adafb6c168c96d96d9093c8e31 Mon Sep 17 00:00:00 2001 From: Joshua Siler Date: Tue, 17 Apr 2012 14:11:38 -0700 Subject: [PATCH 1/3] added Login API support --- lib/wuparty.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/wuparty.rb b/lib/wuparty.rb index 3526b13..ed1cc41 100644 --- a/lib/wuparty.rb +++ b/lib/wuparty.rb @@ -93,6 +93,19 @@ def initialize(code, message) # :nodoc: ENDPOINT = 'https://%s.wufoo.com/api/v3' API_VERSION = '3.0' + # uses the Login API to fetch a user's API key + def self.fetch_api_key(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 }}) + puts result + if result.is_a?(String) + raise ConnectionError, result + elsif result['HTTPCode'] + raise HTTPError.new(result['HTTPCode'], result['Text']) + else + result + end + end + # Create a new WuParty object def initialize(account, api_key) @account = account From e22ac3e3f7ee62bd7541e91b3e69a4a410982de5 Mon Sep 17 00:00:00 2001 From: Joshua Siler Date: Tue, 17 Apr 2012 14:17:12 -0700 Subject: [PATCH 2/3] updated docs --- README.rdoc | 6 ++++++ lib/wuparty.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 5c551fe..57d4fdd 100644 --- a/README.rdoc +++ b/README.rdoc @@ -59,6 +59,12 @@ Make sure you have latest version installed (1.0.0 or higher). result = wufoo.add_webhook(FORM_ID, 'http://www.postbin.org/zh9iy1') result = wufoo.delete_webhook(FORM_ID, result["WebHookPutResult"]["Hash"]) + # You can use the Login API (http://www.wufoo.com/docs/api/v3/login/), like so + result = WuParty.login(myIntegrationKey, users_email, users_password) + + # or + result = WuParty.login(myIntegrationKey, users_email, users_password, users_subdomain) + == Feedback I’d love to hear from you if you have suggestions for improvement, bug fixes, or whatever. diff --git a/lib/wuparty.rb b/lib/wuparty.rb index ed1cc41..4e25744 100644 --- a/lib/wuparty.rb +++ b/lib/wuparty.rb @@ -94,7 +94,7 @@ def initialize(code, message) # :nodoc: API_VERSION = '3.0' # uses the Login API to fetch a user's API key - def self.fetch_api_key(integration_key, email, password, account = nil) + 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 }}) puts result if result.is_a?(String) From 9de58bbcef5e97919568b8eb0ed2240c827cd851 Mon Sep 17 00:00:00 2001 From: Joshua Siler Date: Wed, 18 Apr 2012 19:26:32 -0700 Subject: [PATCH 3/3] added metadata flag to webhook calls --- README.rdoc | 6 ++++++ lib/wuparty.rb | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.rdoc b/README.rdoc index 57d4fdd..0a1be87 100644 --- a/README.rdoc +++ b/README.rdoc @@ -53,10 +53,16 @@ Make sure you have latest version installed (1.0.0 or higher). # Add a webhook to your Wufoo form. # Any submission to this form will now post to the given url. result = form.add_webhook('http://www.postbin.org/zh9iy1') + # Tell the webhook to include metadata in its postback + result = form.add_webhook('http://www.postbin.org/zh9iy1', true) + result = form.delete_webhook(result["WebHookPutResult"]["Hash"]) # Or, directly through wufoo: result = wufoo.add_webhook(FORM_ID, 'http://www.postbin.org/zh9iy1') + # Tell the webhook to include metadata in its postback + result = wufoo.add_webhook(FORM_ID, 'http://www.postbin.org/zh9iy1', true) + result = wufoo.delete_webhook(FORM_ID, result["WebHookPutResult"]["Hash"]) # You can use the Login API (http://www.wufoo.com/docs/api/v3/login/), like so diff --git a/lib/wuparty.rb b/lib/wuparty.rb index 4e25744..888b2ac 100644 --- a/lib/wuparty.rb +++ b/lib/wuparty.rb @@ -141,8 +141,8 @@ def form(form_id) end end - def add_webhook(form_id, url) - put("forms/#{form_id}/webhooks", :body => {'url' => url}) + def add_webhook(form_id, url, metadata = false) + put("forms/#{form_id}/webhooks", :body => {'url' => url, 'metadata' => metadata}) end def delete_webhook(form_id, webhook_hash) @@ -241,8 +241,8 @@ def [](id) @details[id] end - def add_webhook(url) - @party.add_webhook(@details["Hash"], url) + def add_webhook(url, metadata = false) + @party.add_webhook(@details["Hash"], url, metadata) end def delete_webhook(webhook_id)