Skip to content

Commit

Permalink
[chore] Prep for v5.0.0 release (#474)
Browse files Browse the repository at this point in the history
- Bump version number
- Update README examples, remove outdated information
  • Loading branch information
nwithan8 authored May 15, 2023
1 parent 7bb29ea commit 5e2919c
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 72 deletions.
38 changes: 19 additions & 19 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
# CHANGELOG

## Next Release
## v5.0.0 (2023-05-15)

### Breaking Changes

- **[CHANGED]** All API-calling functions on models have been moved to their respective services. For example, `myPickup.Buy()` is now `myClient.Pickup.Buy(myPickup.Id)`.
- **[CHANGED]** `Client` constructor now takes a `ClientConfiguration` object rather than a list of parameters.
- All API-calling functions on models have been moved to their respective services. For example, `myPickup.Buy()` is now `myClient.Pickup.Buy(myPickup.Id)`.
- `Client` constructor now takes a `ClientConfiguration` object rather than a list of parameters.
- `Client myClient = new Client("my_api_key");` is now `Client myClient = new Client(new ClientConfiguration("my_api_key"));`
- **[CHANGED]** `Smartrate` is now `SmartRate`
- **[REMOVED]** `myClient.Clone` functionality has been removed. Please construct a new `Client` object instead.
- **[REMOVED]** RestSharp dependency has been dropped entirely.
- **[CHANGED]** Renamed `UnexpectedHttpError` exception type to `UnknownHttpError` to better reflect its purpose.
- **[REMOVED]** Removed `UnknownApiError` exception type, consolidated into `UnknownHttpError` exception type.
- **[CHANGED]** `ExternalApiError` no longer inherits from `ApiError` (`ApiError` reserved for EasyPost API errors only).
- **[IMPROVED]** All `EasyPostError` exceptions and subclasses now have a `PrettyPrint` getter that returns a human-readable string representation of the error.
- `Smartrate` is now `SmartRate`
- `myClient.Clone` functionality has been removed. Please construct a new `Client` object instead.
- RestSharp dependency has been dropped entirely.
- Renamed `UnexpectedHttpError` exception type to `UnknownHttpError` to better reflect its purpose.
- Removed `UnknownApiError` exception type, consolidated into `UnknownHttpError` exception type.
- `ExternalApiError` no longer inherits from `ApiError` (`ApiError` reserved for EasyPost API errors only).
- All `EasyPostError` exceptions and subclasses now have a `PrettyPrint` getter that returns a human-readable string representation of the error.
- Previously, only `ApiError` exceptions had this. Now, all exceptions thrown by the library should have this.
- **[IMPROVED]** Logic for calculating exception type to throw based on API error
- Logic for calculating exception type to throw based on API error
- EasyPost API failures can trigger a variety of specific exceptions, all inheriting from `ApiError`.
- Non-EasyPost API/HTTP failures will trigger an `ExternalApiError` exception.

### New Features

- **[CHANGED]** [Parameter sets](#v450-2023-03-22) are out of beta. Users can use access them via `EasyPost.Parameters` namespace.
- [Parameter sets](#v450-2023-03-22) are out of beta. Users can use access them via `EasyPost.Parameters` namespace.
- Previous plural namespaces are now singular (eg: `Parameters.Addresses` is now `Parameters.Address`)
- **[ADDED]** All API-calling functions accept an optional `CancellationToken` parameter that can be used to cancel the request.
- **[ADDED]** Reintroduce `GenerateForm` function for shipments that was accidentally removed in `v4`.
- **[ADDED]** All `EasyPostClient`-based classes, all `EasyPostService`-based classes, `ClientConfiguration` and internal request classes are now explicitly disposable.
- All API-calling functions accept an optional `CancellationToken` parameter that can be used to cancel the request.
- Reintroduce `GenerateForm` function for shipments that was accidentally removed in `v4`.
- All `EasyPostClient`-based classes, all `EasyPostService`-based classes, `ClientConfiguration` and internal request classes are now explicitly disposable.

### Miscellaneous

- **[IMPROVED]** Add missing `Declaration` parameter to Customs Info creation parameter set
- **[IMPROVED]** Handle API timeout errors more gracefully (produce proper `TimeoutError` exception with readable messages)
- **[IMPROVED]** `myClient.Webhook.Update` function now has an optional `Parameters.Webhook.Update` parameter (rather than required)
- **[IMPROVED]** All aspects of the library have been documented with XML comments
- Add missing `Declaration` parameter to Customs Info creation parameter set
- Handle API timeout errors more gracefully (produce proper `TimeoutError` exception with readable messages)
- `myClient.Webhook.Update` function now has an optional `Parameters.Webhook.Update` parameter (rather than required)
- All aspects of the library have been documented with XML comments

## v4.6.0 (2023-04-18)

Expand Down
2 changes: 1 addition & 1 deletion EasyPost.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>EasyPost-Official</id>
<title>EasyPost (Official)</title>
<version>4.6.0</version>
<version>5.0.0</version>
<authors>EasyPost</authors>
<owners>EasyPost</owners>
<projectUrl>https://www.easypost.com</projectUrl>
Expand Down
6 changes: 3 additions & 3 deletions EasyPost/Properties/VersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

// Version information for an assembly must follow semantic versioning
// When releasing a release candidate, append a 4th digit being the number of the release candidate
[assembly: AssemblyVersion("4.6.0")]
[assembly: AssemblyFileVersion("4.6.0")]
[assembly: AssemblyInformationalVersion("4.6.0")]
[assembly: AssemblyVersion("5.0.0")]
[assembly: AssemblyFileVersion("5.0.0")]
[assembly: AssemblyInformationalVersion("5.0.0")]
91 changes: 42 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,71 +26,68 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using EasyPost;
using Newtonsoft.Json;
using EasyPost.Parameters;

namespace example
{
class exampleClass
{
static async Task Main()
{
Client client = new Client(Environment.GetEnvironmentVariable("EASYPOST_API_KEY"));

Shipment shipment = await client.Shipment.Create(new Dictionary<string, object>()
{
{
"to_address", new Dictionary<string, object>()
{
{ "name", "Dr. Steve Brule" },
{ "street1", "179 N Harbor Dr" },
{ "city", "Redondo Beach" },
{ "state", "CA" },
{ "zip", "90277" },
{ "country", "US" },
{ "phone", "8573875756" },
{ "email", "[email protected]" }
}
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]"
},
{
"from_address", new Dictionary<string, object>()
{
{ "name", "EasyPost" },
{ "street1", "417 Montgomery Street" },
{ "street2", "5th Floor" },
{ "city", "San Francisco" },
{ "state", "CA" },
{ "zip", "94104" },
{ "country", "US" },
{ "phone", "4153334445" },
{ "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 Dictionary<string, object>()
{
{ "length", 20.2 },
{ "width", 10.9 },
{ "height", 5 },
{ "weight", 65.9 }
}
Parcel = new Parameters.Parcel.Create {
Length = 20.2,
Width = 10.9,
Height = 5,
Weight = 65.9
}
});
}

await shipment.Buy(shipment.LowestRate());
Shipment shipment = await client.Shipment.Create(parameters);

Rate rate = shipment.LowestRate();

Paramaters.Shipment.Buy buyParameters = new(rate);

Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented));
Shipment purchasedShipment = await client.Shipment.Buy(shipment.Id, buyParameters);

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

### Configuration

A `Client` object is the entry point into the EasyPost API. It is instantiated with your API key:
A `Client` object is the entry point into the EasyPost API. It is instantiated with a `ClientConfiguration` with your API key:

```csharp
using EasyPost;

Client myClient = new Client("EASYPOST_API_KEY");
Client myClient = new Client(new ClientConfiguration("EASYPOST_API_KEY"));
```

An API key is required for all requests. You can find your API key in
Expand Down Expand Up @@ -129,17 +126,13 @@ Shipment myShipment = await myClient.Shipment.Create(new Dictionary<string, obje
});
```

Functions involving a specific resource are then enacted on that resource. For example, to buy the shipment:
All API-calling functions are made from the appropriate service object (rather than against the resource object), by providing the ID of the related resource. For example, to buy a shipment:

```csharp
await myShipment.Buy(myShipment.LowestRate());
Shipment myPurchasedShipment = await myClient.Shipment.Buy(myShipment.Id, myShipment.LowestRate());
```

Any generated local resource will have stored internally the same client used to create or retrieve them. Any API call
made against the resource will automatically use the same client. This will prevent potential issues of accidentally
using the wrong API key when interacting with a resource in a multi-client environment.

## Parameters (BETA)
## Parameters

Most functions in this library accept a `Dictionary<string, object>` as their sole parameter, which is ultimately used as the body of the HTTP request against EasyPost's API. If you instead would like to use .NET objects to construct API call parameters, you can use the various `Parameters` classes (currently in beta).

Expand Down

0 comments on commit 5e2919c

Please sign in to comment.