View Source UspsEx.Service (usps_ex v2023.1.27)

A Service represents a shipping option.

Service fields are:

  • :id - A unique UspsEx ID that can be used to perform lookups or fetch rates
  • :description - A user-friendly string containing the name of the service

example

Example

  iex> UspsEx.Service.services_for_carrier(:usps)
  [
    %UspsEx.Service{id: :usps_next_day_air,  description: "USPS Next Day Air"},
    %UspsEx.Service{id: :usps_second_day_air, description: "USPS 2nd Day Air"},
    %UspsEx.Service{id: :usps_three_day_select,  description: "USPS 3 Day Select"},
    %UspsEx.Service{id: :usps_ground,  description: "USPS Ground"}
  ]

Link to this section Summary

Functions

Looks up a shipping service by its unique UspsEx ID. Returns nil if none exist.

Returns all services based on the shipment provided.

Link to this section Types

@type t() :: %UspsEx.Service{description: String.t(), id: atom()}

Link to this section Functions

@spec get(atom()) :: t() | nil

Looks up a shipping service by its unique UspsEx ID. Returns nil if none exist.

iex> Service.get(:usps_priority)
%Service{id: :usps_priority,  description: "Priority Mail"}
iex> Service.get(:invalid_service)
nil

Returns all services based on the shipment provided.

UspsEx.Service.services(%Shipment{})