Shippex.Service (shippex v0.17.0) View Source
A Service
represents a carrier's offered shipping option. This is not
initialized by the user directly. However, some convenience functions exist
to display all offered carrier services to the user.
Service fields are:
:id
- A unique Shippex ID that can be used to perform lookups or fetch rates:carrier
- The atom representing the carrier:code
- Internally used by Shippex for API requests:description
- A user-friendly string containing the name of the service
Example
iex> Shippex.Service.services_for_carrier(:ups)
[
%Shippex.Service{id: :ups_next_day_air, carrier: :ups, description: "UPS Next Day Air"},
%Shippex.Service{id: :ups_second_day_air, carrier: :ups, description: "UPS 2nd Day Air"},
%Shippex.Service{id: :ups_three_day_select, carrier: :ups, description: "UPS 3 Day Select"},
%Shippex.Service{id: :ups_ground, carrier: :ups, description: "UPS Ground"}
]
Link to this section Summary
Functions
Looks up a shipping service by its unique Shippex ID. Returns nil if none exist.
Returns all services for carrier
based on the shipment
provided.
Link to this section Types
Specs
t() :: %Shippex.Service{ carrier: Shippex.Carrier.t(), description: String.t(), id: atom() }
Link to this section Functions
Specs
Looks up a shipping service by its unique Shippex ID. Returns nil if none exist.
iex> Service.get(:usps_priority)
%Service{id: :usps_priority, carrier: :usps, description: "Priority Mail"}
iex> Service.get(:invalid_service)
nil
Specs
services_for_carrier(Shippex.Carrier.t(), Shippex.Shipment.t()) :: [t()]
Returns all services for carrier
based on the shipment
provided.
Shippex.Service.services_for_carrier(:ups)