Sha256: 0180e38bfb6e956146a1a50ab2329a7eadb2d009c88e35bfd683a6d49d44c065
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
module Workarea module ShipStation class Webhook class ItemShipNotify < Webhook class ShipStationItemShipNotifyError < StandardError; end def process uri = URI(attrs["resource_url"]) rest_endpoint = "https://" + uri.host query_hash = Rack::Utils.parse_query(uri.query) response = gateway(rest_endpoint).get_shipping(query_hash) raise ShipStationItemShipNotifyError, response.body["ExceptionMessage"] unless response.success? response.body["shipments"].each do |shipment| fulfillment = Workarea::Fulfillment.find(shipment["orderKey"]) tracking_number = shipment["trackingNumber"] items = shipment["shipmentItems"].map { |item| { id: item["lineItemKey"], quantity: item["quantity"] } } fulfillment.ship_items(tracking_number, items) end end private def gateway(rest_endpoint) Workarea::ShipStation.gateway(rest_endpoint) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
workarea-ship_station-1.0.1 | app/services/workarea/ship_station/webhook/item_ship_notify.rb |
workarea-ship_station-1.0.0 | app/services/workarea/ship_station/webhook/item_ship_notify.rb |