Class: Access::Request

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/access/request.rb

Instance Method Summary collapse

Instance Method Details

#get(path, api_type, options = {}, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/access/request.rb', line 5

def get(path, api_type, options={}, &block)
  url = set_base(api_type, path)
  results = self.class.get(url, headers: headers(options[:access_token]), query: options, timeout: (options[:access_timeout] || 3))
  if should_return_json?(options[:return_json])
    hashify_results?(options[:hashify]) ? results.hashify : results
  else
    block.call results
  end
rescue Net::ReadTimeout, Net::OpenTimeout
  # block.call({"message"=>"Request Timeout Error", "status"=>408})
  raise Access::Error::Timeout
end

#get_for_filter(path, api_type, filter, options = {}, &block) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/access/request.rb', line 18

def get_for_filter(path, api_type, filter, options={}, &block)
  url = set_base(api_type, path)
  results = self.class.get(url, headers: headers(options[:access_token]), body: filter, timeout: (options[:access_timeout] || 3))
  if should_return_json?(options[:return_json])
    hashify_results?(options[:hashify]) ? results.hashify : results
  else
    block.call results
  end
end