Class: GdsApi::LinkCheckerApi
- Defined in:
- lib/gds_api/link_checker_api.rb
Defined Under Namespace
Classes: BatchReport, LinkReport
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.
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:, synchronous:, 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:, checked_within:, webhook_uri:, 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 |