Skip to content

Commit

Permalink
Merge pull request #139 from EasyPost/dont_retrieve
Browse files Browse the repository at this point in the history
chore: remove unnecessary retrieve calls
  • Loading branch information
Justintime50 authored Jun 25, 2024
2 parents cfc3ad1 + eeb262f commit 87c74e9
Show file tree
Hide file tree
Showing 144 changed files with 373 additions and 577 deletions.
16 changes: 1 addition & 15 deletions official/docs/csharp/current/addresses/verify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,7 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

Parameters.Address.Create parameters = new()
{
Street1 = "417 MONTGOMERY ST",
Street2 = "FLOOR 5",
City = "SAN FRANCISCO",
State = "CA",
Zip = "94104",
Country = "US",
Company = "EasyPost",
Phone = "415-123-4567",
};

Address address = await client.Address.Create(parameters);

address = await client.Address.Verify(address.Id)
address = await client.Address.Verify("adr_...")

Console.WriteLine(JsonConvert.SerializeObject(address, Formatting.Indented));
}
Expand Down
4 changes: 1 addition & 3 deletions official/docs/csharp/current/batches/add-shipments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ public static async Task Main()

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

Batch batch = await client.Batch.Retrieve("batch_...");

Parameters.Batch.AddShipments parameters = new()
{
Shipments = new List<IShipmentParameter> { shipment },
};

batch = await client.Batch.AddShipments(batch.Id, parameters);
batch = await client.Batch.AddShipments("batch_...", parameters);

Console.WriteLine(JsonConvert.SerializeObject(batch, Formatting.Indented));
}
Expand Down
29 changes: 28 additions & 1 deletion official/docs/csharp/current/batches/buy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,34 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

Batch batch = await client.Batch.Retrieve("batch_...");
Parameters.Shipment.Create shipmentParameters = new()
{
ToAddress = new Parameters.Address.Create
{
Id = "adr_..."
},
FromAddress = new Parameters.Address.Create
{
Id = "adr_..."
},
Parcel = new Parameters.Parcel.Create
{
Id = "prcl_..."
},
Service = "First",
Carrier = "USPS",
CarrierAccountIds = new List<string> { "ca_..." }
};

Parameters.Batch.Create parameters = new()
{
Shipments = new List<IShipmentParameter>()
{
shipmentParameters
}
};

Batch batch = await client.Batch.Create(parameters);

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

Expand Down
4 changes: 1 addition & 3 deletions official/docs/csharp/current/batches/label.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

Batch batch = await client.Batch.Retrieve("batch_...");

Parameters.Batch.GenerateLabel parameters = new()
{
FileFormat = "PDF",
}

batch = await client.Batch.GenerateLabel(batch.Id, parameters);
batch = await client.Batch.GenerateLabel("batch_...", parameters);

Console.WriteLine(JsonConvert.SerializeObject(batch, Formatting.Indented));
}
Expand Down
4 changes: 1 addition & 3 deletions official/docs/csharp/current/batches/remove-shipments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ public static async Task Main()

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

Batch batch = await client.Batch.Retrieve("batch_...");

Parameters.Batch.RemoveShipments parameters = new()
{
Shipments = new List<IShipmentParameter> { shipment },
};

batch = await client.Batch.RemoveShipments(batch.Id, parameters);
batch = await client.Batch.RemoveShipments("batch_...", parameters);

Console.WriteLine(JsonConvert.SerializeObject(batch, Formatting.Indented));
}
Expand Down
4 changes: 1 addition & 3 deletions official/docs/csharp/current/batches/scan-forms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

Batch batch = await client.Batch.Retrieve("batch_...");

Parameters.Batch.GenerateScanForm parameters = new()
{
FileFormat = "ZPL",
}

batch = await client.Batch.GenerateScanForm(batch.Id, parameters);
batch = await client.Batch.GenerateScanForm("batch_...", parameters);

Console.WriteLine(JsonConvert.SerializeObject(batch, Formatting.Indented));
}
Expand Down
4 changes: 1 addition & 3 deletions official/docs/csharp/current/brand/update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

User user = await client.User.RetrieveMe();

Parameters.User.UpdateBrand parameters = new()
{
BackgroundColorHexCode = "#FFFFFF",
Expand All @@ -27,7 +25,7 @@ public static async Task Main()
Theme = "theme1"
};

Brand brand = await client.User.UpdateBrand(user.Id, parameters);
Brand brand = await client.User.UpdateBrand("user_...", parameters);

Console.WriteLine(JsonConvert.SerializeObject(user, Formatting.Indented));
}
Expand Down
4 changes: 1 addition & 3 deletions official/docs/csharp/current/carrier-accounts/delete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

CarrierAccount carrierAccount = await client.CarrierAccount.Retrieve("ca_...");

await client.CarrierAccount.Delete(carrierAccount.Id);
await client.CarrierAccount.Delete("ca_...");
}
}
4 changes: 1 addition & 3 deletions official/docs/csharp/current/carrier-accounts/update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

CarrierAccount carrierAccount = await client.CarrierAccount.Retrieve("ca_...");

Parameters.CarrierAccount.Update parameters = new()
{
Description = "FL Location DHL eCommerce Solutions Account",
Expand All @@ -25,7 +23,7 @@ public static async Task Main()
},
};

carrierAccount = await client.CarrierAccount.Update(carrierAccount.Id, parameters);
carrierAccount = await client.CarrierAccount.Update("ca_...", parameters);

Console.WriteLine(JsonConvert.SerializeObject(carrierAccount, Formatting.Indented));
}
Expand Down
2 changes: 0 additions & 2 deletions official/docs/csharp/current/carrier-metadata/retrieve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public static async Task Main()

// Request all metadata for all carriers
List<Carrier> carrierMetadata = await client.CarrierMetadata.Retrieve();

Console.WriteLine(JsonConvert.SerializeObject(carrierMetadata, Formatting.Indented));

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

List<Carrier> carrierMetadata = await client.CarrierMetadata.Retrieve(parameters);

Console.WriteLine(JsonConvert.SerializeObject(carrierMetadata, Formatting.Indented));
}
}
Expand Down
4 changes: 1 addition & 3 deletions official/docs/csharp/current/child-users/delete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

User user = await client.User.Retrieve("user_...");

await client.User.Delete(user.Id);
await client.User.Delete("user_...");
}
}
6 changes: 3 additions & 3 deletions official/docs/csharp/current/endshipper/buy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

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

Rate rate = shipment.LowestRate();
Rate rate = retrievedShipment.LowestRate();

Parameters.Shipment.Buy parameters = new(rate)
{
EndShipperId = "es_...",
};

shipment = await client.Shipment.Buy(shipment.Id, parameters);
shipment = await client.Shipment.Buy(retrievedShipment.Id, parameters);

Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented));
}
Expand Down
4 changes: 1 addition & 3 deletions official/docs/csharp/current/endshipper/update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

EndShipper endShipper = await client.EndShipper.Retrieve("es_...");

// Updating an EndShipper requires all the original data to be sent back + the updated data
Parameters.EndShipper.Update parameters = new()
{
Expand All @@ -31,7 +29,7 @@ public static async Task Main()
Email = "[email protected]",
};

endShipper = await client.EndShipper.Update(endShipper.Id, parameters);
endShipper = await client.EndShipper.Update("es_...", parameters);

Console.WriteLine(JsonConvert.SerializeObject(endShipper, Formatting.Indented));
}
Expand Down
5 changes: 1 addition & 4 deletions official/docs/csharp/current/forms/create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

// Shipment has to be purchased before forms can be generated
Shipment shipment = await client.Shipment.Retrieve("shp_...");

Parameters.Shipment.GenerateForm parameters = new()
{
Type = "return_packing_slip",
Expand All @@ -39,7 +36,7 @@ public static async Task Main()
}
};

shipment = await client.Shipment.GenerateForm(shipment.Id, parameters);
shipment = await client.Shipment.GenerateForm("shp_...", parameters);

Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented));
}
Expand Down
4 changes: 1 addition & 3 deletions official/docs/csharp/current/orders/buy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

Order order = await client.Order.Retrieve("order_...");

Parameters.Order.Buy parameters = new("FedEx", "FEDEX_GROUND");

order = await client.Order.Buy(order.Id, parameters);
order = await client.Order.Buy("order_...", parameters);

Console.WriteLine(JsonConvert.SerializeObject(order, Formatting.Indented));
}
Expand Down
4 changes: 1 addition & 3 deletions official/docs/csharp/current/pickups/buy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

Pickup pickup = await client.Pickup.Retrieve("pickup_...");

Parameters.Pickup.Buy parameters = new("UPS", "Same-Day Pickup");

pickup = await client.Pickup.Buy(pickup.Id, parameters);
pickup = await client.Pickup.Buy("pickup_...", parameters);

Console.WriteLine(JsonConvert.SerializeObject(pickup, Formatting.Indented));
}
Expand Down
4 changes: 1 addition & 3 deletions official/docs/csharp/current/pickups/cancel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

Pickup pickup = await client.Pickup.Retrieve("pickup_...");

pickup = await client.Pickup.Cancel(pickup.Id);
pickup = await client.Pickup.Cancel("pickup_...");

Console.WriteLine(JsonConvert.SerializeObject(pickup, Formatting.Indented));
}
Expand Down
4 changes: 1 addition & 3 deletions official/docs/csharp/current/rates/regenerate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

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

shipment = await client.Shipment.RegenerateRates(shipment.Id);
shipment = await client.Shipment.RegenerateRates("shp_...");

Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented));
}
Expand Down
6 changes: 3 additions & 3 deletions official/docs/csharp/current/shipments/buy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

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

Rate rate = shipment.LowestRate();
Rate rate = retrievedShipment.LowestRate();

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

shipment = await client.Shipment.Buy(shipment.Id, parameters);
shipment = await client.Shipment.Buy(retrievedShipment.Id, parameters);

Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented));
}
Expand Down
4 changes: 1 addition & 3 deletions official/docs/csharp/current/shipments/label.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

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

Parameters.Shipment.GenerateLabel parameters = new()
{
FileFormat = "ZPL",
};

shipment = await client.Shipment.GenerateLabel(shipment.Id, parameters);
shipment = await client.Shipment.GenerateLabel("shp_...", parameters);

Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented));
}
Expand Down
4 changes: 1 addition & 3 deletions official/docs/csharp/current/shipping-insurance/insure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

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

shipment = await client.Shipment.Insure(shipment.Id, 200);
shipment = await client.Shipment.Insure("shp_...", 200);

Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented));
}
Expand Down
4 changes: 1 addition & 3 deletions official/docs/csharp/current/shipping-refund/refund.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

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

shipment = await client.Shipment.Refund(shipment.Id);
shipment = await client.Shipment.Refund("shp_...");

Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

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

Parameters.Shipment.RetrieveEstimatedDeliveryDate parameters = new()
{
PlannedShipDate = "2021-01-01",
};

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

Console.WriteLine(JsonConvert.SerializeObject(rates, Formatting.Indented));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

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

List<SmartRate> smartRates = await client.Shipment.GetSmartRates(shipment.Id);
List<SmartRate> smartRates = await client.Shipment.GetSmartRates("shp_...");

Console.WriteLine(JsonConvert.SerializeObject(smartRates, Formatting.Indented));
}
Expand Down
4 changes: 1 addition & 3 deletions official/docs/csharp/current/users/update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ public static async Task Main()
{
var client = new EasyPost.Client(new EasyPost.ClientConfiguration("EASYPOST_API_KEY"));

User user = await client.User.RetrieveMe();

Parameters.User.Update parameters = new()
{
RechargeThreshold = "50.00"
};

user = await client.User.Update(user.Id, parameters);
user = await client.User.Update("user_...", parameters);

Console.WriteLine(JsonConvert.SerializeObject(user, Formatting.Indented));
}
Expand Down
Loading

0 comments on commit 87c74e9

Please sign in to comment.