Class: BankExchangeApi::Connection
- Inherits:
-
Object
- Object
- BankExchangeApi::Connection
- Defined in:
- lib/bank_exchange_api/connection.rb
Constant Summary collapse
- HOST =
'api.bank.exchange'.freeze
- PORT =
80.freeze
Instance Attribute Summary collapse
-
#cli ⇒ Object
readonly
Returns the value of attribute cli.
Instance Method Summary collapse
- #get(uri) ⇒ Object
- #headers ⇒ Object
-
#initialize(cli) ⇒ Connection
constructor
A new instance of Connection.
- #transport ⇒ Object
Constructor Details
#initialize(cli) ⇒ Connection
Returns a new instance of Connection.
11 12 13 |
# File 'lib/bank_exchange_api/connection.rb', line 11 def initialize(cli) @cli = cli end |
Instance Attribute Details
#cli ⇒ Object (readonly)
Returns the value of attribute cli.
9 10 11 |
# File 'lib/bank_exchange_api/connection.rb', line 9 def cli @cli end |
Instance Method Details
#get(uri) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/bank_exchange_api/connection.rb', line 28 def get(uri) bm :GET, uri do transport.get(uri, headers).tap do |http| error(uri, http) unless http.is_a?(Net::HTTPOK) end end end |
#headers ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/bank_exchange_api/connection.rb', line 19 def headers { 'Accept' => 'application/json', 'X-Api-Token' => cli.config.api_token!, 'X-Client' => 'bank_exchange_ruby_api', 'X-Client-Version' => VERSION } end |