Class: ScreenshotFreeAPI::Resources::Integrations

Inherits:
Object
  • Object
show all
Defined in:
lib/screenshotfreeapi/resources/integrations.rb

Overview

Third-party integration endpoints.

Currently supports Zapier REST Hooks for no-code workflow automation. All methods use API key authentication (no JWT required).

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ Integrations

Returns a new instance of Integrations.



10
11
12
# File 'lib/screenshotfreeapi/resources/integrations.rb', line 10

def initialize(http)
  @http = http
end

Instance Method Details

#zapier_subscribe(target_url:, event:, **options) ⇒ Hash

Register a Zapier webhook subscription (REST Hook subscribe).

Zapier calls this endpoint when a Zap is turned on. You can also call it directly to register any webhook for screenshot-complete events.

Parameters:

  • target_url (String)

    URL Zapier will POST events to

  • event (String)

    Event type to subscribe to, e.g. “screenshot.completed”

  • options (Hash)

    Additional subscription options

Returns:

  • (Hash)

    { “id”, “targetUrl”, “event”, “createdAt” }



24
25
26
27
# File 'lib/screenshotfreeapi/resources/integrations.rb', line 24

def zapier_subscribe(target_url:, event:, **options)
  body = { targetUrl: target_url, event: event }.merge(options)
  @http.request(:post, "/integrations/zapier/subscribe", body: body)
end

#zapier_triggers(event:) ⇒ Array<Hash>

Retrieve a sample payload for a Zapier trigger event.

Zapier uses this to show users a preview of the data they can map in their Zap.

Parameters:

  • event (String)

    Event type, e.g. “screenshot.completed”

Returns:

  • (Array<Hash>)

    Array of sample event payloads (Zapier polling format)



47
48
49
# File 'lib/screenshotfreeapi/resources/integrations.rb', line 47

def zapier_triggers(event:)
  @http.request(:get, "/integrations/zapier/triggers/#{event}")
end

#zapier_unsubscribe(subscription_id:) ⇒ Hash

Unregister a Zapier webhook subscription (REST Hook unsubscribe).

Zapier calls this when the Zap is turned off.

Parameters:

  • subscription_id (String)

    ID returned by ‘zapier_subscribe`

Returns:

  • (Hash)

    Confirmation object



36
37
38
# File 'lib/screenshotfreeapi/resources/integrations.rb', line 36

def zapier_unsubscribe(subscription_id:)
  @http.request(:delete, "/integrations/zapier/unsubscribe/#{subscription_id}")
end