Sha256: 103c8f6fceedc513de996b01143e834167c210a69b45c0150c52290be6fccd62

Contents?: true

Size: 815 Bytes

Versions: 2

Compression:

Stored size: 815 Bytes

Contents

module Workarea
  module GlobalE
    class UpdateOrderDispatch
      include Sidekiq::Worker

      def perform(id, tracking_number)
        domain = GlobalE.domains[GlobalE.environment]
        path = "/Order/UpdateOrderDispatchV2?merchantGUID=#{GlobalE.merchant_guid}"

        dispatch = UpdateOrderDispatchRequest.new(id, tracking_number: tracking_number)
        uri = URI("#{domain}#{path}")

        http = Net::HTTP.new(uri.host, uri.port).tap do |net_http|
          net_http.use_ssl = true
        end

        post = Net::HTTP::Post.new(path).tap do |request|
          request['Content-Type'] = 'application/json'
          request.body = dispatch.to_json
        end

        response = http.request(post)

        raise response.body unless response.is_a? Net::HTTPSuccess
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-global_e-1.3.0 app/workers/workarea/global_e/update_order_dispatch.rb
workarea-global_e-1.2.1 app/workers/workarea/global_e/update_order_dispatch.rb