Coder Social home page Coder Social logo

easypost / easypost-csharp Goto Github PK

View Code? Open in Web Editor NEW
66.0 66.0 74.0 15.67 MB

EasyPost Shipping API Client Library for .NET and .NET Framework applications

Home Page: https://easypost.com/docs/api

License: MIT License

C# 98.51% Shell 0.23% F# 0.04% Visual Basic .NET 0.04% Batchfile 0.72% Makefile 0.46%
client

easypost-csharp's People

Contributors

adamchester avatar ben10ger avatar chamby avatar cwoolum avatar davitgr avatar epclee avatar eschutho avatar giorgio-montagnoli avatar hellbinder avatar humbersoft avatar jchen293 avatar jmalatia avatar jontsai avatar justintime50 avatar kcamp avatar kevinalexliu avatar leehester avatar marina-ep avatar mjmatthiesen avatar mwaldt avatar mxmissile avatar nwithan8 avatar rbellow avatar ryannguyen16 avatar sawyer avatar scotthendrickson avatar scrivy avatar swrhim avatar umitgnr avatar whoiskevinrich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

easypost-csharp's Issues

Could not load file or assembly 'RestSharp, Version=100.0.0.0...

When trying to use this package, getting the error: "Could not load file or assembly 'RestSharp, Version=100.0.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"

EasyPost API errors

Receiving data related errors (address errors) and environment errors via the EasyPostException. How can we tell the difference between data related errors from environmental errors?
There is a verifyAddress object getMessage that returns null when successful. Can all data related errors be returned via the verifyAddress.getMessage()?
When coding an interface, it simplifies the coding if we provide to very distinct path for returning Exceptions.
Or if it is imperative to return data errors via an Exception, can you create an EasyPostDataException?
Or simply move all the environmental Exceptions to the JAVA Exception.

Thanks for your time and support.

Error for "Create Shipment" Method

Hi,

at this url
https://www.easypost.com/docs/api/csharp.html#shipments-create-codesample
I find a C# sample that I have implemented in this way

static void Main(string[] args)
{
  ClientManager.SetCurrent(() => new Client(new ClientConfiguration("xjv...VTQ")));
 
  var fromAddress = new Address
  {
    name = "EasyPost",
    street1 = "417 Montgomery Street",
    street2 = "5th Floor",
    city = "San Francisco",
    state = "CA",
    zip = "94104",
    country = "US",
    phone = "4153334444",
    email = "[email protected]"
  };
 
  // verifications: non genera errore
  // strictVerifications: solleva una EasyPost.HttpException
  fromAddress.Create(strictVerifications: new List<string>() { "delivery" });
 
  var toAddress = new Address
  {
    name = "Dr. Steve Brule",
    street1 = "179 N Harbor Dr",
    city = "Redondo Beach",
    state = "CA",
    zip = "90277",
    country = "US",
    phone = "4153334444"
  };
 
  toAddress.Create(strictVerifications: new List<string>() { "delivery" });
 
  var parcel = new Parcel
  {
    length = 20.2,
    width = 10.9,
    height = 5.0,
    weight = 140.8
  };
 
  Console.WriteLine(parcel.predefined_package);
 
  var shipment = new Shipment
  {
    to_address = toAddress,
    from_address = fromAddress,
    parcel = parcel,
    customs_info = new CustomsInfo 
    { 
      contents_type = "merchandise",
      customs_certify = "false",
      non_delivery_option = "return",
      restriction_type = "none",
      customs_items = new List<CustomsItem>
      {
        new CustomsItem
        {
          description = "Many, many EasyPost stickers.",
          hs_tariff_number = "123456",
          origin_country = "US",
          quantity = 1,
          value = 879,
          weight = 140,
        }
      }
    }
  };
 
  shipment.Create();
 
  Console.ReadLine();
}

But I've got this error

'DateTimeInvalidLocalFormat'
Additional information: This can happen when calling DateTime.ToString using the 'z' format specifier, which will include a local time zone offset in the output. In that case, either use the 'Z' format specifier, which designates a UTC time, or use the 'o' format string, which is the recommended way to persist a DateTime in text. This can also occur when passing a DateTime to be serialized by XmlConvert or DataSet. If using XmlConvert.ToString, pass in XmlDateTimeSerializationMode.RoundtripKind to serialize correctly. If using DataSet, set the DateTimeMode on the DataColumn object to DataSetDateTime.Utc.

