Class: Shipping::ShipsuranceClient

Inherits:
BaseService show all
Defined in:
app/services/shipping/shipsurance_client.rb

Overview

Faraday-backed HTTP client for the Shipsurance (DSI) Carrier Insurance API.

Handles credential injection, URL routing (record vs void), and
form-encoded POST delivery for both production and sandbox environments.

The record and void endpoints live on different subdomains; this client
resolves the correct void base automatically from the configured base_url.

Constant Summary collapse

RECORD_PATH =
'/dsi_recordShipment.aspx'
VOID_PATH =
'/VoidShipment.aspx'

Instance Method Summary collapse

Methods inherited from BaseService

#initialize, #log_debug, #log_error, #log_info, #log_warning, #logger, #options, #process, #tagged_logger

Constructor Details

This class inherits a constructor from BaseService

Instance Method Details

#record_shipment(params) ⇒ String

Record a new shipment for insurance coverage.

Parameters:

  • params (Hash)

    shipment-specific fields (recordSourceIdentifier,
    extCarrierId, trackingNumber, declaredValue, shipmentDate, etc.)

Returns:

  • (String)

    raw comma-separated API response body ("1,OK,<record_id>" on success)



21
22
23
# File 'app/services/shipping/shipsurance_client.rb', line 21

def record_shipment(params)
  post(record_url, with_credentials(params))
end

#void_shipment(params) ⇒ String

Void a previously recorded shipment.

Parameters:

  • params (Hash)

    void-specific fields (recordedShipmentId,
    extRSVoidReasonId, voidDescription, shipmentDate, extCarrierId)

Returns:

  • (String)

    raw comma-separated API response body



30
31
32
# File 'app/services/shipping/shipsurance_client.rb', line 30

def void_shipment(params)
  post(void_url, with_credentials(params))
end