Skip to content

Commit 87c74e9

Browse files
authored
Merge pull request #139 from EasyPost/dont_retrieve
chore: remove unnecessary retrieve calls
2 parents cfc3ad1 + eeb262f commit 87c74e9

File tree

144 files changed

+373
-577
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+373
-577
lines changed

official/docs/csharp/current/addresses/verify.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,7 @@ public static async Task Main()
1414
{
1515
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1616

17-
Parameters.Address.Create parameters = new()
18-
{
19-
Street1 = "417 MONTGOMERY ST",
20-
Street2 = "FLOOR 5",
21-
City = "SAN FRANCISCO",
22-
State = "CA",
23-
Zip = "94104",
24-
Country = "US",
25-
Company = "EasyPost",
26-
Phone = "415-123-4567",
27-
};
28-
29-
Address address = await client.Address.Create(parameters);
30-
31-
address = await client.Address.Verify(address.Id)
17+
address = await client.Address.Verify("adr_...")
3218

3319
Console.WriteLine(JsonConvert.SerializeObject(address, Formatting.Indented));
3420
}

official/docs/csharp/current/batches/add-shipments.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@ public static async Task Main()
1616

1717
Shipment shipment = await client.Shipment.Retrieve("shp_...");
1818

19-
Batch batch = await client.Batch.Retrieve("batch_...");
20-
2119
Parameters.Batch.AddShipments parameters = new()
2220
{
2321
Shipments = new List<IShipmentParameter> { shipment },
2422
};
2523

26-
batch = await client.Batch.AddShipments(batch.Id, parameters);
24+
batch = await client.Batch.AddShipments("batch_...", parameters);
2725

2826
Console.WriteLine(JsonConvert.SerializeObject(batch, Formatting.Indented));
2927
}

official/docs/csharp/current/batches/buy.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,34 @@ public static async Task Main()
1313
{
1414
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1515

16-
Batch batch = await client.Batch.Retrieve("batch_...");
16+
Parameters.Shipment.Create shipmentParameters = new()
17+
{
18+
ToAddress = new Parameters.Address.Create
19+
{
20+
Id = "adr_..."
21+
},
22+
FromAddress = new Parameters.Address.Create
23+
{
24+
Id = "adr_..."
25+
},
26+
Parcel = new Parameters.Parcel.Create
27+
{
28+
Id = "prcl_..."
29+
},
30+
Service = "First",
31+
Carrier = "USPS",
32+
CarrierAccountIds = new List<string> { "ca_..." }
33+
};
34+
35+
Parameters.Batch.Create parameters = new()
36+
{
37+
Shipments = new List<IShipmentParameter>()
38+
{
39+
shipmentParameters
40+
}
41+
};
42+
43+
Batch batch = await client.Batch.Create(parameters);
1744

1845
batch = await client.Batch.Buy(batch.Id);
1946

official/docs/csharp/current/batches/label.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ public static async Task Main()
1414
{
1515
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1616

17-
Batch batch = await client.Batch.Retrieve("batch_...");
18-
1917
Parameters.Batch.GenerateLabel parameters = new()
2018
{
2119
FileFormat = "PDF",
2220
}
2321

24-
batch = await client.Batch.GenerateLabel(batch.Id, parameters);
22+
batch = await client.Batch.GenerateLabel("batch_...", parameters);
2523

2624
Console.WriteLine(JsonConvert.SerializeObject(batch, Formatting.Indented));
2725
}

official/docs/csharp/current/batches/remove-shipments.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@ public static async Task Main()
1616

1717
Shipment shipment = await client.Shipment.Retrieve("shp_...");
1818

19-
Batch batch = await client.Batch.Retrieve("batch_...");
20-
2119
Parameters.Batch.RemoveShipments parameters = new()
2220
{
2321
Shipments = new List<IShipmentParameter> { shipment },
2422
};
2523

26-
batch = await client.Batch.RemoveShipments(batch.Id, parameters);
24+
batch = await client.Batch.RemoveShipments("batch_...", parameters);
2725

2826
Console.WriteLine(JsonConvert.SerializeObject(batch, Formatting.Indented));
2927
}