You should be able to fix it, here
https://github.com/EasyPost/easypost-csharp/blob/master/EasyPost/Request.cs#L106
if I read the error correctly.

Can you please provide us a feedback?

Support for Latest C# and Asp.Net (DotNetCore)

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.

Null client could throw a more informative exception

Currently, if you try to create an Order without initializing the client, you get a null pointer on ClientManager.cs line 11. It would be nice if this threw a "No EasyPost Client Configured" message or similar.

Easypost.Batch.AddShipments not working properly

The below doesn't seem to work... it's not enumerating the list correctly as there is only 1 shipment returned in the batch and it is always the last shipment is the list.

batch.AddShipments(new List<string>() { "shp_KYCxvzPY", "shp_C3Cm07xW" });

The only way to get it to work is to call AddShipments multiple times with a single shipment in each call... this works and creates 2 shipments in the batch.

batch.AddShipments(new List<string>() { "shp_KYCxvzPY" });
batch.AddShipments(new List<string>() { "shp_C3Cm07xW" });

Add ScanForm.batch_id

This would be really helpful for associating the scan_form.updated event with the parent batch.

C# Library - ScanForm.Create is failing

I've been trying for several days to get an answer to how to make ScanForm.Create work, both here in github and with your support channels. My prior ticket (#76) was closed, and I was directed to look at the unit test for ScanForm:

https://github.com/EasyPost/easypost-csharp/blob/master/EasyPostTest/ScanFormTest.cs

I created my own test shipment to plugin to the TestScanFormCreateAndRetrieve test, and it fails. I wrote a few more tests (one that attempts to create a ScanForm from an unpurchased shipment, and one that attempts to buy the shipment, THEN create ScanForm), and neither works. Could someone on your team please run these tests? My hope is you'll quickly see what I'm seeing, and be able to address. I'm assuming this is an issue with the C# client, as there must be someone generating ScanForms correctly within your system? Any help appreciated, this is holding us up from turning on our EasyPost implementation.


    [TestFixture]
    class TestScanFormFixture
    {
        private string _apiKey = "<INSERT KEY>";

        [SetUp]
        public void SetUp()
        {
            ClientManager.SetCurrent(() => new Client(new ClientConfiguration(_apiKey)));
        }

        [Test]
        public void TestScanFormCreateAndRetrieve()
        {
            // XXX: This is not repeatable. Need a new shipment id each time.
            List<Shipment> shipments = new List<Shipment>() {
                new Shipment() { id = "shp_abc5c7d6af9f4af894e1ef17bcf74311" }
            };

            ScanForm scanForm = ScanForm.Create(shipments);
            Assert.IsNotNull(scanForm.id);

            ScanForm otherScanForm = ScanForm.Retrieve(scanForm.id);
            Assert.AreEqual(scanForm.id, otherScanForm.id);
        }

        [Test]
        public void CreateShipmentWithoutBuyingAndCreateScanForm()
        {
            var address1 = new Address
            {
                name = "Frank Smidlap",
                company = "Great Company",
                street1 = "100 N Main St",
                street2 = null,
                city = "Chicago",
                state = "IL",
                country = "US",
                zip = "60601",
                phone = "3122011234"
            };
            address1.Create();

            var address2 = new Address
            {
                name = "Francine Smidlap",
                company = "Great Company",
                street1 = "200 N Main St",
                street2 = null,
                city = "Chicago",
                state = "IL",
                country = "US",
                zip = "60601",
                phone = "3122011234"
            };
            address2.Create();

            Shipment shipment = new Shipment()
            {
                from_address = address1,
                to_address = address2,
                parcel = new Parcel
                {
                    weight = .01,
                    mode = "test",
                    predefined_package = "Letter"
                },
                options = new Options
                {
                    label_date = DateTime.Now.AddDays(2).Date
                },
            };
            shipment.Create();

            ScanForm scanForm = ScanForm.Create(new List<Shipment>() { shipment });
            Assert.IsNotNull(scanForm.id);

        }
        [Test]
        public void CreateShipmetThenBuyAndCreateScanForm()
        {
            var address1 = new Address
            {
                name = "Frank Smidlap",
                company = "Great Company",
                street1 = "100 N Main St",
                street2 = null,
                city = "Chicago",
                state = "IL",
                country = "US",
                zip = "60601",
                phone = "3122011234"
            };
            address1.Create();

            var address2 = new Address
            {
                name = "Francine Smidlap",
                company = "Great Company",
                street1 = "200 N Main St",
                street2 = null,
                city = "Chicago",
                state = "IL",
                country = "US",
                zip = "60601",
                phone = "3122011234"
            };
            address2.Create();

            Shipment shipment = new Shipment()
            {
                from_address = address1,
                to_address = address2,
                parcel = new Parcel
                {
                    weight = .01,
                    mode = "test",
                    predefined_package = "Letter"
                },
                options = new Options
                {
                    label_date = DateTime.Now.AddDays(2).Date
                },
            };
            shipment.Create();
            shipment.Buy(shipment.rates.First());

            ScanForm scanForm = ScanForm.Create(new List<Shipment>() { shipment });
            Assert.IsNotNull(scanForm.id);

        }
    }

