-
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.
[chore] Add missing GenerateForm function (#469)
- Add missing GenerateForm function - Add unit tests for GenerateForm function - Add assertion utility to confirm nothing in enumerable matches
- Loading branch information
Showing
12 changed files
with
829 additions
and
2 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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Xunit.Sdk; | ||
|
||
namespace EasyPost.Tests._Utilities.Assertions | ||
{ | ||
/// <summary> | ||
/// Exception thrown when a None assertion has one or more items fail an assertion. | ||
/// </summary> | ||
public class NoneException : XunitException | ||
{ | ||
/// <summary> | ||
/// Creates a new instance of the <see cref="NoneException"/> class. | ||
/// </summary> | ||
public NoneException() | ||
: base("Assert.None() Failure") | ||
{ | ||
} | ||
} | ||
} |
155 changes: 155 additions & 0 deletions
155
EasyPost.Tests/cassettes/net/shipment_service/generate_form.json
Large diffs are not rendered by default.
Oops, something went wrong.
154 changes: 154 additions & 0 deletions
154
EasyPost.Tests/cassettes/net/shipment_service_with_parameters/generate_form.json
Large diffs are not rendered by default.
Oops, something went wrong.
154 changes: 154 additions & 0 deletions
154
EasyPost.Tests/cassettes/netstandard/shipment_service/generate_form.json
Large diffs are not rendered by default.
Oops, something went wrong.
154 changes: 154 additions & 0 deletions
154
EasyPost.Tests/cassettes/netstandard/shipment_service_with_parameters/generate_form.json
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using EasyPost.Exceptions.General; | ||
using EasyPost.Utilities.Internal.Extensions; | ||
|
||
namespace EasyPost.Parameters.Shipment | ||
{ | ||
/// <summary> | ||
/// <a href="https://www.easypost.com/docs/api#create-form">Parameters</a> for <see cref="EasyPost.Services.ShipmentService.GenerateForm(string, GenerateForm, System.Threading.CancellationToken)"/> API calls. | ||
/// </summary> | ||
[ExcludeFromCodeCoverage] | ||
public class GenerateForm : BaseParameters | ||
{ | ||
#region Request Parameters | ||
|
||
/// <summary> | ||
/// The type for the new form. | ||
/// </summary> | ||
public string? Type { get; set; } | ||
|
||
/// <summary> | ||
/// The data for the new form. | ||
/// </summary> | ||
// There's many different types of forms, so we just collect a generic dictionary of data to pass along rather than building per-form parameter sets. | ||
public Dictionary<string, object>? Data { get; set; } | ||
|
||
/// <summary> | ||
/// Override the default <see cref="BaseParameters.ToDictionary"/> method to handle the unique serialization requirements for this parameter set. | ||
/// </summary> | ||
/// <returns>A <see cref="Dictionary{TKey,TValue}"/>.</returns> | ||
/// <exception cref="MissingParameterError">Thrown when the form type was not provided.</exception> | ||
internal override Dictionary<string, object> ToDictionary() | ||
{ | ||
if (Type == null) | ||
{ | ||
throw new MissingParameterError(nameof(Type)); | ||
} | ||
|
||
Dictionary<string, object> data = Data ?? new Dictionary<string, object>(); | ||
data.Add("type", Type!); | ||
|
||
return data.Wrap("form"); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
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