Class: Bart::Connection::HTTPartyAdapter
- Inherits:
-
Object
- Object
- Bart::Connection::HTTPartyAdapter
- Includes:
- HTTParty
- Defined in:
- lib/bart_api/connection_adapters/httparty_adapter.rb
Instance Method Summary collapse
- #defaults ⇒ Object
- #get(endpoint, opts = {}, &block) ⇒ Object
-
#initialize(config) ⇒ HTTPartyAdapter
constructor
A new instance of HTTPartyAdapter.
- #post(endpoint, opts = {}, &block) ⇒ Object
Constructor Details
#initialize(config) ⇒ HTTPartyAdapter
Returns a new instance of HTTPartyAdapter.
10 11 12 13 14 15 |
# File 'lib/bart_api/connection_adapters/httparty_adapter.rb', line 10 def initialize config self.class.base_uri config.base_uri # Write debug information to the configured output stream self.class.debug_output config.debug_output @config = config end |
Instance Method Details
#defaults ⇒ Object
17 18 19 20 21 |
# File 'lib/bart_api/connection_adapters/httparty_adapter.rb', line 17 def defaults { query: { key: @config.api_key } } end |
#get(endpoint, opts = {}, &block) ⇒ Object
23 24 25 |
# File 'lib/bart_api/connection_adapters/httparty_adapter.rb', line 23 def get endpoint, opts={}, &block self.class.get(endpoint, defaults.deep_merge(opts), &block).parsed_response end |
#post(endpoint, opts = {}, &block) ⇒ Object
27 28 29 |
# File 'lib/bart_api/connection_adapters/httparty_adapter.rb', line 27 def post endpoint, opts={}, &block self.class.post(endpoint, defaults.deep_merge(opts), &block).parsed_response end |