lib/cloudscrape_client/dto.rb in cloudscrape-client-0.4.0 vs lib/cloudscrape_client/dto.rb in cloudscrape-client-0.5.1
- old
+ new
@@ -1,10 +1,14 @@
+# frozen_string_literal: true
+
require "cloudscrape_client/api"
require "cloudscrape_client/validate"
class CloudscrapeClient
class DTO
+ DEFAULT_CONTENT_TYPE = MIME::Types["application/json"].first
+
attr_reader :options
def initialize(options:)
@options = options
end
@@ -28,10 +32,11 @@
def response(method)
API.public_send(
method,
domain: domain,
url: endpoint,
+ content_type: content_type,
options: {
api_key: api_key,
format: "json"
}.merge(params)
).tap(&CloudscrapeClient::Validate).body
@@ -39,11 +44,15 @@
def params
{}
end
+ def content_type
+ DEFAULT_CONTENT_TYPE
+ end
+
def endpoint
- fail NotImplementedError, "Inheriting class must implement"
+ raise NotImplementedError, "Inheriting class must implement"
end
private
def domain