Class: PartyResource::Connector::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/party_resource/connector/base.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, options) ⇒ Base

Returns a new instance of Base.



7
8
9
10
11
12
# File 'lib/party_resource/connector/base.rb', line 7

def initialize(name, options)
  set_base_uri(options)
  set_basic_auth(options)
  set_headers(options)
  @name = name
end

Instance Method Details

#fetch(request) ⇒ Object



20
21
22
23
24
# File 'lib/party_resource/connector/base.rb', line 20

def fetch(request)
  response = send_request(request)
  return response if successful_response?(response.code)
  raise PartyResource::Exceptions::ConnectionError.build(response)
end

#optionsObject



26
27
28
# File 'lib/party_resource/connector/base.rb', line 26

def options
  @options ||= {}
end

#send_request(request) ⇒ Object



14
15
16
17
18
# File 'lib/party_resource/connector/base.rb', line 14

def send_request(request)
  params = request.http_data(options)
  log_request(request, params)
  HTTParty.send(request.verb, request.path, params)
end