Class: SearchmetricsClient::Request

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/searchmetrics_client/request.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query) ⇒ Request

Returns a new instance of Request.



20
21
22
23
# File 'lib/searchmetrics_client/request.rb', line 20

def initialize(query)
  @query = query
  @url = build_url
end

Instance Attribute Details

#queryObject (readonly)

Returns the value of attribute query.



6
7
8
# File 'lib/searchmetrics_client/request.rb', line 6

def query
  @query
end

#responseObject (readonly)

Returns the value of attribute response.



6
7
8
# File 'lib/searchmetrics_client/request.rb', line 6

def response
  @response
end

#urlObject (readonly)

Returns the value of attribute url.



6
7
8
# File 'lib/searchmetrics_client/request.rb', line 6

def url
  @url
end

Class Method Details

.send_request(query) ⇒ Object



11
12
13
# File 'lib/searchmetrics_client/request.rb', line 11

def self.send_request(query)
  new(query).send_request
end

.send_request_from_hash(hash) ⇒ Object



15
16
17
18
# File 'lib/searchmetrics_client/request.rb', line 15

def self.send_request_from_hash(hash)
  query = SearchmetricsClient::Query.from_hash(hash)
  SearchmetricsClient::Request.send_request(query)
end

Instance Method Details

#send_requestObject



25
26
27
28
29
30
31
# File 'lib/searchmetrics_client/request.rb', line 25

def send_request
  check_credentials
  result = Client.instance.public_send(method, url)
  @response = SearchmetricsClient::Response.new(self, result)
rescue OAuth2::Error => e
  check_errors(e.response)
end