~tim/wuparty

2a47c43fc4e65ec999a9bf2e8ddab86b7824933e ā€” Tim Morgan 9 years ago e9f837f + 9de58bb
Merge pull request #6 from hiringthing/master

Added Login API support & Support for Metadata in Webhook calls
2 files changed, 29 insertions(+), 4 deletions(-)

M README.rdoc
M lib/wuparty.rb
M README.rdoc => README.rdoc +12 -0
@@ 53,12 53,24 @@ 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
    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.

M lib/wuparty.rb => lib/wuparty.rb +17 -4
@@ 93,6 93,19 @@ class WuParty
  ENDPOINT    = 'https://%s.wufoo.com/api/v3'
  API_VERSION = '3.0'

  # uses the Login API to fetch a user's API key
  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)
      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


@@ 128,8 141,8 @@ class WuParty
    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)


@@ 228,8 241,8 @@ class WuParty
      @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)