Skip to content

Commit

Permalink
Remove carbon offset (#524)
Browse files Browse the repository at this point in the history
- Remove carbon offset parameter for create/buy of shipment
- Remove carbon offset unit tests
- Re-record cassettes as needed
- Update fixtures
  • Loading branch information
nwithan8 authored Nov 29, 2023
1 parent f32b21b commit 30df9fc
Show file tree
Hide file tree
Showing 201 changed files with 3,710 additions and 5,665 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## Next Release (Major Version)

- Remove `carbon_offset` (`CarbonOffset`) parameter from shipment creation and purchase flows
- This parameter is no longer supported by the EasyPost API
- Remove `CarbonOffset` model

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

- Add `RetrieveApiKeysForUser` to `ApiKey` service
Expand Down
1 change: 0 additions & 1 deletion EasyPost.Integration/Basics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public void UserCanLocallyConstructResponseObject()
var batchCollection = new BatchCollection();
var batchShipment = new BatchShipment();
var brand = new Brand();
var carbonOffset = new CarbonOffset();
var carrier = new EasyPost.Models.API.Carrier();
var carrierBeta = new EasyPost.Models.API.Beta.Carrier();

Check warning on line 25 in EasyPost.Integration/Basics.cs

View workflow job for this annotation

GitHub Actions / Integration_Tests

'Carrier' is obsolete: 'This class is deprecated. Please use EasyPost.Models.API.Carrier instead. This class will be removed in a future version.'
var carrierAccount = new CarrierAccount();
Expand Down
5 changes: 2 additions & 3 deletions EasyPost.Tests/Fixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ internal static Dictionary<string, object> BasicPickup
{
Dictionary<string, object> fixture = GetFixtureStructure().Pickups.Basic;

const string pickupDate = "2023-05-12";
const string pickupDate = "2023-12-01";

fixture!.AddOrUpdate("min_datetime", pickupDate);
fixture!.AddOrUpdate("max_datetime", pickupDate);
Expand Down Expand Up @@ -89,7 +89,7 @@ internal static Dictionary<string, object> BasicPickup

internal static string PickupService => GetFixtureStructure().ServiceNames.Usps.PickupService;

internal static string PlannedShipDate => "2023-05-12";
internal static string PlannedShipDate => "2023-12-01";

internal static Dictionary<string, object> ReferralCustomer => GetFixtureStructure().Users.Referral;

Expand Down Expand Up @@ -645,7 +645,6 @@ internal static ParameterSets.Shipment.Create Create(Dictionary<string, object>?
Parcel = Parcels.Create(parcelFixture),
CustomsInfo = CustomsInfo.Create(customsInfoFixture),
Options = Options(optionsFixture),
CarbonOffset = fixture.GetOrDefault<bool>("carbon_offset"), // this will always be true or false, never null
CarrierAccountIds = fixture.GetOrNull<List<string>>("carrier_accounts"),
Carrier = fixture.GetOrNull<string>("carrier"),
Service = fixture.GetOrNull<string>("service"),
Expand Down
68 changes: 0 additions & 68 deletions EasyPost.Tests/ServicesTests/ShipmentServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,6 @@ public async Task TestCreateEmptyObjects()
Assert.Null(shipment.TaxIdentifiers);
}

[Fact]
[CrudOperations.Create]
[Testing.Parameters]
public async Task TestCreateWithCarbonOffset()
{
UseVCR("create_with_carbon_offset");

Shipment shipment = await Client.Shipment.Create(Fixtures.BasicShipment, true);

Assert.IsType<Shipment>(shipment);

Rate rate = shipment.LowestRate();
CarbonOffset carbonOffset = rate.CarbonOffset;

Assert.NotNull(carbonOffset);
Assert.NotNull(carbonOffset.Price);
}

[Fact]
[CrudOperations.Create]
[Testing.Parameters]
Expand All @@ -108,20 +90,6 @@ public async Task TestCreateWithIds()
Assert.Equal("388 Townsend St", shipment.FromAddress.Street1);
}

[Fact]
[CrudOperations.Create]
[Testing.Parameters]
public async Task TestOneCallBuyShipmentWithCarbonOffset()
{
UseVCR("one_call_buy_shipment_with_carbon_offset");

Shipment shipment = await Client.Shipment.Create(Fixtures.OneCallBuyShipment, true);

Assert.NotNull(shipment.Fees);
bool carbonOffsetIncluded = shipment.Fees.Any(fee => fee.Type == "CarbonOffsetFee");
Assert.True(carbonOffsetIncluded);
}

[Fact]
[CrudOperations.Read]
[Testing.Function]
Expand Down Expand Up @@ -344,22 +312,6 @@ public async Task TestBuyWithNoRateId()
await Assert.ThrowsAsync<MissingParameterError>(async () => await Client.Shipment.Buy(shipment.Id, rateId: null));
}

[Fact]
[CrudOperations.Update]
[Testing.Parameters]
public async Task TestBuyWithCarbonOffset()
{
UseVCR("buy_with_carbon_offset");

Shipment shipment = await Client.Shipment.Create(Fixtures.FullShipment);

shipment = await Client.Shipment.Buy(shipment.Id, shipment.LowestRate(), withCarbonOffset: true);

Assert.NotNull(shipment.Fees);
bool carbonOffsetIncluded = shipment.Fees.Any(fee => fee.Type == "CarbonOffsetFee");
Assert.True(carbonOffsetIncluded);
}

[Fact]
[CrudOperations.Update]
[Testing.Parameters]
Expand Down Expand Up @@ -427,26 +379,6 @@ public async Task TestRegenerateRates()
}
}