official/docs/csharp/current/batches/scan-forms.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ public static async Task Main()
1414
{
1515
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1616

17-
Batch batch = await client.Batch.Retrieve("batch_...");
18-
1917
Parameters.Batch.GenerateScanForm parameters = new()
2018
{
2119
FileFormat = "ZPL",
2220
}
2321

24-
batch = await client.Batch.GenerateScanForm(batch.Id, parameters);
22+
batch = await client.Batch.GenerateScanForm("batch_...", parameters);
2523

2624
Console.WriteLine(JsonConvert.SerializeObject(batch, Formatting.Indented));
2725
}

official/docs/csharp/current/brand/update.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ public static async Task Main()
1414
{
1515
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1616

17-
User user = await client.User.RetrieveMe();
18-
1917
Parameters.User.UpdateBrand parameters = new()
2018
{
2119
BackgroundColorHexCode = "#FFFFFF",
@@ -27,7 +25,7 @@ public static async Task Main()
2725
Theme = "theme1"
2826
};
2927

30-
Brand brand = await client.User.UpdateBrand(user.Id, parameters);
28+
Brand brand = await client.User.UpdateBrand("user_...", parameters);
3129

3230
Console.WriteLine(JsonConvert.SerializeObject(user, Formatting.Indented));
3331
}

official/docs/csharp/current/carrier-accounts/delete.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ public static async Task Main()
1313
{
1414
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1515

16-
CarrierAccount carrierAccount = await client.CarrierAccount.Retrieve("ca_...");
17-
18-
await client.CarrierAccount.Delete(carrierAccount.Id);
16+
await client.CarrierAccount.Delete("ca_...");
1917
}
2018
}

official/docs/csharp/current/carrier-accounts/update.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ public static async Task Main()
1414
{
1515
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1616

17-
CarrierAccount carrierAccount = await client.CarrierAccount.Retrieve("ca_...");
18-
1917
Parameters.CarrierAccount.Update parameters = new()
2018
{
2119
Description = "FL Location DHL eCommerce Solutions Account",
@@ -25,7 +23,7 @@ public static async Task Main()
2523
},
2624
};
2725

28-
carrierAccount = await client.CarrierAccount.Update(carrierAccount.Id, parameters);
26+
carrierAccount = await client.CarrierAccount.Update("ca_...", parameters);
2927

3028
Console.WriteLine(JsonConvert.SerializeObject(carrierAccount, Formatting.Indented));
3129
}

official/docs/csharp/current/carrier-metadata/retrieve.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public static async Task Main()
1616

1717
// Request all metadata for all carriers
1818
List<Carrier> carrierMetadata = await client.CarrierMetadata.Retrieve();
19-
2019
Console.WriteLine(JsonConvert.SerializeObject(carrierMetadata, Formatting.Indented));
2120

2221
// Request specific metadata for specific carriers
@@ -27,7 +26,6 @@ public static async Task Main()
2726
};
2827

2928
List<Carrier> carrierMetadata = await client.CarrierMetadata.Retrieve(parameters);
30-
3129
Console.WriteLine(JsonConvert.SerializeObject(carrierMetadata, Formatting.Indented));
3230
}
3331
}

official/docs/csharp/current/child-users/delete.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ public static async Task Main()
1313
{
1414
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1515

16-
User user = await client.User.Retrieve("user_...");
17-
18-
await client.User.Delete(user.Id);
16+
await client.User.Delete("user_...");
1917
}
2018
}

