Class: IngramMicro::Client
- Inherits:
-
Object
- Object
- IngramMicro::Client
- Defined in:
- lib/ingram_micro/client.rb
Instance Attribute Summary collapse
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(url = api_root) ⇒ Client
constructor
A new instance of Client.
- #post(data) ⇒ Object
Constructor Details
#initialize(url = api_root) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 11 12 13 14 |
# File 'lib/ingram_micro/client.rb', line 6 def initialize(url=api_root) @uri = URI.parse(url) @conn = Faraday.new(url: uri) do |faraday| faraday.request :url_encoded faraday.response :logger, logger, bodies: log_request_body faraday.adapter Faraday.default_adapter faraday.proxy proxy if proxy end end |
Instance Attribute Details
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
4 5 6 |
# File 'lib/ingram_micro/client.rb', line 4 def conn @conn end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
4 5 6 |
# File 'lib/ingram_micro/client.rb', line 4 def uri @uri end |
Instance Method Details
#get ⇒ Object
16 17 18 |
# File 'lib/ingram_micro/client.rb', line 16 def get conn.get uri.request_uri end |
#post(data) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/ingram_micro/client.rb', line 20 def post(data) conn.post do |req| req.url uri.request_uri req.headers['Content-Type'] = 'application/xml' req.body = data end end |