Class: Shipwire::Request
- Inherits:
-
Object
- Object
- Shipwire::Request
- Defined in:
- lib/shipwire/request.rb
Constant Summary collapse
- API_VERSION =
3
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(method: :get, path: '', params: {}, body: {}) ⇒ Request
constructor
A new instance of Request.
- #send ⇒ Object
Constructor Details
#initialize(method: :get, path: '', params: {}, body: {}) ⇒ Request
Returns a new instance of Request.
11 12 13 14 15 16 17 18 |
# File 'lib/shipwire/request.rb', line 11 def initialize(method: :get, path: '', params: {}, body: {}) @method = method @path = path @params = params @body = body @connection = build_connection end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
9 10 11 |
# File 'lib/shipwire/request.rb', line 9 def body @body end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
9 10 11 |
# File 'lib/shipwire/request.rb', line 9 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/shipwire/request.rb', line 9 def path @path end |
Class Method Details
.send(**args) ⇒ Object
3 4 5 |
# File 'lib/shipwire/request.rb', line 3 def self.send(**args) new(**args).send end |
Instance Method Details
#send ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/shipwire/request.rb', line 20 def send Response.new(underlying_response: make_request) rescue Faraday::ConnectionFailed Response.new(error_summary: 'Unable to connect to Shipwire') rescue Faraday::TimeoutError Response.new(error_summary: 'Shipwire connection timeout') end |