private string GetNewOrderID()
        {
            var orderRequest = new Order
            {
                Name       = "AutomationClientOrder",
                ClientId   = DataClass.Agency1.ClientData[0].Client.Id,
                ContactIds = new List <string> {
                    DataClass.Agency1.ClientData[0].Contact[0].Id
                },
                OwnerIds = new List <string> {
                    DataClass.OwnerOnly[0].Id
                },
                Status         = 1,
                ClientBrandId  = DataClass.Agency1.ClientData[0].BrandData[0].Brand.Id,
                BrandProductId = DataClass.Agency1.ClientData[0].BrandData[0].Product[0].Id,
                AgencyId       = null
            };
            var automationVariables = AppSettingsInitialization.GetConfigInstance();

            httpService.EndPoint = automationVariables.OrderAPI;
            var orderResponse = httpService.PerformPost(orderRequest);
            var response      = JSONLibrary.DeserializeJSon <Order>(orderResponse.Content);

            orderRequest.Id = response.Id;
            return(orderRequest.Id);
        }
        public BillingLineBuyingArea CreateBuyingArea(BillingLineBuyingArea request)
        {
            AutomationVariables AutomationVariables = AppSettingsInitialization.GetConfigInstance();

            httpService.EndPoint = AutomationVariables.BillingLineBuyingAreaAPI;
            var postResponse = httpService.PerformPost(request);
            var response     = JSONLibrary.DeserializeJSon <BillingLineBuyingArea>(postResponse.Content);

            return(response);
        }
        public string CreateProductID(BillingLineProduct request)
        {
            var automationVariables = AppSettingsInitialization.GetConfigInstance();

            httpService.EndPoint = automationVariables.BillingLineProductAPI;
            var productResponse = httpService.PerformPost(request);
            var response        = JSONLibrary.DeserializeJSon <Order>(productResponse.Content);

            return(response.Id);
        }
        public OrderItemType GetOrderItemType()
        {
            var automationVariables = AppSettingsInitialization.GetConfigInstance();

            httpService.EndPoint = automationVariables.OrderItemTypeAPI;
            var orderResponse    = httpService.PerformGet();
            var response         = JSONLibrary.DeserializeJSon <List <OrderItemType> >(orderResponse.Content);
            var selectedResponse = response.FirstOrDefault(r => r.Name == "AutomationOrderItem");

            return((selectedResponse == null) ? GetNewOrderItemType() : selectedResponse);
        }
        public string GetBuyingAreaId()
        {
            var automationVariables = AppSettingsInitialization.GetConfigInstance();

            httpService.EndPoint = automationVariables.OrderAPI;
            var orderResponse    = httpService.PerformGet();
            var response         = JSONLibrary.DeserializeJSon <List <BillingLineBuyingArea> >(orderResponse.Content);
            var selectedResponse = response.FirstOrDefault(r => r.Name == "AutomationBillingLineBuyingArea");
            var request          = GetRequest();

            return((selectedResponse == null) ? CreateBuyingArea(request).Id : selectedResponse.Id);
        }
        private OrderItemType GetNewOrderItemType()
        {
            var orderItemTypeRequest = new OrderItemType
            {
                Name          = "AutomationOrderItem",
                IsDisabled    = false,
                Url           = "https://www.test.com",
                Key           = GenericLibrary.RandomString(10),
                InitialStatus = "ReadyToBook"
            };
            var automationVariables = AppSettingsInitialization.GetConfigInstance();

            httpService.EndPoint = automationVariables.OrderItemTypeAPI;
            var orderItemTypeResponse = httpService.PerformPost(orderItemTypeRequest);
            var response = JSONLibrary.DeserializeJSon <OrderItemType>(orderItemTypeResponse.Content);

            orderItemTypeRequest.Id = response.Id;
            return(orderItemTypeRequest);
        }
Ejemplo n.º 7
0
        public ApiRequest()
        {
            this.AutomationVariables = AppSettingsInitialization.GetConfigInstance();

            var environment = Environment.GetEnvironmentVariable("RUNTIME_ENVIRONMENT") ?? "int";

            switch (environment.ToLower())
            {
            case "test":
                BaseUrl = AutomationVariables.TestUrl;
                break;

            case "int":
                BaseUrl = AutomationVariables.IntUrl;
                break;

            case "dev":
                BaseUrl = AutomationVariables.DevUrl;
                break;
            }

            Client = new RestClient(BaseUrl);
        }