Example #1
0
        /// <summary>
        /// 订单确认/取消接口
        /// <para>
        /// 详细说明请查看丰桥API说明<seealso cref="https://qiao.sf-express.com/pages/developDoc/index.html?level2=474384"/>
        /// </para>
        /// </summary>
        /// <param name="expressOrderConfirm">快递订单确认对象</param>
        /// <param name="saveRequestXmlAction">落地请求报文的委托</param>
        /// <param name="saveResponseXmlAction">落地响应报文的委托</param>
        /// <returns></returns>
        public async Task <ExpressOrderConfirmResult> OrderConfirmAsync(ExpressOrderConfirm expressOrderConfirm, Action <string> saveRequestXmlAction = null, Action <string> saveResponseXmlAction = null)
        {
            var    request    = new Request <OrderConfirmRequestBody>(new OrderConfirmRequestBody(expressOrderConfirm), options.ClientCode);
            string xmlContent = request.ToXml();

            saveRequestXmlAction?.Invoke(xmlContent);
            var responseStr = await httpClient.PostAsync(xmlContent, BuidVerifyCode(xmlContent));

            saveResponseXmlAction?.Invoke(responseStr);
            if (responseStr.IsNullOrWhiteSpace())
            {
                return(null);
            }
            Response <OrderConfirmResponseBody> orderResponse = new Response <OrderConfirmResponseBody>()
            {
                Body = new OrderConfirmResponseBody()
            };

            orderResponse.Fill(responseStr.ToXmlDocument());
            if (orderResponse.Error != null)
            {
                throw SFExpressException.ThrowException(orderResponse.Error);
            }
            return(orderResponse.Body.Result);
        }
Example #2
0
        /// <summary>
        /// 路由查询接口
        /// <para>
        /// 详细说明请查看丰桥API说明<seealso cref="https://qiao.sf-express.com/pages/developDoc/index.html?level2=314896"/>
        /// </para>
        /// </summary>
        /// <param name="expressRoute"></param>
        /// <param name="saveRequestXmlAction">落地请求报文的委托</param>
        /// <param name="saveResponseXmlAction">落地响应报文的委托</param>
        /// <returns></returns>
        public async Task <IEnumerable <ExpressRouteGroup> > RouteAsync(ExpressRoute expressRoute, Action <string> saveRequestXmlAction = null, Action <string> saveResponseXmlAction = null)
        {
            var    request    = new Request <RouteRequestBody>(new RouteRequestBody(expressRoute), options.ClientCode);
            string xmlContent = request.ToXml();

            saveRequestXmlAction?.Invoke(xmlContent);
            var responseStr = await httpClient.PostAsync(xmlContent, BuidVerifyCode(xmlContent));

            saveResponseXmlAction?.Invoke(responseStr);
            if (responseStr.IsNullOrWhiteSpace())
            {
                return(null);
            }
            Response <RouteResponseBody> routeResponse = new Response <RouteResponseBody>()
            {
                Body = new RouteResponseBody()
            };

            routeResponse.Fill(responseStr.ToXmlDocument());
            if (routeResponse.Error != null)
            {
                throw SFExpressException.ThrowException(routeResponse.Error);
            }
            return(routeResponse.Body.Result);
        }