Example #1
0
        /// <summary>
        /// Получение статуса доставки асинхронно
        /// </summary>
        /// <param name="orderId">ID заказа в системе службы доставки</param>
        /// <returns>результат ответа сервера с информацией о статусе</returns>
        public Task <OrderStatusRequestResult> GetOrderStatusAsync(string orderId, RequestSettings rs = null) //t-ok
        {
            var r = (rs ?? RequestSettings.CreateNew()).SetJson();

            r.Body = _serializer.SerializeObject(new { OrderId = orderId });
            var url = _apiUrl + "/api/get_order_status?sid=@" + _securityToken;

            return(TryGetObjectAsync <OrderStatusRequestResult>(url, HttpMethod.Post, r));
        }
Example #2
0
        private Task <PickupPointsRequestResult> GetPickupObjectsAsync(string type,
                                                                       long?masterId, long?limit, long?offset, RequestSettings rs = null, string language = "RU")
        {
            var r = (rs ?? RequestSettings.CreateNew()).SetJson();

            r.Body = _serializer.SerializeObject(new { Language = language, Type = type, Limit = limit, Offset = offset, MasterId = masterId });
            var url = _apiUrl + "/api/get_objects?sid=@" + _securityToken;

            return(TryGetObjectAsync <PickupPointsRequestResult>(url, HttpMethod.Post, r));
        }
Example #3
0
        //это не проверялось
        //пункт 6.5 документации
        public string GetInsalesOrder(InsalesOrderRequestBody order, string method, RequestSettings rs = null)
        {
            var r = (rs ?? RequestSettings.CreateNew());

            r.Body = _serializer.SerializeObject(order);
            var url            = $"https://api.viasarci.com/insales-orders/{method}?id={_shopId}&sid=@{_securityToken}";
            var responseString = _httpLoader.GetString(url, HttpMethod.Post, r);

            return(responseString);
        }
Example #4
0
        /// <summary>
        /// Получение точек выдачи для карты в формате InSales
        /// </summary>
        /// <param name="body">InSalesPointListRequestBody</param>
        /// <returns>список объектов InSalesPoint</returns>
        public List <InSalesPoint> GetInsalesPointList(InSalesPointListRequestBody body, RequestSettings rs = null)
        {
            var r = (rs ?? RequestSettings.CreateNew());

            r.Body = _serializer.SerializeObject(body);
            //здесь прописан путь из документации. для develop-режима не понятно где взять
            var url = $"https://api.viasarci.com/insales/point-list?id={_shopId}";

            return(TryGetObject <List <InSalesPoint> >(url, HttpMethod.Post, r));
        }
Example #5
0
        => GetPickupObjectsAsync("pickup_points", masterId, limit, offset, rs, language);     //t-ok

        /// <summary>
        /// Создание доставки
        /// </summary>
        /// <param name="delivery">объект доставки</param>
        /// <returns>в случае успеха возвращает ID заказа в системе службы доставки</returns>
        public string CreateDeliveryGetId(Delivery delivery, RequestSettings rs = null) //t-ok
        {
            var r = (rs ?? RequestSettings.CreateNew()).SetJson();

            r.Body = _serializer.SerializeObject(delivery);
            var url = _apiUrl + "/api/post_order?sid=@" + _securityToken;
            var o   = TryGetObject <CreateOrderRequestResult>(url, HttpMethod.Post, r);

            return(string.Equals(o.Status, "OK", StringComparison.OrdinalIgnoreCase) ? o.Data.OrderId : null);
        }
Example #6
0
        /// <summary>
        /// Создание доставки асинхронно
        /// </summary>
        /// <param name="delivery">объект доставки</param>
        /// <returns>в случае успеха возвращает ID заказа в системе службы доставки</returns>
        public async Task <string> CreateDeliveryGetIdAsync(Delivery delivery, RequestSettings rs = null) //t-ok
        {
            var r = (rs ?? RequestSettings.CreateNew()).SetJson();

            r.Body = _serializer.SerializeObject(delivery);

            var url            = _apiUrl + "/api/post_order?sid=@" + _securityToken;
            var responseString = await _httpLoader.GetStringAsync(url, HttpMethod.Post, r);

            var o = AnswerToObject <CreateOrderRequestResult>(responseString, _serializer);

            if (o != null && string.Equals(o.Status, "OK", StringComparison.OrdinalIgnoreCase))
            {
                return(o.Data.OrderId);
            }
            return(null);
        }