Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prep for v5.6.0 release #514

Merged
merged 3 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## v5.6.0 (2023-08-31)

- Add ability to compare an EasyPost object to a parameter set object via `Matches` function
- Users can define a custom `Matches` function on any parameter set class
- Fix parameter set serialization that was causing issues when altering and reusing parameter sets

## v5.5.0 (2023-08-29)

- Add custom parameter sets (`CreateFedEx`, `CreateUps`) for carrier account creation API calls
Expand Down
37 changes: 37 additions & 0 deletions EasyPost.Tests/ParametersTests/ParametersTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,43 @@ public void TestParametersToDictionaryWithSubDictionary()
Assert.Equal(streetB, addressData["street1"]);
}

/// <summary>
/// This test proves that you can reuse a parameter object, and that re-serializing it will take into account any changes made to its properties since the last serialization.
/// </summary>
[Fact]
[Testing.Logic]
public void TestReusingParameterSets()
{
var parameters = new Parameters.Shipment.All
{
BeforeId = null,
};

// null values should not be serialized
var parametersDictionary = parameters.ToDictionary();
Assert.False(parametersDictionary.ContainsKey("before_id"));

parameters.BeforeId = "1";

// now that the property has a value, it should be serialized
parametersDictionary = parameters.ToDictionary();
Assert.True(parametersDictionary.ContainsKey("before_id"));
Assert.Equal("1", parametersDictionary["before_id"]);

parameters.BeforeId = "2";

// the new value should be serialized
parametersDictionary = parameters.ToDictionary();
Assert.True(parametersDictionary.ContainsKey("before_id"));
Assert.Equal("2", parametersDictionary["before_id"]);

parameters.BeforeId = null;

// null values should not be serialized
parametersDictionary = parameters.ToDictionary();
Assert.False(parametersDictionary.ContainsKey("before_id"));
}

[Fact]
[Testing.Exception]
public void TestRequiredAndOptionalParameterValidation()
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>5.5.0</version>
<version>5.6.0</version>
<authors>EasyPost</authors>
<owners>EasyPost</owners>
<projectUrl>https://www.easypost.com</projectUrl>
Expand Down
4 changes: 4 additions & 0 deletions EasyPost/Parameters/BaseParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public virtual Dictionary<string, object> ToDictionary()
// Bad stuff could happen if we allow end-users to convert a parameter object to a dictionary themselves and try to use it in the normal functions
// In particular, a lot of the normal functions do additional wrapping of their dictionaries, which would result in invalid JSON schemas being sent to the API

_parameterDictionary = new Dictionary<string, object?>();

// Construct the dictionary of all parameters
PropertyInfo[] properties = GetType().GetProperties(BindingFlags.Instance |
BindingFlags.NonPublic |
Expand Down Expand Up @@ -106,6 +108,8 @@ public virtual Dictionary<string, object> ToDictionary()
/// <returns><see cref="Dictionary{TKey,TValue}" /> of parameters.</returns>
public virtual Dictionary<string, object> ToSubDictionary(Type parentParameterObjectType)
{
_parameterDictionary = new Dictionary<string, object?>();

// Construct the dictionary of all parameters
PropertyInfo[] properties = GetType().GetProperties(BindingFlags.Instance |
BindingFlags.NonPublic |
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("5.5.0")]
[assembly: AssemblyFileVersion("5.5.0")]
[assembly: AssemblyInformationalVersion("5.5.0")]
[assembly: AssemblyVersion("5.6.0")]
[assembly: AssemblyFileVersion("5.6.0")]
[assembly: AssemblyInformationalVersion("5.6.0")]
Loading