official/docs/csharp/current/endshipper/buy.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ public static async Task Main()
1414
{
1515
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1616

17-
Shipment shipment = await client.Shipment.Retrieve("shp_...");
17+
Shipment retrievedShipment = await client.Shipment.Retrieve("shp_...");
1818

19-
Rate rate = shipment.LowestRate();
19+
Rate rate = retrievedShipment.LowestRate();
2020

2121
Parameters.Shipment.Buy parameters = new(rate)
2222
{
2323
EndShipperId = "es_...",
2424
};
2525

26-
shipment = await client.Shipment.Buy(shipment.Id, parameters);
26+
shipment = await client.Shipment.Buy(retrievedShipment.Id, parameters);
2727

2828
Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented));
2929
}

official/docs/csharp/current/endshipper/update.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ public static async Task Main()
1414
{
1515
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1616

17-
EndShipper endShipper = await client.EndShipper.Retrieve("es_...");
18-
1917
// Updating an EndShipper requires all the original data to be sent back + the updated data
2018
Parameters.EndShipper.Update parameters = new()
2119
{
@@ -31,7 +29,7 @@ public static async Task Main()
3129
Email = "FOO@EXAMPLE.COM",
3230
};
3331

34-
endShipper = await client.EndShipper.Update(endShipper.Id, parameters);
32+
endShipper = await client.EndShipper.Update("es_...", parameters);
3533

3634
Console.WriteLine(JsonConvert.SerializeObject(endShipper, Formatting.Indented));
3735
}

official/docs/csharp/current/forms/create.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ public static async Task Main()
1414
{
1515
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1616

17-
// Shipment has to be purchased before forms can be generated
18-
Shipment shipment = await client.Shipment.Retrieve("shp_...");
19-
2017
Parameters.Shipment.GenerateForm parameters = new()
2118
{
2219
Type = "return_packing_slip",
@@ -39,7 +36,7 @@ public static async Task Main()
3936
}
4037
};
4138

42-
shipment = await client.Shipment.GenerateForm(shipment.Id, parameters);
39+
shipment = await client.Shipment.GenerateForm("shp_...", parameters);
4340

4441
Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented));
4542
}

official/docs/csharp/current/orders/buy.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ public static async Task Main()
1414
{
1515
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1616

17-
Order order = await client.Order.Retrieve("order_...");
18-
1917
Parameters.Order.Buy parameters = new("FedEx", "FEDEX_GROUND");
2018

21-
order = await client.Order.Buy(order.Id, parameters);
19+
order = await client.Order.Buy("order_...", parameters);
2220

2321
Console.WriteLine(JsonConvert.SerializeObject(order, Formatting.Indented));
2422
}

official/docs/csharp/current/pickups/buy.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ public static async Task Main()
1414
{
1515
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1616

17-
Pickup pickup = await client.Pickup.Retrieve("pickup_...");
18-
1917
Parameters.Pickup.Buy parameters = new("UPS", "Same-Day Pickup");
2018

21-
pickup = await client.Pickup.Buy(pickup.Id, parameters);
19+
pickup = await client.Pickup.Buy("pickup_...", parameters);
2220

2321
Console.WriteLine(JsonConvert.SerializeObject(pickup, Formatting.Indented));
2422
}

official/docs/csharp/current/pickups/cancel.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ public static async Task Main()
1313
{
1414
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1515

16-
Pickup pickup = await client.Pickup.Retrieve("pickup_...");
17-
18-
pickup = await client.Pickup.Cancel(pickup.Id);
16+
pickup = await client.Pickup.Cancel("pickup_...");
1917

2018
Console.WriteLine(JsonConvert.SerializeObject(pickup, Formatting.Indented));
2119
}

official/docs/csharp/current/rates/regenerate.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ public static async Task Main()
1414
{
1515
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1616

17-
Shipment shipment = await client.Shipment.Retrieve("shp_...");
18-
19-
shipment = await client.Shipment.RegenerateRates(shipment.Id);
17+
shipment = await client.Shipment.RegenerateRates("shp_...");
2018

2119
Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented));
2220
}

