-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
42 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)); | ||
} | ||
} | ||
``` | ||
|