Class: Datahen::Client::ScraperVar

Inherits:
Base
  • Object
show all
Defined in:
lib/datahen/client/scraper_var.rb

Constant Summary

Constants inherited from Base

Base::CHECK_EMPTY_BODY, Base::CHECK_NIL, Base::DEFAULT_RETRY_LIMIT

Instance Method Summary collapse

Methods inherited from Base

#auth_token, #auth_token=, #default_retry_limit, #env_api_url, env_auth_token, env_ignore_ssl, #ignore_ssl, #initialize, #left_merge, random_delay, #retry

Constructor Details

This class inherits a constructor from Datahen::Client::Base

Instance Method Details

#all(scraper_name, opts = {}) ⇒ Object



9
10
11
12
# File 'lib/datahen/client/scraper_var.rb', line 9

def all(scraper_name, opts={})
  params = @options.merge opts
  self.class.get("/scrapers/#{scraper_name}/vars", params)
end

#find(scraper_name, var_name) ⇒ Object



5
6
7
# File 'lib/datahen/client/scraper_var.rb', line 5

def find(scraper_name, var_name)
  self.class.get("/scrapers/#{scraper_name}/vars/#{var_name}", @options)
end

#set(scraper_name, var_name, value, opts = {}) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/datahen/client/scraper_var.rb', line 14

def set(scraper_name, var_name, value, opts={})
  body = {}
  body[:value] = value
  body[:secret] = opts[:secret] if opts[:secret]
  params = @options.merge({body: body.to_json})
  self.class.put("/scrapers/#{scraper_name}/vars/#{var_name}", params)
end

#unset(scraper_name, var_name, opts = {}) ⇒ Object



22
23
24
25
# File 'lib/datahen/client/scraper_var.rb', line 22

def unset(scraper_name, var_name, opts={})
  params = @options.merge(opts)
  self.class.delete("/scrapers/#{scraper_name}/vars/#{var_name}", params)
end