Tracker is missing many elements

Within the tracker return there are many missing objects. For example: Tracking_Location, est_delivery_date,signed_by and others. Am I missing something obvious here?

RestSharp and Newtonsoft JSON references

I already have those packages installed in their latest version (105.2.3 and 9.0.1) , but after adding EasyPost package to my project, they get overwritten by EasyPosts older own dll versions.

EasyPost operations seem to revert System.Net.ServicePointManager.SecurityProtocol to Tls

We are operating a site that has some integrations that require Tls12, and recently noticed that after invoking a call using easypost-csharp (for example, "address.Create"), our system's SecurityProtocol had been downgraded to Tls. Looking at your code, I see the following in security.cs:

        public static SecurityProtocolType GetProtocol() {
#if NET45
            return SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
#else
            return SecurityProtocolType.Tls;
#endif
        }
    }

I couldn't find where this NET45 precompiler flag was getting set, but the version we're using seems to be setting things to "SecurityProtocolType.Tls". Here's the version we're using:

<package id="EasyPost-Official" version="2.2.6" targetFramework="net45" />

WIP?

I'm assuming this project is a WIP correct? Or am I missing something, the code in the ReadMe does not compile as is. If so are you taking pull requests?

NuGet install error - File contains corrupted data

I am unable to install via NuGet. The Package Manager Console gives this error:

PM> Install-Package EasyPost-Official
Attempting to resolve dependency 'Newtonsoft.Json (≥ 6.0.3)'.
Install-Package : File contains corrupted data.
At line:1 char:1
+ Install-Package EasyPost-Official
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], FileFormatException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
 PM> 

Do you have any ideas or documentation on a manual install? Thanks.

Carrier Is missing in tracker

Carrier is missing in tracker object. It is listed in the docs but not in the SDK. Also the API states est_delivery_date and in the SDK it is est_delivery_days, which seems to result in nothing on every call

Address CreateandVerify requires param

When attempting to send in an object of Address to CreateAndVerify, service returns street missing. This only occurs when I only send in the AddressObject, if I send in the parameters as a dictionary the return is correct.

Question regarding the Easy Post API

I was testing out your API. I downloaded the DLL from Nuget Package.

There is some sample code given there.
I tried out the code that gets me Rates for a shipment.
However, I do not see anywhere where there is a call made to the Easy Post Web Service. I think due to this, I am getting Object Reference not set to an instance of object error at the code highlighted in bold.
foreach (Rate rate in shipment.rates)
{
RateinDollar = rate.rate;
// process rates
}

I also downloaded the C# code from gihub and opened the Project in Visual Studio. Even there I did not see anything under the Service Reference folder. Is there something I am missing? Please let me know

Shipment_Postage_Failure

System was working fine for over 6 months but now getting HttpException error when using UPS, SHIPMENT.POSTAGE.FAILURE, "message":"Missing or invalid ship to attention name"

