Exemplo n.º 1
0
        private float GetDocumentPrice(Guid citySender, Guid cityRecipient, enNovaPoshtaDeliveryType serviceType, float weight, float coast)
        {
            var model = new NovaPoshtaRequest <NovaRequestPrice>
            {
                ApiKey           = ApiKey,
                Language         = Language,
                ModelName        = "InternetDocument",
                CalledMethod     = "getDocumentPrice",
                MethodProperties = new NovaRequestPrice
                {
                    CitySender    = citySender,
                    CityRecipient = cityRecipient,
                    ServiceType   = serviceType.ToString(),
                    Weight        = weight,
                    Cost          = coast
                }
            };
            var str = MakeRequest(JsonConvert.SerializeObject(model));
            var obj = JsonConvert.DeserializeObject <NovaResponse <NovaResponsePrice> >(str);

            if (obj.Errors != null && obj.Errors.ToString() != "[]")
            {
                throw new Exception(obj.Errors.ToString());
            }
            return(obj.Data.First().Cost);
        }
Exemplo n.º 2
0
        private DateTime GetDocumentDeliveryDate(Guid citySender, Guid cityRecipient, enNovaPoshtaDeliveryType serviceType, DateTime dateTime)
        {
            var model = new NovaPoshtaRequest <NovaRequestDelivery>
            {
                ApiKey           = ApiKey,
                Language         = Language,
                ModelName        = "InternetDocument",
                CalledMethod     = "getDocumentDeliveryDate",
                MethodProperties = new NovaRequestDelivery
                {
                    CitySender    = citySender,
                    CityRecipient = cityRecipient,
                    ServiceType   = serviceType.ToString(),
                    DateTime      = dateTime.ToString("dd.MM.yyyy")
                }
            };
            var str = MakeRequest(JsonConvert.SerializeObject(model));
            var obj = JsonConvert.DeserializeObject <NovaResponse <NovaResponseDeliveryDate> >(str);

            if (obj.Errors != null && obj.Errors.ToString() != "[]")
            {
                throw new Exception(obj.Errors.ToString());
            }
            return(obj.Data.First().DeliveryDate.Date);
        }
Exemplo n.º 3
0
        private string GetCities(int page, string findByString, string @ref = "")
        {
            var model = new NovaPoshtaRequest <NovaRequestCity>
            {
                ApiKey           = ApiKey,
                Language         = Language,
                ModelName        = "Address",
                CalledMethod     = "getCities",
                MethodProperties = new NovaRequestCity {
                    Page = page, FindByString = findByString, Ref = @ref
                }
            };

            return(MakeRequest(JsonConvert.SerializeObject(model)));
        }