~tim/wuparty

1205d4ea9e8c455fe8702bc8438317181bafae64 — Aaron Oman 10 years ago 75c6e7c
Add add/delete webhook methods to the form itself, for added convenience.
2 files changed, 12 insertions(+), 2 deletions(-)

M README.rdoc
M lib/wuparty.rb
M README.rdoc => README.rdoc +4 -2
@@ 52,9 52,11 @@ 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 = wufoo.add_webhook(FORM_ID, 'http://www.postbin.org/zh9iy1')
    result = form.add_webhook('http://www.postbin.org/zh9iy1')
    result = form.delete_webhook(result["WebHookPutResult"]["Hash"])

    # Remove the specified webhook from your Wufoo form.
    # Or, directly through wufoo:
    result = wufoo.add_webhook(FORM_ID, 'http://www.postbin.org/zh9iy1')
    result = wufoo.delete_webhook(FORM_ID, result["WebHookPutResult"]["Hash"])
    
== Feedback

M lib/wuparty.rb => lib/wuparty.rb +8 -0
@@ 228,6 228,14 @@ class WuParty
      @details[id]
    end

    def add_webhook(url)
      @party.add_webhook(@details["Hash"], url)
    end

    def delete_webhook(webhook_id)
      @party.delete_webhook(@details["Hash"], webhook_id)
    end

    # Returns fields and subfields, as a flattened array, e.g.
    #   [{'ID' => 'Field1', 'Title' => 'Name - First', 'Type' => 'shortname', 'Required' => true }, # (subfield)
    #    {'ID' => 'Field2', 'Title' => 'Name - Last',  'Type' => 'shortname', 'Required' => true }, # (subfield)