Class: PartyResource::Connector::Base
- Inherits:
-
Object
- Object
- PartyResource::Connector::Base
- Defined in:
- lib/party_resource/connector/base.rb
Instance Method Summary collapse
- #fetch(request) ⇒ Object
-
#initialize(name, options) ⇒ Base
constructor
A new instance of Base.
- #options ⇒ Object
- #send_request(request) ⇒ Object
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, ) set_base_uri() set_basic_auth() set_headers() @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 |
#options ⇒ Object
26 27 28 |
# File 'lib/party_resource/connector/base.rb', line 26 def @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() log_request(request, params) HTTParty.send(request.verb, request.path, params) end |