Class: GdsApi::LinkCheckerApi
- Defined in:
- lib/gds_api/link_checker_api.rb
Defined Under Namespace
Classes: BatchReport, LinkReport, MonitorReport
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#check(uri, synchronous: nil, checked_within: nil) ⇒ LinkReport
Checks whether a link is broken.
-
#create_batch(uris, checked_within: nil, webhook_uri: nil, webhook_secret_token: nil) ⇒ BatchReport
Create a batch of links to check.
-
#get_batch(id) ⇒ BatchReport
Get information about a batch.
-
#upsert_resource_monitor(links, app, reference) ⇒ MonitorReport
Update or create a set of links to be monitored for a resource.
Methods inherited from Base
#client, #create_client, #get_list, #initialize, #url_for_slug
Constructor Details
This class inherits a constructor from GdsApi::Base
Instance Method Details
#check(uri, synchronous: nil, checked_within: nil) ⇒ LinkReport
Checks whether a link is broken.
Makes a GET
request to the link checker api to check a link.
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/gds_api/link_checker_api.rb', line 23 def check(uri, synchronous: nil, checked_within: nil) params = { uri: uri, synchronous: synchronous, checked_within: checked_within, } response = get_json( "#{endpoint}/check" + query_string(params.delete_if { |_, v| v.nil? }), ) LinkReport.new(response.to_hash) end |
#create_batch(uris, checked_within: nil, webhook_uri: nil, webhook_secret_token: nil) ⇒ BatchReport
Create a batch of links to check.
Makes a POST
request to the link checker api to create a batch.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/gds_api/link_checker_api.rb', line 55 def create_batch(uris, checked_within: nil, webhook_uri: nil, webhook_secret_token: nil) payload = { uris: uris, checked_within: checked_within, webhook_uri: webhook_uri, webhook_secret_token: webhook_secret_token, } response = post_json( "#{endpoint}/batch", payload.delete_if { |_, v| v.nil? } ) BatchReport.new(response.to_hash) end |
#get_batch(id) ⇒ BatchReport
Get information about a batch.
Makes a GET
request to the link checker api to get a batch.
84 85 86 87 88 89 90 |
# File 'lib/gds_api/link_checker_api.rb', line 84 def get_batch(id) BatchReport.new( get_json( "#{endpoint}/batch/#{id}", ).to_hash, ) end |
#upsert_resource_monitor(links, app, reference) ⇒ MonitorReport
Update or create a set of links to be monitored for a resource.
Makes a POST
request to the link checker api to create a resource monitor.
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/gds_api/link_checker_api.rb', line 105 def upsert_resource_monitor(links, app, reference) payload = { links: links, app: app, reference: reference, } response = post_json("#{endpoint}/monitor", payload) MonitorReport.new(response.to_hash) end |