-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from easykeys/easykeys/bug/amazon/rates
Update shipping rate provider and version to 5.2.0
- Loading branch information
Showing
7 changed files
with
38 additions
and
17 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
mode: Mainline | ||
next-version: 5.1.0 | ||
next-version: 5.2.0 | ||
branches: | ||
feature: | ||
tag: preview | ||
|
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
using EasyKeys.Shipping.Amazon.Abstractions.OpenApis.V2.Shipping; | ||
using EasyKeys.Shipping.Amazon.Abstractions.Options; | ||
using EasyKeys.Shipping.Amazon.Abstractions.Services; | ||
using EasyKeys.Shipping.Amazon.Rates.Models; | ||
|
||
using Microsoft.Extensions.Logging; | ||
|
||
|
@@ -27,7 +28,7 @@ public AmazonShippingRateProvider( | |
_shippingApi.BaseUrl = _options.IsDevelopment ? _shippingApi.BaseUrl : "https://sellingpartnerapi-na.amazon.com"; | ||
} | ||
|
||
public async Task<Shipment> GetRatesAsync(Shipment shipment, CancellationToken cancellationToken = default) | ||
public async Task<Shipment> GetRatesAsync(Shipment shipment,RateContactInfo rateContactInfo, CancellationToken cancellationToken = default) | ||
Check warning on line 31 in src/EasyKeys.Shipping.Amazon.Rates/AmazonShippingRateProvider.cs GitHub Actions / build
|
||
{ | ||
try | ||
{ | ||
|
@@ -36,14 +37,16 @@ public async Task<Shipment> GetRatesAsync(Shipment shipment, CancellationToken c | |
ShipDate = shipment.Options.ShippingDate.ToString("yyyy-MM-dd'T'HH:mm:ss'Z'"), | ||
ShipTo = new Abstractions.OpenApis.V2.Shipping.Address() | ||
{ | ||
Name = "unknown name", | ||
AddressLine1 = shipment.DestinationAddress.StreetLine, | ||
AddressLine2 = shipment.DestinationAddress.StreetLine2, | ||
StateOrRegion = shipment.DestinationAddress.StateOrProvince, | ||
City = shipment.DestinationAddress.City, | ||
CountryCode = shipment.DestinationAddress.CountryCode, | ||
PostalCode = shipment.DestinationAddress.PostalCode, | ||
PhoneNumber = "unknown phone number" | ||
Name = rateContactInfo.RecipientContact.FullName, | ||
Email = rateContactInfo.RecipientContact.Email, | ||
CompanyName = rateContactInfo.RecipientContact.Company, | ||
PhoneNumber = rateContactInfo.RecipientContact.PhoneNumber | ||
}, | ||
ShipFrom = new Abstractions.OpenApis.V2.Shipping.Address() | ||
{ | ||
|
@@ -53,10 +56,10 @@ public async Task<Shipment> GetRatesAsync(Shipment shipment, CancellationToken c | |
City = shipment.OriginAddress.City, | ||
CountryCode = shipment.OriginAddress.CountryCode, | ||
PostalCode = shipment.OriginAddress.PostalCode, | ||
Name = "Easykeys fullfuilment team", | ||
Email = "[email protected]", | ||
CompanyName = "EasyKeys", | ||
PhoneNumber = "unknown phone number" | ||
Name = rateContactInfo.SenderContact.FullName, | ||
Email = rateContactInfo.SenderContact.Email, | ||
CompanyName = rateContactInfo.SenderContact.Company, | ||
PhoneNumber = rateContactInfo.SenderContact.PhoneNumber | ||
}, | ||
Packages = new () | ||
{ | ||
|
@@ -72,7 +75,7 @@ public async Task<Shipment> GetRatesAsync(Shipment shipment, CancellationToken c | |
Weight = new () | ||
{ | ||
Unit = WeightUnit.POUND, | ||
Value = (double)shipment.Packages.Sum(x => x.RoundedWeight) | ||
Value = (double)shipment.Packages.Sum(x => x.Weight) | ||
}, | ||
InsuredValue = new () | ||
{ | ||
|
@@ -86,7 +89,8 @@ public async Task<Shipment> GetRatesAsync(Shipment shipment, CancellationToken c | |
{ | ||
Weight = new () | ||
{ | ||
Unit = WeightUnit.POUND | ||
Unit = WeightUnit.POUND, | ||
Value = (double)shipment.Packages.Sum(x => x.Weight) | ||
}, | ||
LiquidVolume = new () | ||
{ | ||
|
3 changes: 2 additions & 1 deletion
3
src/EasyKeys.Shipping.Amazon.Rates/IAmazonShippingRateProvider.cs
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
using EasyKeys.Shipping.Abstractions.Models; | ||
using EasyKeys.Shipping.Amazon.Rates.Models; | ||
|
||
namespace EasyKeys.Shipping.Amazon.Rates; | ||
|
||
public interface IAmazonShippingRateProvider | ||
{ | ||
Task<Shipment> GetRatesAsync(Shipment shipment, CancellationToken cancellationToken = default); | ||
Task<Shipment> GetRatesAsync(Shipment shipment, RateContactInfo rateContactInfo, CancellationToken cancellationToken = default); | ||
} |
16 changes: 16 additions & 0 deletions
16
src/EasyKeys.Shipping.Amazon.Rates/Models/RateContactInfo.cs
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,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using EasyKeys.Shipping.Abstractions.Models; | ||
|
||
namespace EasyKeys.Shipping.Amazon.Rates.Models; | ||
|
||
public class RateContactInfo | ||
{ | ||
public ContactInfo SenderContact { get; set; } = new (); | ||
|
||
public ContactInfo RecipientContact { get; set; } = new (); | ||
} |
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