Ejemplo n.º 1
0
        /// <summary>
        /// Gets the order processing status.
        /// This code performs a simple GET on the "/services/rest/orders/v1/process/" PlazaAPI.
        /// NOTE: It is important to check for each of the items in your order if they are contained within the OrderItemsList array.
        /// If not, they have NOT been accepted by bol.com and the customer will not know that they have been shipped. Nor will you receive payment for them.
        /// All the SUCCESS statuses may make it seem like all is well but until you verify that each and every OrderItem has been accepted you cannot be sure.
        /// A sure sign of trouble is if orders that have been processed through the API have are still visible in the seller Dashboard after some time (say, a couple of hours at most)
        /// </summary>
        /// <param name="orderId">The order identifier.</param>
        /// <returns>
        /// A ProcessOrdersOverview object. This ProcessOrdersOverview object was generated by a tool.
        /// The different elements are described on the following XML Schema Definition https://plazaapi.bol.com/services/xsd/plazaapiservice-v1.xsd
        /// </returns>
        public ProcessOrdersOverview GetProcessStatus(int orderId)
        {
            HttpWebResponse       response = null;
            ProcessOrdersOverview results  = null;

            if (orderId < -1)
            {
                throw new Exception("Invalid (no) processing ID received.");
            }

            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_url + "/services/rest/orders/v1/process/" + orderId.ToString());

                Utils.HandleRequest(request, C.RequestMethods.GET, _publicKey, _privateKey);

                SigningRequest = Utils.StringToSign.Replace("\n", Environment.NewLine);
                response       = (HttpWebResponse)request.GetResponse();

                if (HttpStatusCode.OK == response.StatusCode)
                {
                    XmlSerializer ser = new XmlSerializer(typeof(ProcessOrdersOverview));
                    object        obj = ser.Deserialize(response.GetResponseStream());
                    results = (ProcessOrdersOverview)obj;

                    var json = new JavaScriptSerializer().Serialize(obj);
                    ResponseOutput = json;
                }
            }
            catch (WebException ex)
            {
                if (ex.Response != null)
                {
                    throw ExceptionHandler.HandleResponseException((HttpWebResponse)ex.Response);
                }
                else
                {
                    throw;
                }
            }
            finally
            {
                if (response != null)
                {
                    response.Close();
                }
            }

            return(results);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// This code demonstrates how to get the process status.
 /// This code performs a simple GET on the "/services/rest/orders/v1/process/" PlazaAPI.
 /// </summary>
 /// <param name="plazaAPIClient">The plaza API client.</param>
 private static void GetProcessStatus(PlazaAPIClient plazaAPIClient)
 {
     ProcessOrdersOverview processOrdersOverview = plazaAPIClient.GetProcessStatus(123);
 }