This happens only when an attempted rate is purchased

UK deliveries are fine, it's just international consignments

Regards

Adam Wright FIAP
TWS

Price Estimations

Does easy post support price estimations ? It would be nice to know how much a transaction will cost before executing the transaction. If so, how ?

New issue RestSharp and Newtonsoft JSON references

This is the same issue as #50 which was closed.

When I add the EasyPost-Official package to my project via NuGet, it overwrites my existing Newtonsoft and RestSharp references. Even though RestSharp 105.2.3 is specified as a dependency for EasyPost, it replaces it with RestSharp 100.0.0.0.

Add Events to library

Need a way to handle Events including the ability to load from the JSON sent by EasyPost

Shipment.Create() error when TLS 1.0 is disabled

When we disable TLS 1.0 on our server, we get the following error when calling Shipment.Create():

System.NullReferenceException: Object reference not set to an instance of an object.  
at EasyPost.Resource.Merge(Object source)  
at EasyPost.Shipment.Create()  

Is there a dependency on TLS 1.0? We have no issues with it enabled.

Accessing request/response json for logging

It would be nice to have access to the request and response JSON for logging purposes.

I'm not sure exactly how to go about that in a simple way from the existing design, though, since the methods all create the requests, pass them to client, and interpret the responses. You'd sort of need to CQRS-ify it so that there are variants of the methods that just create the response and return it, leaving the programmer responsible for handing it to the client if they actually want it to execute. And once you do that you realize that you probably want the type parameter to be on Request<T> in addition to the type parameter dangling off the Execute<T>(Request ...) method, so that you could have Execute<T>(Request<T> ... ). And it doesn't play 100% nicely with the Merge approach since weird things would happen if you executed the same request twice, but you could just make that case be an exception.

Plus I'm not sure how to get RestSharp to cough up this information either, for similar reasons.

There's got to be a simpler way. I'd almost think about introducing an HTTP proxy and scraping it from there. RestClient does support using an IWebProxy...

ScanForm.Create failing

I'm attempting to use the ScanForm.Create functionality, passing local Shipments (with just their "id" property populated), and am seeing the following error returned:

{"error":{"code":"SCAN_FORM.CREATE.FAILURE","message":"Unable to create manifest. 2 of the specified shipments were not found: shp_8b44037ea7fb4294a19a3412da786942, shp_195c3f7bfe564d4889769a97e4f52f3e","errors":[]}}

I have confirmed that both of these shipments exist in our test environment.

No Async support?

This library currently does not have any support for Async network calls? I might modify the code for the library to make it async myself, but I am curious why async support was not added from the start?

Date Created/updated returns nothing

Prior to this recent update when an address was created " date created" and "date updated" returns a date. Now they return nothing and it was not obvious that this became nullable.

Parcel.cs

According to API docs, parcel length, width, height and weight should be double. Current code shows just the weight as double and length, width and height as integers. Length, width and height should be changed to double.

public class Parcel : IResource {
        public string id { get; set; }
        public DateTime created_at { get; set; }
        public DateTime updated_at { get; set; }
        public **int** length { get; set; }
        public **int** width { get; set; }
        public **int** height { get; set; }
        public double weight { get; set; }
        public string predefined_package { get; set; }
        public string mode { get; set; }

Also, what was the reasoning for removing the enums for (e.g. predefined_package) in the latest build?

Cannot use shipment.Create with a predefined package

Maybe I've missed something, but right now the EasyPost API is returning an error when I try to call .Create() on an instance of a Shipment like so:

var shipment = new Shipment()
{
    to_address = ...,
    from_address = ...,
    parcel = new Parcel()
    {
        weight = 16,
        predefined_package = "UPSLetter"
    }
};

shipment.Create();

The error returned says "Validation failed: Length is required when dimensions are supplied with parcel, Width is required when dimensions are supplied with parcel, Height is required when dimensions are supplied with parcel".

It's being raised because the client is sending shipment[parcel][length]=0, shipment[parcel][width]=0 and shipment[parcel][height]=0, rather than allowing null values when a predefined package is present.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.