Class: PuppeteerEntity::Base

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/puppeteer_entity/base.rb

Direct Known Subclasses

Content, Pdf, Screenshot

Instance Method Summary collapse

Instance Method Details

#responseObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/puppeteer_entity/base.rb', line 14

def response
  url = url_with_query_params
  json = as_body_json
  retries = 0
  begin
    HTTP.headers(response_headers)
        .post(url, json:)
        .tap do |res|
      raise RequestError.new(res.body.to_s) unless res.status.success?
    rescue RequestError => e
      retries = retries + 1
      retries > retry_limit ? raise(e) : retry
    end
  end
end