Ejemplo n.º 1
0
        /// <summary>
        /// Send a refund request to the carrier the shipment was purchased from.
        /// </summary>
        public void Refund()
        {
            Request request = new Request("shipments/{id}/refund");

            request.AddUrlSegment("id", id);

            ResourceExtension.Merge(this, client.Execute <Shipment>(request));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Generate a postage label for this shipment.
        /// </summary>
        /// <param name="fileFormat">Format to generate the label in. Valid formats: "pdf", "zpl" and "epl2".</param>
        public void GenerateLabel(string fileFormat)
        {
            Request request = new Request("shipments/{id}/label");

            request.AddUrlSegment("id", id);
            // This is a GET, but uses the request body, so use ParameterType.GetOrPost instead.
            request.AddParameter("file_format", fileFormat, ParameterType.GetOrPost);

            ResourceExtension.Merge(this, client.Execute <Shipment>(request));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Insure shipment for the given amount.
        /// </summary>
        /// <param name="amount">The amount to insure the shipment for. Currency is provided when creating a shipment.</param>
        public void Insure(double amount)
        {
            Request request = new Request("shipments/{id}/insure", Method.POST);

            request.AddUrlSegment("id", id);
            request.addBody(new List <Tuple <string, string> >()
            {
                new Tuple <string, string>("amount", amount.ToString())
            });

            ResourceExtension.Merge(this, client.Execute <Shipment>(request));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Purchase the shipments within this order with a carrier and service.
        /// </summary>
        /// <param name="carrier">The carrier to purchase a shipment from.</param>
        /// <param name="service">The service to purchase.</param>
        public void Buy(string carrier, string service)
        {
            Request request = new Request("orders/{id}/buy", Method.POST);

            request.AddUrlSegment("id", id);
            request.addBody(new List <Tuple <string, string> >()
            {
                new Tuple <string, string>("carrier", carrier), new Tuple <string, string>("service", service)
            });

            ResourceExtension.Merge(this, client.Execute <Order>(request));
        }