Class: NubankSdk::Client::HTTP
- Inherits:
-
Object
- Object
- NubankSdk::Client::HTTP
- Defined in:
- lib/nubank_sdk/client.rb
Overview
create a new connection with the given url in Faraday
Instance Method Summary collapse
-
#get(path) ⇒ Faraday::Response
make get on connection with the given path.
-
#initialize(base_url, connection_adapter = nil) ⇒ HTTP
constructor
create a new connection with the given url in Faraday.
-
#post(path, body) ⇒ Faraday::Response
make put on connection with the given path.
Constructor Details
#initialize(base_url, connection_adapter = nil) ⇒ HTTP
create a new connection with the given url in Faraday
30 31 32 33 34 35 |
# File 'lib/nubank_sdk/client.rb', line 30 def initialize(base_url, connection_adapter = nil) @connection = Faraday.new(url: base_url) do |faraday| faraday.adapter(*connection_adapter) if connection_adapter faraday.adapter Faraday.default_adapter unless connection_adapter end end |
Instance Method Details
#get(path) ⇒ Faraday::Response
make get on connection with the given path
58 59 60 |
# File 'lib/nubank_sdk/client.rb', line 58 def get(path) @connection.get(path) end |
#post(path, body) ⇒ Faraday::Response
make put on connection with the given path
44 45 46 47 48 49 50 |
# File 'lib/nubank_sdk/client.rb', line 44 def post(path, body) @connection.post(path) do |req| req.headers['Content-Type'] = 'application/json' req.headers['X-Correlation-Id'] = 'WEB-APP.pewW9' req.body = body.to_json end end |