[Fact]
[CrudOperations.Update]
[Testing.Parameters]
public async Task TestRegenerateRatesWithCarbonOffset()
{
UseVCR("regenerate_rates_with_carbon_offset");

Shipment shipment = await Client.Shipment.Create(Fixtures.OneCallBuyShipment);
List<Rate> baseRates = shipment.Rates;

shipment = await Client.Shipment.RegenerateRates(shipment.Id, withCarbonOffset: true);
List<Rate> newRatesWithCarbon = shipment.Rates;

Rate baseRate = baseRates!.First();
Rate newRateWithCarbon = newRatesWithCarbon!.First();

Assert.Null(baseRate.CarbonOffset);
Assert.NotNull(newRateWithCarbon.CarbonOffset);
}

[Fact]
[Testing.Function]
public void TestLowestRateFiltering()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,6 @@ public async Task TestCreateWithTaxIdentifiers()
Assert.Equal("IOSS", shipment.TaxIdentifiers[0].TaxIdType);
}

[Fact]
[CrudOperations.Create]
[Testing.Parameters]
public async Task TestCreateWithCarbonOffset()
{
UseVCR("create_with_carbon_offset");

Dictionary<string, object> data = Fixtures.BasicShipment;
data["carbon_offset"] = true;

Parameters.Shipment.Create parameters = Fixtures.Parameters.Shipments.Create(data);

Shipment shipment = await Client.Shipment.Create(parameters);

Assert.IsType<Shipment>(shipment);

Rate rate = shipment.LowestRate();
CarbonOffset carbonOffset = rate.CarbonOffset;

Assert.NotNull(carbonOffset);
Assert.NotNull(carbonOffset.Price);
}

[Fact]
[CrudOperations.Create]
[Testing.Parameters]
Expand Down Expand Up @@ -121,25 +98,6 @@ public async Task TestCreateWithIds()
Assert.Equal("388 Townsend St", shipment.FromAddress.Street1);
}

[Fact]
[CrudOperations.Create]
[Testing.Parameters]
public async Task TestOneCallBuyShipmentWithCarbonOffset()
{
UseVCR("one_call_buy_shipment_with_carbon_offset");

Dictionary<string, object> data = Fixtures.OneCallBuyShipment;
data["carbon_offset"] = true;

Parameters.Shipment.Create parameters = Fixtures.Parameters.Shipments.Create(data);

Shipment shipment = await Client.Shipment.Create(parameters);

Assert.NotNull(shipment.Fees);
bool carbonOffsetIncluded = shipment.Fees.Any(fee => fee.Type == "CarbonOffsetFee");
Assert.True(carbonOffsetIncluded);
}

[Fact]
[CrudOperations.Read]
[Testing.Function]
Expand Down Expand Up @@ -243,30 +201,6 @@ public async Task TestBuy()
Assert.NotNull(shipment.PostageLabel);
}

[Fact]
[CrudOperations.Update]
[Testing.Parameters]
public async Task TestBuyWithCarbonOffset()
{
UseVCR("buy_with_carbon_offset");

Dictionary<string, object> shipmentData = Fixtures.FullShipment;
Parameters.Shipment.Create shipmentParameters = Fixtures.Parameters.Shipments.Create(shipmentData);
Shipment shipment = await Client.Shipment.Create(shipmentParameters);
Rate rate = shipment.LowestRate();

Parameters.Shipment.Buy buyParameters = new(rate)
{
CarbonOffset = true,
};

shipment = await Client.Shipment.Buy(shipment.Id, buyParameters);

Assert.NotNull(shipment.Fees);
bool carbonOffsetIncluded = shipment.Fees.Any(fee => fee.Type == "CarbonOffsetFee");
Assert.True(carbonOffsetIncluded);
}

[Fact]
[CrudOperations.Update]
[Testing.Parameters]
Expand Down Expand Up @@ -330,10 +264,7 @@ public async Task TestGenerateForm()

Rate rate = shipment.LowestRate();

Parameters.Shipment.Buy buyParameters = new(rate)
{
CarbonOffset = true,
};
Parameters.Shipment.Buy buyParameters = new(rate);

shipment = await Client.Shipment.Buy(shipment.Id, buyParameters);

Expand Down Expand Up @@ -372,33 +303,6 @@ public async Task TestRegenerateRates()
}
}

[Fact]
[CrudOperations.Update]
[Testing.Parameters]
public async Task TestRegenerateRatesWithCarbonOffset()
{
UseVCR("regenerate_rates_with_carbon_offset");

Dictionary<string, object> shipmentData = Fixtures.OneCallBuyShipment;
Parameters.Shipment.Create shipmentParameters = Fixtures.Parameters.Shipments.Create(shipmentData);
Shipment shipment = await Client.Shipment.Create(shipmentParameters);
List<Rate> baseRates = shipment.Rates;

Parameters.Shipment.RegenerateRates regenerateRatesParameters = new()
{
CarbonOffset = true,
};
shipment = await Client.Shipment.RegenerateRates(shipment.Id, regenerateRatesParameters);

List<Rate> newRatesWithCarbon = shipment.Rates;

Rate baseRate = baseRates!.First();
Rate newRateWithCarbon = newRatesWithCarbon!.First();

Assert.Null(baseRate.CarbonOffset);
Assert.NotNull(newRateWithCarbon.CarbonOffset);
}

[Fact]
[Testing.Function]
public async Task TestRetrieveEstimatedDeliveryDates()
Expand Down
Loading

0 comments on commit 30df9fc

Please sign in to comment.