~tim/wuparty

d5606fdf74e7c3adafb6c168c96d96d9093c8e31 — Joshua Siler 9 years ago e9f837f
added Login API support
1 files changed, 13 insertions(+), 0 deletions(-)

M lib/wuparty.rb
M lib/wuparty.rb => lib/wuparty.rb +13 -0
@@ 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.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