We need to call a webservice which registers a shipment with either UPS or TNT. You fill in some details, call the function to register and pass json for details. Pretty basic stuff.
Shipment shipment = new Shipment
{
Services = new List<int>(),
Lines = new List<Line>()
};
shipment.Addresses = new List<Carrier.Address> {
new Carrier.Address {
Name1 = dealer.Name,
Street1 = dealer.Address, // etc
}
};
HttpResponseMessage response = mClient.Client.PostAsync(client.BaseAddress, shipment.ToJSON()).Result;
This worked fine with UPS but when using TNT an error was returned.
Some more values need to be sent for TNT to accept the order but not for UPS.
shipment.DetailGroups = new List<DetailGroup>
{
new DetailGroup
{
GroupID = 1,
new Row
{
Details = new List<Detail>
{
new Detail
{
KindID = 1,
Value = 1
},
}
}
}
};
Now instead of having a huge switch statement for every shipment API, what is a good adapter to use in this situation? I was thinking adapter but that one seems more for unifying different interfaces.