Documentation

Webhooks are great to know what is happening by simply listening on your server for things to happen. See bellow how you can use our API in regards to webhooks.

Fork me on GitHub
  • create
    Create a new webhook for the given url to catch the given events.
    ziggeo.webhooks().create(arguments = nil)
    
    1. target_url The url that will catch the events
    2. encoding Data encoding to be used by the webhook to send the events.
    3. events Comma-separated list of the events the webhook will catch. They must be valid webhook type events.
    This method returns string
    Example:
    =begin
      This script shows you how to create a webhook, which you'll later need to confirm.
    
      Parameters you need to pass:
        1. APP_TOKEN
        2. PRIVATE_KEY
        3. SERVER_URL
        4. EVENTS
      
      Example call:
        ruby webhooks_create.rb APP_TOKEN PRIVATE_KEY SERVER_URL video_create
        ruby webhooks_create.rb APP_TOKEN PRIVATE_KEY SERVER_URL video_create video_delete video_failed
    =end
    
    require_relative "../lib/Ziggeo"
    
    app_token, private_key, server_url = ARGV.shift(3)
    events_to_catch = ARGV.join(",")
    
    @ziggeo = Ziggeo.new(app_token, private_key)
    
    webhook_id = @ziggeo.webhooks.create(
      target_url: server_url,
      events: events_to_catch
    )
    
    puts webhook_id
    
  • confirm
    Confirm a webhook using its ID and the corresponding validation code.
    ziggeo.webhooks().confirm(arguments = nil)
    
    1. webhook_id Webhook ID that's returned in the creation call.
    2. validation_code Validation code that is sent to the webhook when created.
    This method returns string
    Example:
    =begin
      This script shows you how to confirm a webhook to start catching events.
    
      Parameters you need to pass:
        1. APP_TOKEN
        2. PRIVATE_KEY
        3. WEBHOOK_ID
        4. VALIDATION_CODE
      
      Example call:
        ruby webhooks_confirm.rb APP_TOKEN PRIVATE_KEY WEBHOOK_ID VALIDATION_CODE
    =end
    
    require_relative "../lib/Ziggeo"
    
    app_token, private_key, webhook_id, validation_code = ARGV
    
    @ziggeo = Ziggeo.new(app_token, private_key)
    
    response = @ziggeo.webhooks.confirm(
      webhook_id: webhook_id,
      validation_code: validation_code
    )
    
    puts response
    
  • delete
    Delete a webhook using its URL.
    ziggeo.webhooks().delete(arguments = nil)
    
    1. target_url The url that will catch the events
    This method returns string
    Example:
    =begin
      This script shows you how to delete a webhook.
    
      Parameters you need to pass:
        1. WEBHOOK_URL
        2. APP_TOKEN
        3. PRIVATE_KEY
      
      Example call:
        ruby webhooks_delete.rb WEBHOOK_ID APP_TOKEN PRIVATE_KEY
        ruby webhooks_delete.rb WEBHOOK_ID APP_TOKEN PRIVATE_KEY ENCRIPTION_KEY
    =end
    
    require_relative "../lib/Ziggeo"
    
    server_url = ARGV.shift()
    
    @ziggeo = Ziggeo.new(*ARGV)
    
    response = @ziggeo.webhooks.delete(
      target_url: server_url
    )
    
    puts response == "null" ? "Webhook deleted." : response