public ActionResult <object> ShipAsync(ShippoShipping model)
        {
            APIResource resource = new APIResource("shippo_test_4b21ff87309dbb951077d18f554f1ffc1d1f9988");

            Hashtable parameters = new Hashtable();

            parameters.Add("address_to", model.address_to);
            parameters.Add("address_from", model.address_from);
            parameters.Add("parcels", model.parcels);
            parameters.Add("async", false);

            var shipmentInfo = resource.CreateShipment(parameters);

            return(shipmentInfo);
        }
        static void Main(string[] args)
        {
            // replace with your Shippo Token
            // don't have one? get more info here
            // (https://goshippo.com/docs/#overview)
            APIResource resource = new APIResource("<Shippo Token>");

            // to address
            Hashtable toAddressTable = new Hashtable();

            toAddressTable.Add("object_purpose", "PURCHASE");
            toAddressTable.Add("name", "Shippo Itle");
            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", "*****@*****.**");

            // from address
            Hashtable fromAddressTable = new Hashtable();

            fromAddressTable.Add("object_purpose", "PURCHASE");
            fromAddressTable.Add("name", "Mr 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", "*****@*****.**");
            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");

            // shipment
            Hashtable shipmentTable = new Hashtable();

            shipmentTable.Add("address_to", toAddressTable);
            shipmentTable.Add("address_from", fromAddressTable);
            shipmentTable.Add("parcel", parcelTable);
            shipmentTable.Add("object_purpose", "PURCHASE");

            // create Shipment object
            Console.WriteLine("Creating Shipment object..");
            Shipment shipment = resource.CreateShipment(shipmentTable);

            // get shipping rates
            Console.WriteLine("Generating rates for shipment " + shipment.ObjectId);
            ShippoCollection <Rate> rates = resource.GetShippingRatesSync((String)shipment.ObjectId);

            Console.WriteLine(String.Format("Obtained " + rates.Data.Count + " rates for shipment " + shipment.ObjectId));
            Rate rate = rates.Data [0];

            Console.WriteLine("Getting shipping label..");
            Hashtable transactionParameters = new Hashtable();

            transactionParameters.Add("rate", rate.ObjectId);
            Transaction transaction = resource.CreateTransactionSync(transactionParameters);


            if (((String)transaction.ObjectStatus).Equals("SUCCESS", StringComparison.OrdinalIgnoreCase))
            {
                Console.WriteLine("Label url : " + transaction.LabelURL);
                Console.WriteLine("Tracking number : " + transaction.TrackingNumber);
            }
            else
            {
                Console.WriteLine("An Error has occured while generating your label. Messages : " + transaction.Messages);
            }
        }
        static void Main(string[] args)
        {
            // replace with your Shippo Token
            // don't have one? get more info here
            // (https://goshippo.com/docs/#overview)
            APIResource resource = new APIResource ("<Shippo Token>");

            // 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", "*****@*****.**");

            // 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", "*****@*****.**");
            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");

            // shipment
            Hashtable shipmentTable = new Hashtable ();
            shipmentTable.Add ("address_to", toAddressTable);
            shipmentTable.Add ("address_from", fromAddressTable);
            shipmentTable.Add ("parcel", parcelTable);
            shipmentTable.Add ("object_purpose", "PURCHASE");
            shipmentTable.Add ("async", false);

            // 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
            Rate rate = shipment.RatesList[0];

            Console.WriteLine ("Getting shipping label..");
            Hashtable transactionParameters = new Hashtable ();
            transactionParameters.Add ("rate", rate.ObjectId);
            transactionParameters.Add ("async", false);
            Transaction transaction = resource.CreateTransaction (transactionParameters);

            if (((String) transaction.ObjectStatus).Equals ("SUCCESS", StringComparison.OrdinalIgnoreCase)) {
                Console.WriteLine ("Label url : " + transaction.LabelURL);
                Console.WriteLine ("Tracking number : " + transaction.TrackingNumber);
            } else {
                Console.WriteLine ("An Error has occured while generating your label. Messages : " + transaction.Messages);
            }
        }
        public void Test()
        {
            var resource = new APIResource("shippo_live_c436088fca4e8ddee7df15da1c46458777e9d687");

            // Create address (from)
            var fromAdr = new Hashtable();

            fromAdr.Add("name", "Mr. Thierry Habart");
            fromAdr.Add("street1", "223 avenue des croix du feu");
            fromAdr.Add("city", "BRUXELLES");
            fromAdr.Add("zip", "1020");
            fromAdr.Add("country", "BE");
            fromAdr.Add("phone", "0485350536");
            fromAdr.Add("email", "*****@*****.**");

            var fromAddress = resource.CreateAddress(fromAdr);

            // Create address (to)
            var toAdr = new Hashtable();

            toAdr.Add("name", "Mr. Donabedian David");
            toAdr.Add("street1", "rue solleveld 20");
            toAdr.Add("city", "BRUXELLES");
            toAdr.Add("zip", "1200");
            toAdr.Add("country", "BE");
            toAdr.Add("phone", "0485350536");
            toAdr.Add("email", "*****@*****.**");

            var toAddress = resource.CreateAddress(toAdr);

            // Create a parcel (colis)
            var parcel = new Hashtable();

            parcel.Add("length", 5);
            parcel.Add("width", 5);
            parcel.Add("height", 5);
            parcel.Add("distance_unit", "cm");
            parcel.Add("weight", 2);
            parcel.Add("mass_unit", "kg");

            var p = resource.CreateParcel(parcel);

            // Create shippment.
            var shippment  = new Hashtable();
            var lstParcels = new List <string> {
                p.ObjectId
            };

            shippment.Add("address_to", toAddress.ObjectId);
            shippment.Add("address_from", fromAddress.ObjectId);
            shippment.Add("object_purpose", "PURCHASE");
            shippment.Add("parcels", lstParcels);
            shippment.Add("insurance_currency", "EUR");
            shippment.Add("insurance_amount", 0);
            shippment.Add("submission_type", "DROPOFF");
            shippment.Add("submission_date", "2017-09-04T23:59:50+00:00");
            var ship = resource.CreateShipment(shippment);

            // Get rates
            var    rates = resource.GetShippingRatesSync(ship.ObjectId);
            string s     = "";
        }
        static void Main(string[] args)
        {
            // replace with your Shippo Token
            // don't have one? get more info here
            // (https://goshippo.com/docs/#overview)
            APIResource resource = new APIResource("<Shippo Token>");

            // to address
            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", "*****@*****.**");

            // from address
            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", "*****@*****.**");
            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");

            // shipment
            Hashtable shipmentTable = new Hashtable();

            shipmentTable.Add("address_to", toAddressTable);
            shipmentTable.Add("address_from", fromAddressTable);
            shipmentTable.Add("parcel", parcelTable);
            shipmentTable.Add("object_purpose", "PURCHASE");
            shipmentTable.Add("async", false);

            // 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
            Rate rate = shipment.Rates[0];

            Console.WriteLine("Getting shipping label..");
            Hashtable transactionParameters = new Hashtable();

            transactionParameters.Add("rate", rate.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);
            }
            else
            {
                Console.WriteLine("An Error has occured while generating your label. Messages : " + transaction.Messages);
            }

            Console.WriteLine("\nBatch\n");
            RunBatchExample(resource);

            Console.WriteLine("\nTrack\n");
            RunTrackingExample(resource);
        }
        public object Post(ShippmentDTO request)
        {
            //APIResource resource = new APIResource("shippo_test_5f00f661c1f2f19191bfba82cc8575fddb06c202");
            //APIResource resource = new APIResource("shippo_live_b248c98357917b42d991df307d6573359a901ea9");
            try {
                //to address
                Hashtable toAddressTable = new Hashtable();
                toAddressTable.Add("name", request.To.Name);
                toAddressTable.Add("company", request.To.Company);
                toAddressTable.Add("street_no", request.To.StreetNumber);
                toAddressTable.Add("street1", request.To.Street1);
                toAddressTable.Add("city", request.To.City);
                toAddressTable.Add("state", request.To.State);
                toAddressTable.Add("zip", request.To.Zip);
                toAddressTable.Add("country", request.To.Country);
                toAddressTable.Add("validate", "false");

                Address address = resource.CreateAddress(toAddressTable);

                // from address
                Hashtable fromAddressTable = new Hashtable();
                fromAddressTable.Add("name", request.From.Name);
                fromAddressTable.Add("company", request.From.Company);
                fromAddressTable.Add("street_no", request.From.StreetNumber);
                fromAddressTable.Add("street1", request.From.Street1);
                fromAddressTable.Add("city", request.From.City);
                fromAddressTable.Add("state", request.From.State);
                fromAddressTable.Add("zip", request.From.Zip);
                fromAddressTable.Add("country", request.From.Country);
                fromAddressTable.Add("validate", "false");

                List <Hashtable> parcels = new List <Hashtable>();

                foreach (var parcel in request.Parcels)
                {
                    Hashtable parcelTable = new Hashtable();
                    parcelTable.Add("length", parcel.Length);
                    parcelTable.Add("width", parcel.Width);
                    parcelTable.Add("height", parcel.Height);
                    parcelTable.Add("distance_unit", parcel.Distance_unit);
                    parcelTable.Add("weight", parcel.Weight);
                    parcelTable.Add("mass_unit", parcel.Mass_unit);
                    parcels.Add(parcelTable);
                }

                var apiResponse = resource.CreateShipment(new Hashtable()
                {
                    { "address_to", toAddressTable },
                    { "address_from", fromAddressTable },
                    { "parcels", parcels },
                    { "async", false }
                });

                var response = "{\"success\": \"success\" ," +
                               "\"shipment_id\" : \"" + apiResponse.ObjectId + "\"," +
                               "\"rates\" : " + JSON.stringify(apiResponse.Rates) + "}";

                return(response);
            }
            catch (Exception e)
            {
                var response = "{\"error\": \"exception caught by server\" ," +
                               "\"details\" : " + e.Message.ToString() + "}";
                return(response);
            }
        }