Class: CloudscrapeClient::API

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudscrape_client/api.rb

Constant Summary collapse

InvalidApiKey =
Class.new(StandardError)
InvalidAccountId =
Class.new(StandardError)

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.delete(*args) ⇒ Object



22
23
24
# File 'lib/cloudscrape_client/api.rb', line 22

def self.delete(*args)
  new.delete(*args)
end

.get(*args) ⇒ Object



14
15
16
# File 'lib/cloudscrape_client/api.rb', line 14

def self.get(*args)
  new.get(*args)
end

.post(*args) ⇒ Object



18
19
20
# File 'lib/cloudscrape_client/api.rb', line 18

def self.post(*args)
  new.post(*args)
end

Instance Method Details

#delete(domain:, url:, content_type:, options: {}) ⇒ Object



39
40
41
42
# File 'lib/cloudscrape_client/api.rb', line 39

def delete(domain:, url:, content_type:, options: {})
  connection(domain: domain, content_type: content_type)
    .delete(URI.escape(url), options)
end

#get(domain:, url:, content_type:, options: {}) ⇒ Object



26
27
28
29
# File 'lib/cloudscrape_client/api.rb', line 26

def get(domain:, url:, content_type:, options: {})
  connection(domain: domain, content_type: content_type)
    .get(URI.escape(url), options)
end

#post(domain:, url:, content_type:, options: {}) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/cloudscrape_client/api.rb', line 31

def post(domain:, url:, content_type:, options: {})
  connection(domain: domain, content_type: content_type).post do |req|
    req.url URI.escape(url)
    req.headers["Content-Type"] = content_type.to_s
    req.body = options.to_json
  end
end