Skip to content

Commit

Permalink
Refactor: Remove with_carbon_offset parameter (#288)
Browse files Browse the repository at this point in the history
* Remove all references to carbon offset

* Remove carbon offset specific specs

* Re-record cassettes for shipment specs and adjust expectations to current data

* Re-record cassettes for batch and insurance specs

* Re-record pickup cassettes and adjust some fixtures

* Re-record applicable cassettes for rate, refund and scan form specs

* Update CHANGELOG
  • Loading branch information
dcaballeroc authored Nov 30, 2023
1 parent bb0fa0d commit 3753698
Show file tree
Hide file tree
Showing 55 changed files with 1,967 additions and 2,778 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## Next release

- Removed `with_carbon_offset` parameter from `create`, `buy` and `regenerate_rates` methods in the shipment service since now EasyPost offers carbon neutral shipments by default for free

## v5.3.0 (2023-10-11)

- Migrate API Key-related functions out of `user` service into `api_key` service, deprecating the old and introducing the new
Expand Down
2 changes: 1 addition & 1 deletion examples
Submodule examples updated 517 files
1 change: 0 additions & 1 deletion lib/easypost/models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module EasyPost::Models
require_relative 'models/api_key'
require_relative 'models/batch'
require_relative 'models/brand'
require_relative 'models/carbon_offset'
require_relative 'models/carrier_account'
require_relative 'models/carrier_type'
require_relative 'models/customs_info'
Expand Down
5 changes: 0 additions & 5 deletions lib/easypost/models/carbon_offset.rb

This file was deleted.

18 changes: 5 additions & 13 deletions lib/easypost/services/shipment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ class EasyPost::Services::Shipment < EasyPost::Services::Service
MODEL_CLASS = EasyPost::Models::Shipment

# Create a Shipment.
def create(params = {}, with_carbon_offset = false)
wrapped_params = {
shipment: params,
carbon_offset: with_carbon_offset,
}
def create(params = {})
wrapped_params = { shipment: params }

@client.make_request(:post, 'shipments', MODEL_CLASS, wrapped_params)
end
Expand All @@ -34,10 +31,8 @@ def get_next_page(collection, page_size = nil)
end

# Regenerate the rates of a Shipment.
def regenerate_rates(id, with_carbon_offset = false)
params = { carbon_offset: with_carbon_offset }

@client.make_request(:post, "shipments/#{id}/rerate", MODEL_CLASS, params)
def regenerate_rates(id)
@client.make_request(:post, "shipments/#{id}/rerate", MODEL_CLASS)
end

# Get the SmartRates of a Shipment.
Expand All @@ -46,14 +41,11 @@ def get_smart_rates(id)
end

# Buy a Shipment.
def buy(id, params = {}, with_carbon_offset = false, end_shipper_id = nil)
def buy(id, params = {}, end_shipper_id = nil)
if params.instance_of?(EasyPost::Models::Rate)
params = { rate: params.clone }
end

params[:carbon_offset] = params[:with_carbon_offset] || with_carbon_offset
params.delete(:with_carbon_offset)

params[:end_shipper_id] = end_shipper_id if end_shipper_id

@client.make_request(:post, "shipments/#{id}/buy", MODEL_CLASS, params)
Expand Down
1 change: 0 additions & 1 deletion lib/easypost/utilities/static_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ module EasyPost::InternalUtilities::StaticMapper
'BankAccount' => EasyPost::Models::PaymentMethod,
'Batch' => EasyPost::Models::Batch,
'Brand' => EasyPost::Models::Brand,
'CarbonOffset' => EasyPost::Models::CarbonOffset,
'CarrierAccount' => EasyPost::Models::CarrierAccount,
'CreditCard' => EasyPost::Models::PaymentMethod,
'CustomsInfo' => EasyPost::Models::CustomsInfo,
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

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

Loading

0 comments on commit 3753698

Please sign in to comment.