Class: FriendlyShipping::Services::ShipEngine::ParseVoidResponse
- Inherits:
-
Object
- Object
- FriendlyShipping::Services::ShipEngine::ParseVoidResponse
- Extended by:
- Dry::Monads::Result::Mixin
- Defined in:
- lib/friendly_shipping/services/ship_engine/parse_void_response.rb
Overview
Parses the API response for voiding a label.
Class Method Summary collapse
-
.call(request:, response:) ⇒ Success<ApiResult<String>>, Failure<ApiResult<String>>
The success or failure message.
Class Method Details
.call(request:, response:) ⇒ Success<ApiResult<String>>, Failure<ApiResult<String>>
Returns the success or failure message.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/friendly_shipping/services/ship_engine/parse_void_response.rb', line 13 def self.call(request:, response:) parsed_json = JSON.parse(response.body) approved, = parsed_json["approved"], parsed_json["message"] if approved Success( ApiResult.new(, original_request: request, original_response: response) ) else Failure( ApiResult.new(, original_request: request, original_response: response) ) end end |