Skip to content

Commit 24881a3

Browse files
authored
Merge pull request #326 from EasyPost/luma
feat: adds luma functions
2 parents 1674223 + a5df6e1 commit 24881a3

12 files changed

+422
-5
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# CHANGELOG
22

3+
## Next Release
4+
5+
- Adds the following functions
6+
- `shipment.create_and_buy_luma`
7+
- `shipment.buy_luma`
8+
- `luma.get_promise`
9+
310
## v7.0.1 (2025-05-27)
411

512
- Corrects the endpoint used for creating/updating UPS accounts

examples

Submodule examples updated 1556 files

lib/easypost/client.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def initialize(api_key:, read_timeout: 60, open_timeout: 30, api_base: 'https://
4848
EasyPost::Services::EndShipper,
4949
EasyPost::Services::Event,
5050
EasyPost::Services::Insurance,
51+
EasyPost::Services::Luma,
5152
EasyPost::Services::Order,
5253
EasyPost::Services::Parcel,
5354
EasyPost::Services::Pickup,

lib/easypost/services.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ module EasyPost::Services
2020
require_relative 'services/end_shipper'
2121
require_relative 'services/event'
2222
require_relative 'services/insurance'
23+
require_relative 'services/luma'
2324
require_relative 'services/order'
2425
require_relative 'services/parcel'
2526
require_relative 'services/pickup'

lib/easypost/services/luma.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
class EasyPost::Services::Luma < EasyPost::Services::Service
4+
# Get service recommendations from Luma that meet the criteria of your ruleset.
5+
def get_promise(params = {})
6+
url = 'luma/promise'
7+
wrapped_params = { shipment: params }
8+
response = @client.make_request(:post, url, wrapped_params)
9+
10+
EasyPost::InternalUtilities::Json.convert_json_to_object(response).luma_info
11+
end
12+
end

lib/easypost/services/shipment.rb

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,35 @@ def generate_form(id, form_type, form_options = {})
113113
# Retrieves the estimated delivery date of each Rate via SmartRate.
114114
def retrieve_estimated_delivery_date(id, planned_ship_date)
115115
url = "shipments/#{id}/smartrate/delivery_date"
116-
params = { planned_ship_date: planned_ship_date }
117-
response = @client.make_request(:get, url, params)
116+
wrapped_params = { planned_ship_date: planned_ship_date }
117+
response = @client.make_request(:get, url, wrapped_params)
118118

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

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

128128
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS).rates
129129
end
130+
131+
# Create and buy a Luma Shipment in one call.
132+
def create_and_buy_luma(params = {})
133+
url = 'shipments/luma'
134+
wrapped_params = { shipment: params }
135+
response = @client.make_request(:post, url, wrapped_params)
136+
137+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
138+
end
139+
140+
# Buy a Shipment with Luma.
141+
def buy_luma(id, params = {})
142+
url = "shipments/#{id}/luma"
143+
response = @client.make_request(:post, url, params)
144+
145+
EasyPost::InternalUtilities::Json.convert_json_to_object(response, MODEL_CLASS)
146+
end
130147
end

spec/cassettes/luma/EasyPost_Services_Luma_get_promise_gets_service_recommendations_from_Luma_based_on_your_ruleset.yml

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)