Class: CloudScrape::API

Inherits:
Object
  • Object
show all
Defined in:
lib/cloud_scrape/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



20
21
22
# File 'lib/cloud_scrape/api.rb', line 20

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

.get(*args) ⇒ Object



12
13
14
# File 'lib/cloud_scrape/api.rb', line 12

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

.post(*args) ⇒ Object



16
17
18
# File 'lib/cloud_scrape/api.rb', line 16

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

Instance Method Details

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



36
37
38
# File 'lib/cloud_scrape/api.rb', line 36

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

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



24
25
26
# File 'lib/cloud_scrape/api.rb', line 24

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

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



28
29
30
31
32
33
34
# File 'lib/cloud_scrape/api.rb', line 28

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