Skip to content

feat: adds luma functions #326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

## Next Release

- Adds the following functions
- `shipment.create_and_buy_luma`
- `shipment.buy_luma`
- `luma.get_promise`

## v7.0.1 (2025-05-27)

- Corrects the endpoint used for creating/updating UPS accounts
Expand Down
2 changes: 1 addition & 1 deletion examples
Submodule examples updated 1556 files
1 change: 1 addition & 0 deletions lib/easypost/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def initialize(api_key:, read_timeout: 60, open_timeout: 30, api_base: 'https://
EasyPost::Services::EndShipper,
EasyPost::Services::Event,
EasyPost::Services::Insurance,
EasyPost::Services::Luma,
EasyPost::Services::Order,
EasyPost::Services::Parcel,
EasyPost::Services::Pickup,
Expand Down
1 change: 1 addition & 0 deletions lib/easypost/services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module EasyPost::Services
require_relative 'services/end_shipper'
require_relative 'services/event'
require_relative 'services/insurance'
require_relative 'services/luma'
require_relative 'services/order'
require_relative 'services/parcel'
require_relative 'services/pickup'
Expand Down
12 changes: 12 additions & 0 deletions lib/easypost/services/luma.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

class EasyPost::Services::Luma < EasyPost::Services::Service
# Get service recommendations from Luma that meet the criteria of your ruleset.
def get_promise(params = {})
url = 'luma/promise'
wrapped_params = { shipment: params }
response = @client.make_request(:post, url, wrapped_params)

EasyPost::InternalUtilities::Json.convert_json_to_object(response).luma_info
end
end
25 changes: 21 additions & 4 deletions lib/easypost/services/shipment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,35 @@ def generate_form(id, form_type, form_options = {})
# Retrieves the estimated delivery date of each Rate via SmartRate.
def retrieve_estimated_delivery_date(id, planned_ship_date)
url = "shipments/#{id}/smartrate/delivery_date"
params = { planned_ship_date: planned_ship_date }
response = @client.make_request(:get, url, params)
wrapped_params = { planned_ship_date: planned_ship_date }
response = @client.make_request(:get, url, wrapped_params)

EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS).rates
end

# Retrieve a recommended ship date for an existing Shipment via the Precision Shipping API, based on a specific desired delivery date.
def recommend_ship_date(id, desired_delivery_date)
url = "shipments/#{id}/smartrate/precision_shipping"
params = { desired_delivery_date: desired_delivery_date }
response = @client.make_request(:get, url, params)
wrapped_params = { desired_delivery_date: desired_delivery_date }
response = @client.make_request(:get, url, wrapped_params)

EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS).rates
end

# Create and buy a Luma Shipment in one call.
def create_and_buy_luma(params = {})
url = 'shipments/luma'
wrapped_params = { shipment: params }
response = @client.make_request(:post, url, wrapped_params)

EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
end

# Buy a Shipment with Luma.
def buy_luma(id, params = {})
url = "shipments/#{id}/luma"
response = @client.make_request(:post, url, params)

EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
end
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading