Sha256: adb422f601c9f56c55c8f22e1958276fb18fda7836a289885802f7ace44e6c14
Contents?: true
Size: 973 Bytes
Versions: 4
Compression:
Stored size: 973 Bytes
Contents
# frozen_string_literal: true require 'dry/monads/result' require 'friendly_shipping/bad_request' require 'rest-client' module FriendlyShipping module Services class Ups class Client extend Dry::Monads::Result::Mixin class << self def post(friendly_shipping_request) http_response = ::RestClient.post( friendly_shipping_request.url, friendly_shipping_request.body, friendly_shipping_request.headers ) Success(convert_to_friendly_response(http_response)) rescue ::RestClient::Exception => e Failure(e) end private def convert_to_friendly_response(http_response) FriendlyShipping::Response.new( status: http_response.code, body: http_response.body, headers: http_response.headers ) end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems