Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
Ensure example can be compiled.
  • Loading branch information
cargilltay committed Aug 2, 2024
1 parent 80236f5 commit 5eff652
Showing 1 changed file with 42 additions and 41 deletions.
83 changes: 42 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,60 +22,61 @@ A simple create & buy shipment example:

```csharp
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using EasyPost;
using Newtonsoft.Json;
using EasyPost.Parameters;

namespace example
namespace Example;

class ExampleClass
{
class exampleClass
static async Task Main()
{
static async Task Main()
var client = new Client(new ClientConfiguration(Environment.GetEnvironmentVariable("EASYPOST_API_KEY")));

var createParameters = new EasyPost.Parameters.Shipment.Create()
{
Client client = new Client(new ClientConfiguration(Environment.GetEnvironmentVariable("EASYPOST_API_KEY")));

Parameters.Shipment.Create createParameters = new() {
ToAddress = new Parameters.Address.Create {
Name = "Dr. Steve Brule",
Street1 = "179 N Harbor Dr",
City = "Redondo Beach",
State = "CA",
Zip = "90277",
Country = "US",
Phone = "8573875756",
Email = "[email protected]"
},
FromAddress = new Parameters.Address.Create {
Name = "EasyPost",
Street1 = "417 Montgomery Street",
Street2 = "5th Floor",
City = "San Francisco",
State = "CA",
Zip = "94104",
Country = "US",
Phone = "4153334445",
Email = "[email protected]"
},
Parcel = new Parameters.Parcel.Create {
Length = 20.2,
Width = 10.9,
Height = 5,
Weight = 65.9
}
ToAddress = new EasyPost.Parameters.Address.Create
{
Name = "Dr. Steve Brule",
Street1 = "179 N Harbor Dr",
City = "Redondo Beach",
State = "CA",
Zip = "90277",
Country = "US",
Phone = "8573875756",
Email = "[email protected]"
},
FromAddress = new EasyPost.Parameters.Address.Create
{
Name = "EasyPost",
Street1 = "417 Montgomery Street",
Street2 = "5th Floor",
City = "San Francisco",
State = "CA",
Zip = "94104",
Country = "US",
Phone = "4153334445",
Email = "[email protected]"
},
Parcel = new EasyPost.Parameters.Parcel.Create
{
Length = 20.2,
Width = 10.9,
Height = 5,
Weight = 65.9
}
};

Shipment shipment = await client.Shipment.Create(parameters);
var shipment = await client.Shipment.Create(createParameters);

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

Paramaters.Shipment.Buy buyParameters = new(rate);
var buyParameters = new EasyPost.Parameters.Shipment.Buy(rate);

Shipment purchasedShipment = await client.Shipment.Buy(shipment.Id, buyParameters);
var purchasedShipment = await client.Shipment.Buy(shipment.Id, buyParameters);

Console.WriteLine(JsonConvert.SerializeObject(purchasedShipment, Formatting.Indented));
}
Console.WriteLine(JsonConvert.SerializeObject(purchasedShipment, Formatting.Indented));
}
}
```
Expand Down

0 comments on commit 5eff652

Please sign in to comment.