official/docs/csharp/current/shipments/buy.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ public static async Task Main()
1414
{
1515
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1616

17-
Shipment shipment = await client.Shipment.Retrieve("shp_...");
17+
Shipment retrievedShipment = await client.Shipment.Retrieve("shp_...");
1818

19-
Rate rate = shipment.LowestRate();
19+
Rate rate = retrievedShipment.LowestRate();
2020

2121
Parameters.Shipment.Buy parameters = new(rate);
2222

23-
shipment = await client.Shipment.Buy(shipment.Id, parameters);
23+
shipment = await client.Shipment.Buy(retrievedShipment.Id, parameters);
2424

2525
Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented));
2626
}

official/docs/csharp/current/shipments/label.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ public static async Task Main()
1414
{
1515
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1616

17-
Shipment shipment = await client.Shipment.Retrieve("shp_...");
18-
1917
Parameters.Shipment.GenerateLabel parameters = new()
2018
{
2119
FileFormat = "ZPL",
2220
};
2321

24-
shipment = await client.Shipment.GenerateLabel(shipment.Id, parameters);
22+
shipment = await client.Shipment.GenerateLabel("shp_...", parameters);
2523

2624
Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented));
2725
}

official/docs/csharp/current/shipping-insurance/insure.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ public static async Task Main()
1313
{
1414
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1515

16-
Shipment shipment = await client.Shipment.Retrieve("shp_...");
17-
18-
shipment = await client.Shipment.Insure(shipment.Id, 200);
16+
shipment = await client.Shipment.Insure("shp_...", 200);
1917

2018
Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented));
2119
}

official/docs/csharp/current/shipping-refund/refund.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ public static async Task Main()
1313
{
1414
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1515

16-
Shipment shipment = await client.Shipment.Retrieve("shp_...");
17-
18-
shipment = await client.Shipment.Refund(shipment.Id);
16+
shipment = await client.Shipment.Refund("shp_...");
1917

2018
Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented));
2119
}

official/docs/csharp/current/smartrate/retrieve-estimated-delivery-date.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ public static async Task Main()
1414
{
1515
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1616

17-
Shipment shipment = await client.Shipment.Retrieve("shp_...");
18-
1917
Parameters.Shipment.RetrieveEstimatedDeliveryDate parameters = new()
2018
{
2119
PlannedShipDate = "2021-01-01",
2220
};
2321

24-
List<RateWithEstimatedDeliveryDate> rates = await client.Shipment.RetrieveEstimatedDeliveryDate(shipment.Id, parameters);
22+
List<RateWithEstimatedDeliveryDate> rates = await client.Shipment.RetrieveEstimatedDeliveryDate("shp_...", parameters);
2523

2624
Console.WriteLine(JsonConvert.SerializeObject(rates, Formatting.Indented));
2725
}

official/docs/csharp/current/smartrate/retrieve-time-in-transit-statistics.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ public static async Task Main()
1313
{
1414
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1515

16-
Shipment shipment = await client.Shipment.Retrieve("shp_...");
17-
18-
List<SmartRate> smartRates = await client.Shipment.GetSmartRates(shipment.Id);
16+
List<SmartRate> smartRates = await client.Shipment.GetSmartRates("shp_...");
1917

2018
Console.WriteLine(JsonConvert.SerializeObject(smartRates, Formatting.Indented));
2119
}

official/docs/csharp/current/users/update.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ public static async Task Main()
1414
{
1515
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));
1616

17-
User user = await client.User.RetrieveMe();
18-
1917
Parameters.User.Update parameters = new()
2018
{
2119
RechargeThreshold = "50.00"
2220
};
2321

24-
user = await client.User.Update(user.Id, parameters);
22+
user = await client.User.Update("user_...", parameters);
2523

2624
Console.WriteLine(JsonConvert.SerializeObject(user, Formatting.Indented));
2725
}

0 commit comments

Comments
 (0)