goshippo / shippo-csharp-client Goto Github PK
View Code? Open in Web Editor NEWShipping API C# library (USPS, FedEx, UPS and more)
Home Page: https://goshippo.com/docs
License: Apache License 2.0
Shipping API C# library (USPS, FedEx, UPS and more)
Home Page: https://goshippo.com/docs
License: Apache License 2.0
Is anyone actively maintaining a Shippo C# client?
Currently, this package does not work with the most current version of DotNet and C#. DotNetCore, the latest version of C# and Asp.Net has been out for over a month. Please support it.
Here are some problems I ran into trying to do a simple address validation.
Would it be possible to publish this package to Nuget?
Attempting to create a Manifest using the client wrapper doesn't appear to be working correctly.
{"detail":
"Invalid transactions 2340e41cdd2047eca4582188779c6f6d for manifest request.
Please check that the carrier (USPS) matches,
that the transactions are of the same date (2017-06-21T19:24:26.127000+00:00),
that the transactions have the correct zip code (92101),
and that the transactions have not been assigned to a different manifest."}
The above is the error you get when trying to create a manifest using the below. The date, carrier, and zip code all are the same between the manifest and the transaction.
Using the following:
private static void RunManifestExample(APIResource resource)
{
ShippoCollection<CarrierAccount> carrierAccounts = resource.AllCarrierAccount ();
string defaultCarrierAccount = "";
foreach (CarrierAccount account in carrierAccounts) {
if (account.Carrier.ToString () == "usps")
defaultCarrierAccount = account.ObjectId;
}
// to address
Hashtable toAddressTable = new Hashtable ();
toAddressTable.Add ("object_purpose", "PURCHASE");
toAddressTable.Add ("name", "Mr. Hippo");
toAddressTable.Add ("company", "Shippo");
toAddressTable.Add ("street1", "215 Clayton St.");
toAddressTable.Add ("city", "San Francisco");
toAddressTable.Add ("state", "CA");
toAddressTable.Add ("zip", "94117");
toAddressTable.Add ("country", "US");
toAddressTable.Add ("phone", "+1 555 341 9393");
toAddressTable.Add ("email", "[email protected]");
// from address
Hashtable fromAddressTable = new Hashtable ();
fromAddressTable.Add ("object_purpose", "PURCHASE");
fromAddressTable.Add ("name", "Ms Hippo");
fromAddressTable.Add ("company", "San Diego Zoo");
fromAddressTable.Add ("street1", "2920 Zoo Drive");
fromAddressTable.Add ("city", "San Diego");
fromAddressTable.Add ("state", "CA");
fromAddressTable.Add ("zip", "92101");
fromAddressTable.Add ("country", "US");
fromAddressTable.Add ("email", "[email protected]");
fromAddressTable.Add ("phone", "+1 619 231 1515");
fromAddressTable.Add ("metadata", "Customer ID 123456");
// parcel
Hashtable parcelTable = new Hashtable ();
parcelTable.Add ("length", "5");
parcelTable.Add ("width", "5");
parcelTable.Add ("height", "5");
parcelTable.Add ("distance_unit", "in");
parcelTable.Add ("weight", "2");
parcelTable.Add ("mass_unit", "lb");
List<Hashtable> parcelArray = new List<Hashtable> ();
parcelArray.Add (parcelTable);
// shipment
Hashtable shipmentTable = new Hashtable ();
shipmentTable.Add ("address_to", toAddressTable);
shipmentTable.Add ("address_from", fromAddressTable);
shipmentTable.Add ("parcels", parcelArray);
shipmentTable.Add ("object_purpose", "PURCHASE");
shipmentTable.Add ("async", false);
shipmentTable.Add ("carrier_accounts", new string [] { defaultCarrierAccount });
// create Shipment object
Console.WriteLine ("Creating Shipment object..");
Shipment shipment = resource.CreateShipment (shipmentTable);
// select desired shipping rate according to your business logic
// we simply select the first rate in this example
Console.WriteLine ("Getting shipping label..");
Hashtable transactionParameters = new Hashtable ();
transactionParameters.Add ("rate", shipment.Rates[0].ObjectId);
transactionParameters.Add ("async", false);
Transaction transaction = resource.CreateTransaction (transactionParameters);
if (((String)transaction.Status).Equals ("SUCCESS", StringComparison.OrdinalIgnoreCase)) {
Console.WriteLine ("Label url : " + transaction.LabelURL);
Console.WriteLine ("Tracking number : " + transaction.TrackingNumber);
Hashtable manifestParams = new Hashtable ();
manifestParams.Add ("carrier_account", defaultCarrierAccount);
manifestParams.Add ("address_from", shipment.AddressFrom);
manifestParams.Add ("shipment_date", transaction.ObjectCreated);
manifestParams.Add ("transactions", new string[]{ transaction.ObjectId } );
manifestParams.Add ("async", false);
Manifest manifest = resource.CreateManifest(manifestParams);
} else {
Console.WriteLine ("An Error has occured while generating your label. Messages : " + transaction.Messages);
}
}
Hello,
would it be possible for you to publish an official Nuget package for the C# client? There are third party shippo clients available in Nuget but an official would be great.
I see you guys provide a way to register a tracking webhook that takes the carrier and tracking number. However, I don't see a way to register the webhook callback url and event type. Is this something that is only available through the Shippo Dashboard, or did I miss some code somewhere that will do this through an api call?
Hello,
There seems to be a lot of fields missing from objects in this library as compared to the objects outlined in the API documentation.
Rates are missing some key fields to generate labels properly. We are not getting the shipmentid off the rate object nor are we getting the insurance amount as a couple of examples.
Are there any plans to fix this besides pinging the API directly? I might have to fork and modify.
Thanks
There is no rate return when creating multi-pieces parcel. Here is an example provided from its document.
APIResource resource = new APIResource(token);
Hashtable toAddressTable = new Hashtable();
toAddressTable.Add("name", "Mr. Hippo");
toAddressTable.Add("company", "Shippo");
toAddressTable.Add("street1", "215 Clayton St.");
toAddressTable.Add("city", "San Francisco");
toAddressTable.Add("state", "CA");
toAddressTable.Add("zip", "94117");
toAddressTable.Add("country", "US");
toAddressTable.Add("phone", "+1 555 341 9393");
toAddressTable.Add("email", "[email protected]");
Hashtable fromAddressTable = new Hashtable();
fromAddressTable.Add("name", "Ms Hippo");
fromAddressTable.Add("company", "San Diego Zoo");
fromAddressTable.Add("street1", "2920 Zoo Drive");
fromAddressTable.Add("city", "San Diego");
fromAddressTable.Add("state", "CA");
fromAddressTable.Add("zip", "92101");
fromAddressTable.Add("country", "US");
fromAddressTable.Add("email", "[email protected]");
fromAddressTable.Add("phone", "+1 619 231 1515");
fromAddressTable.Add("metadata", "Customer ID 123456");
List<Hashtable> parcelsList = new List<Hashtable>();
Hashtable parcelTable = new Hashtable();
parcelTable.Add("length", "5");
parcelTable.Add("width", "5");
parcelTable.Add("height", "5");
parcelTable.Add("distance_unit", "in");
parcelTable.Add("weight", "2");
parcelTable.Add("mass_unit", "lb");
Hashtable parcelTableTwo = new Hashtable();
parcelTableTwo.Add("length", "1");
parcelTableTwo.Add("width", "1");
parcelTableTwo.Add("height", "1");
parcelTableTwo.Add("distance_unit", "in");
parcelTableTwo.Add("weight", "2");
parcelTableTwo.Add("mass_unit", "lb");
parcelsList.Add(parcelTable);
parcelsList.Add(parcelTableTwo);
Hashtable shipmentTable = new Hashtable();
shipmentTable.Add("address_to", toAddressTable);
shipmentTable.Add("address_from", fromAddressTable);
shipmentTable.Add("parcels", parcelsList);
shipmentTable.Add("async", false);
Shipment shipment = resource.CreateShipment(shipmentTable);
Response.Write(shipment.Rates.Count().ToString()); // **output 0**
When the package is installed using nuget, it does not automatically install and reference the dll.
To fix this, we need to:
I'm running the exact same sample code included in this projects for all 3 API Tokens.
My Profile Test: Success
My Profile Live: Success
My Customer's Live: Shippo.ShippoException: '{"parcel": ["This field is required."]}'
Inner Exception: WebException: The remote server returned an error: (400) Bad Request.
Any ideas?
The response when retrieving a rate has a shipment id in it under the "shipment" key. However, I do not see this property on the Rate object.
When creating a shipment, the rate objects within the rates property of shipment are missing the carrier_account field.
Any plans to port this to .Net Core?
PRE_TRANSIT not being on the ShippoEnums.TrackingStatus causes the Newtonsoft Json serializer to crash
could be fixed by #45
The Address object should expose an is_residential field
Since tracking information is only for consumption and it is doesn't change it will be nice if the Track
class along with its related classes are immutable.
Manifest object is missing following properties:
Transactions
Errors
CarrierAccount
There is a Shippo.ServiceLevel and also a Shippo.Servicelevel - only difference is the lower case L. I can't access any of them because they're the same name. Can someone please fix this issue?
Need to support Multi-piece label_url retrieval (need to be able to pass ?rate=<object_id>)
shippo-csharp-client/Shippo/APIResource.cs
Line 308 in d87af6c
Documentation here:
I cloned the repo, opened it using VS Pro 2019, generated my shippo test API token and placed it in APIResource("mytesttoken"). Set my startup project as ShippoExample and pressed the Start button. It built with no error and started running, but the example C# app crashes at the line:
Shipment shipment = resource.CreateShipment(shipmentTable);
with the following (top few lines) from dump of the exception:
System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
--
did I miss something? (I only changed the API token and added try catch to get more exception details....
Added Shippo.Dll to my project and still cant get it working. It keeps on saying NameSpace Shippo could not be found. Is it something i am doing wrong or its an issue?
I've added metadata to every part of the transaction object creation, but I don't receive it back from the webhooks, its just null.
After extensive talks with Shippo support, (been at this for months testing packages and code changes), ultimately the only way for me to get the metadata sent to me was to also post to the tracks endpoint.
What this ended up causing was for me to receive double webhooks from Shippo due to posting to the tracks endpoint as well as having the label created through them.
Is there something I'm missing perhaps?
According to the documentation, there should be a substatus
property containing more information on the status of the package.
This can be seen in the response body:
It looks like this Fork has added this object to the response. https://github.com/dochoffiday/shippo-csharp-client within this commit dochoffiday@a00025f
Is there any chance you can merge this into the mainstream repo?
Steps to reproduce:
In Visual Studio 2015
using Shippo;
namespace TestApp
{
class Program
{
static void Main(string[] args)
{
Shipment x = new Shipment();
}
}
}
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'Shippo' could not be found (are you missing a using directive or an assembly reference?) TestApp d:\dev\test\TestApp\TestApp\Program.cs 6 Active
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.