Module: Snap::Client
- Included in:
- Api::Outbound, Api::ShipmentStatus, Api::Shipments, Api::StockTotals
- Defined in:
- lib/snap/client.rb
Overview
Encapsulates the configuration of each client before JIT before requests are made. This allows us to use our configuration which won’t have been available until runtime, not load time.
Instance Method Summary collapse
- #client ⇒ Object
- #delete(*args, &block) ⇒ Object
- #get(*args, &block) ⇒ Object
- #post(*args, &block) ⇒ Object
- #put(*args, &block) ⇒ Object
- #wrap_response ⇒ Object
Instance Method Details
#client ⇒ Object
6 7 8 9 10 |
# File 'lib/snap/client.rb', line 6 def client base_uri Snap.config.endpoint basic_auth(Snap.config.username, Snap.config.password) self end |
#delete(*args, &block) ⇒ Object
24 25 26 27 28 |
# File 'lib/snap/client.rb', line 24 def delete(*args, &block) wrap_response do super(*args, &block) end end |
#get(*args, &block) ⇒ Object
12 13 14 15 16 |
# File 'lib/snap/client.rb', line 12 def get(*args, &block) wrap_response do super(*args, &block) end end |
#post(*args, &block) ⇒ Object
18 19 20 21 22 |
# File 'lib/snap/client.rb', line 18 def post(*args, &block) wrap_response do super(*args, &block) end end |
#put(*args, &block) ⇒ Object
30 31 32 33 34 |
# File 'lib/snap/client.rb', line 30 def put(*args, &block) wrap_response do super(*args, &block) end end |
#wrap_response ⇒ Object
36 37 38 |
# File 'lib/snap/client.rb', line 36 def wrap_response Snap::Response.new(yield, model) end |