Skip to content

Commit 53e6851

Browse files
authored
fix: correct usage of line items shipment property (closes #645) (#646)
# Description See #645 for more details, this corrects it. <!-- Please provide a general summary of your PR changes and link any related issues or other pull requests. --> # Testing Added `line_items` to a shipment in a test and it successfully passed the params with this change. <!-- Please provide details on how you tested this code. See below. - All pull requests must be tested (unit tests where possible with accompanying cassettes, or provide a screenshot of end-to-end testing when unit tests are not possible) - New features must get a new unit test - Bug fixes/refactors must re-record existing cassettes --> # Pull Request Type Please select the option(s) that are relevant to this PR. - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Improvement (fixing a typo, updating readme, renaming a variable name, etc)
1 parent 1983fe7 commit 53e6851

4 files changed

Lines changed: 42 additions & 18 deletions

File tree

EasyPost/Models/API/LineItem.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using EasyPost._base;
2+
using Newtonsoft.Json;
3+
4+
namespace EasyPost.Models.API
5+
{
6+
/// <summary>
7+
/// Class representing line items of a <a href="https://docs.easypost.com/docs/shipments">Shipment</a>.
8+
/// </summary>
9+
public class LineItem : EasyPostObject, Parameters.ILineItemParameter
10+
{
11+
#region JSON Properties
12+
13+
/// <summary>
14+
/// The total value of the line item.
15+
/// </summary>
16+
[JsonProperty("total_line_value")]
17+
public string? TotalLineValue { get; set; }
18+
19+
/// <summary>
20+
/// The description of the item.
21+
/// </summary>
22+
[JsonProperty("item_description")]
23+
public string? ItemDescription { get; set; }
24+
25+
#endregion
26+
}
27+
}

EasyPost/Models/API/Shipment.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ public class Shipment : EasyPostObject, Parameters.IShipmentParameter
7777
[JsonProperty("is_return")]
7878
public bool? IsReturn { get; set; }
7979

80+
/// <summary>
81+
/// A list of <see cref="LineItem"/>s associated with the shipment.
82+
/// </summary>
83+
[JsonProperty("line_items")]
84+
public List<LineItem>? LineItems { get; set; }
85+
8086
/// <summary>
8187
/// A list of any carrier errors that occurred during rating or purchasing.
8288
/// </summary>

EasyPost/Parameters/IParameter.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ public interface IInsuranceParameter : IParameter
6363
{
6464
}
6565

66+
/// <summary>
67+
/// An interface marking that an instance of the implementing class can be used as a line item parameter in a Parameters object.
68+
/// </summary>
69+
public interface ILineItemParameter : IParameter
70+
{
71+
}
72+
6673
/// <summary>
6774
/// An interface marking that an instance of the implementing class can be used as an order parameter in a Parameters object.
6875
/// </summary>

EasyPost/Parameters/Shipment/Create.cs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -155,27 +155,11 @@ public class Create : BaseParameters<Models.API.Shipment>, IShipmentParameter
155155
public List<string>? CarrierAccountIds { get; set; }
156156

157157
/// <summary>
158-
/// A list of line items for the new <see cref="Models.API.Shipment"/>.
158+
/// A list of <see cref="Models.API.LineItem"/>s for the new <see cref="Models.API.Shipment"/>.
159159
/// </summary>
160160
[TopLevelRequestParameter(Necessity.Optional, "shipment", "line_items")]
161161
[NestedRequestParameter(typeof(Order.Create), Necessity.Optional, "line_items")]
162-
public List<LineItem>? LineItems { get; set; }
163-
164-
/// <summary>
165-
/// Represents a line item for a shipment.
166-
/// </summary>
167-
public class LineItem
168-
{
169-
/// <summary>
170-
/// The total value of the line item.
171-
/// </summary>
172-
public string? TotalLineValue { get; set; }
173-
174-
/// <summary>
175-
/// The description of the item.
176-
/// </summary>
177-
public string? ItemDescription { get; set; }
178-
}
162+
public List<ILineItemParameter>? LineItems { get; set; }
179163

180164
#endregion
181165
}

0 commit comments

Comments
 (0)