~tim/wuparty

d7ca044828858006090f1ac38f33a7914e882bd8 — Tim Morgan 8 years ago 8ddc94c + b0496ee
Merge pull request #8 from applidget/master

Add handshakeKey parameter to add_webhook method
2 files changed, 13 insertions(+), 4 deletions(-)

M lib/wuparty.rb
M test/wuparty_test.rb
M lib/wuparty.rb => lib/wuparty.rb +4 -4
@@ 140,8 140,8 @@ class WuParty
    end
  end

  def add_webhook(form_id, url, metadata = false)
    put("forms/#{form_id}/webhooks", :body => {'url' => url, 'metadata' => metadata})
  def add_webhook(form_id, url, metadata = false, handshakeKey = "")
    put("forms/#{form_id}/webhooks", :body => {'url' => url, 'handshakeKey' => handshakeKey, 'metadata' => metadata})
  end

  def delete_webhook(form_id, webhook_hash)


@@ 240,8 240,8 @@ class WuParty
      @details[id]
    end

    def add_webhook(url, metadata = false)
      @party.add_webhook(@details["Hash"], url, metadata)
    def add_webhook(url, metadata = false, handshakeKey = "")
      @party.add_webhook(@details["Hash"], url, metadata, handshakeKey)
    end

    def delete_webhook(webhook_id)

M test/wuparty_test.rb => test/wuparty_test.rb +9 -0
@@ 96,5 96,14 @@ class WuPartyTest < Test::Unit::TestCase
    assert form.entries([['Field2', 'Is_equal_to', 'Morgan']]).any?
    assert_equal 1, form.entries([['EntryId', 'Is_equal_to', id]]).length
  end
  
  def test_add_webhook
    # test with optional parameters
    response = @wufoo.add_webhook(@form_id, "http://#{ENV['WUFOO_ACCOUNT']}.com/#{@form_id}", true, "handshakeKey01")
    assert_match /[a-z0-9]{6}/i, response['WebHookPutResult']['Hash']
    # test without optional parameters
    response = @wufoo.add_webhook(@form_id, "http://#{ENV['WUFOO_ACCOUNT']}.com/#{@form_id}-2")
    assert_match /[a-z0-9]{6}/i, response['WebHookPutResult']['Hash']
  end

end