Exemple #1
0
        public async Task RunAsync(string customerID, string action)
        {
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Tls12;
            client.DefaultRequestHeaders.Accept.Clear();

            //  passing reqired parameters
            var customer = new WriteProvisionStatusDto
            {
                PipelineId   = "1225AB",
                ErrorMessage = "error message"
            };
            var infrastructureAttributesValues = new CustomAttributeDto
            {
                Key   = "Key-1",
                Value = "MyKey-1"
            };

            customer.InfrastructureAttributes = new List <CustomAttributeDto>
            {
                infrastructureAttributesValues
            };

            // Update the product
            switch (action.ToLower())
            {
            case "pending":
                await UpdateCustomerPending(customer, customerID);

                break;

            case "inprocess":
                await UpdateCustomerInProcess(customer, customerID);

                break;

            case "completed":
                await UpdateCustomerCompleted(customer, customerID);

                break;

            case "failed":
                await UpdateCustomerFailed(customer, customerID);

                break;

            case "deletecustomer":
                await DeleteCustomer(customerID);

                break;

            default:
                throw new NotSupportedException("No action is known, please provide a correct action.");
            }
        }
Exemple #2
0
        private async Task UpdateCustomerFailed(WriteProvisionStatusDto customer, string customerID)
        {
            customer.Status = ProvisionStatuses.Failed;
            string putBody = JsonConvert.SerializeObject(customer);
            HttpResponseMessage response = await client.PutAsync(baseURL + $"/customerapi/Customers/{customerID}/provision",
                                                                 new StringContent(putBody, Encoding.UTF8, "application/json"));

            if (response.IsSuccessStatusCode == true)
            {
                // HTTP GET
                response = await client.GetAsync(baseURL + $"/customerapi/Customers/{customerID}/");

                var product = JsonConvert.DeserializeObject <ReadCustomerDto>(await response.Content.ReadAsStringAsync());
                Console.WriteLine("{0}\t{1}\t{2}", product.Id, product.ProvisionStatus, response.StatusCode);
            }
        }