Class: ScreenshotFreeAPI::Resources::Monitors
- Inherits:
-
Object
- Object
- ScreenshotFreeAPI::Resources::Monitors
- Defined in:
- lib/screenshotfreeapi/resources/monitors.rb
Overview
App monitoring — schedule recurring captures and receive diff alerts.
Monitors run on a cron schedule and alert you when an app’s screenshots change (e.g., new version, UI refresh). Requires a BUSINESS+ plan.
All methods require a management JWT passed as ‘jwt:`.
Instance Method Summary collapse
-
#create(jwt:, app_name:, platform:, schedule:, webhook_url: nil, **options) ⇒ Hash
Create a new app monitor.
-
#delete(jwt:, monitor_id:) ⇒ Hash
Delete a monitor.
-
#get(jwt:, monitor_id:) ⇒ Hash
Get a single monitor’s details.
-
#history(jwt:, monitor_id:, limit: nil, offset: nil) ⇒ Hash
Retrieve the run history and diff results for a monitor.
-
#initialize(http) ⇒ Monitors
constructor
A new instance of Monitors.
-
#list(jwt:) ⇒ Array<Hash>
List all monitors for the authenticated user.
Constructor Details
#initialize(http) ⇒ Monitors
Returns a new instance of Monitors.
12 13 14 |
# File 'lib/screenshotfreeapi/resources/monitors.rb', line 12 def initialize(http) @http = http end |
Instance Method Details
#create(jwt:, app_name:, platform:, schedule:, webhook_url: nil, **options) ⇒ Hash
Create a new app monitor.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/screenshotfreeapi/resources/monitors.rb', line 26 def create(jwt:, app_name:, platform:, schedule:, webhook_url: nil, **) body = { appName: app_name, platform: platform, schedule: schedule, webhookUrl: webhook_url }.compact.merge() @http.request(:post, "/monitors/app", body: body, auth_header: "Bearer #{jwt}") end |
#delete(jwt:, monitor_id:) ⇒ Hash
Delete a monitor.
62 63 64 |
# File 'lib/screenshotfreeapi/resources/monitors.rb', line 62 def delete(jwt:, monitor_id:) @http.request(:delete, "/monitors/app/#{monitor_id}", auth_header: "Bearer #{jwt}") end |
#get(jwt:, monitor_id:) ⇒ Hash
Get a single monitor’s details.
52 53 54 |
# File 'lib/screenshotfreeapi/resources/monitors.rb', line 52 def get(jwt:, monitor_id:) @http.request(:get, "/monitors/app/#{monitor_id}", auth_header: "Bearer #{jwt}") end |
#history(jwt:, monitor_id:, limit: nil, offset: nil) ⇒ Hash
Retrieve the run history and diff results for a monitor.
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/screenshotfreeapi/resources/monitors.rb', line 74 def history(jwt:, monitor_id:, limit: nil, offset: nil) query = {} query[:limit] = limit if limit query[:offset] = offset if offset @http.request( :get, "/monitors/app/#{monitor_id}/history", query: query, auth_header: "Bearer #{jwt}" ) end |
#list(jwt:) ⇒ Array<Hash>
List all monitors for the authenticated user.
42 43 44 |
# File 'lib/screenshotfreeapi/resources/monitors.rb', line 42 def list(jwt:) @http.request(:get, "/monitors/app", auth_header: "Bearer #{jwt}") end |