public void WillCreateANewCustomerInNetsuite()
        {
            var createCustomerRequest = new OrderToImport();

            // General information
            createCustomerRequest.Email       = $"{Faker.Name.First()}{Faker.Name.Last()}@gmail.com";
            createCustomerRequest.PhoneNumber = Faker.Phone.Number();
            createCustomerRequest.Department  = NetSuiteController.b2bDepartmentId;
            createCustomerRequest.UserTypeId  = NetSuiteController.generalContractor;

            // Billing address
            createCustomerRequest.BillingFirstName = Faker.Name.First();
            createCustomerRequest.BillingLastName  = Faker.Name.Last();
            createCustomerRequest.BillingLine1     = Faker.Address.StreetAddress();
            createCustomerRequest.BillingLine2     = "Apt B";
            createCustomerRequest.BillingCity      = Faker.Address.City();
            createCustomerRequest.BillingState     = Faker.Address.UsState();
            createCustomerRequest.BillingZip       = Faker.Address.ZipCode();
            createCustomerRequest.BillingCountry   = "US";

            // Shipping Address
            createCustomerRequest.ShippingFirstName = Faker.Name.First();
            createCustomerRequest.ShippingLastName  = Faker.Name.Last();
            createCustomerRequest.ShippingLine1     = Faker.Address.StreetAddress();
            createCustomerRequest.ShippingLine2     = "Room 104";
            createCustomerRequest.ShippingCity      = Faker.Address.City();
            createCustomerRequest.ShippingState     = Faker.Address.UsState();
            createCustomerRequest.ShippingZip       = Faker.Address.ZipCode();
            createCustomerRequest.ShippingCountry   = "US";

            string customerId = NetSuiteController.GetNetSuiteCustomerId(createCustomerRequest);

            Assert.NotNull(customerId);
        }
        private static void ImportOrdersToNetSuite(JArray ordersAwaitingFulfillment)
        {
            try
            {
                foreach (var order in ordersAwaitingFulfillment)
                {
                    Order parsedOrder = JsonConvert.DeserializeObject <Order>(order.ToString());

                    if (parsedOrder.is_deleted == true)
                    {
                        Log.Information($"Skipping order {parsedOrder.customer_id} because it is marked as deleted/archived.");
                        continue;
                    }

                    BigCommerceController.customerId = parsedOrder.customer_id;
                    int bigCommerceOrderId = parsedOrder.id;
                    Log.Information($"bigCommerceOrderId Id {bigCommerceOrderId}");

                    // Get the shipping information
                    string          shippingAddressUrl      = parsedOrder.shipping_addresses.url;
                    ShippingAddress customerShippingAddress = BigCommerceController.GetCustomerShippingAddress(shippingAddressUrl);

                    // Format the request object to send to CreateCustomerRESTlet
                    OrderToImport netsuiteRequest = NetSuiteController.CreateNetSuiteRequest(parsedOrder, customerShippingAddress);

                    if (netsuiteRequest.NestProId == "")
                    {
                        // We alert these to B2B so they can contact the customer
                        ordersMissingProId.Add(bigCommerceOrderId);
                        continue;
                    }

                    netsuiteCustomerId         = NetSuiteController.GetNetSuiteCustomerId(netsuiteRequest);
                    netsuiteRequest.CustomerId = Convert.ToInt32(netsuiteCustomerId);

                    // Call the Products API to get the products on the order
                    string productsUrl = parsedOrder.products.url;
                    netsuiteRequest.Items = BigCommerceController.GetProductsOnOrder(productsUrl);

                    NetSuiteController.SetNetSuiteItemIdAndPersonalItemFlag(netsuiteRequest);

                    // Import order to Netsuite
                    string netsuiteOrderId = NetSuiteController.ImportOrderToNetSuite(netsuiteRequest);

                    // Set the Big Commerce status to 'awaiting shipment' and add the NetSuite order ID to 'staff notes'
                    BigCommerceController.SetOrderStatus(bigCommerceOrderId, netsuiteOrderId);
                }
            }
            catch (Exception ex)
            {
                Log.Error($"Error: {ex}");
                string      title        = "Error in ImportOrdersToNetSuite";
                string      text         = $"Error message: {ex.Message}";
                string      color        = "red";
                TeamsHelper teamsMessage = new TeamsHelper(title, text, color, errorLogsUrl);
                teamsMessage.LogToMicrosoftTeams(teamsMessage);
            }
        }
        public void WillGetCustomerNetSuiteId()
        {
            OrderToImport customerRequest = new OrderToImport();

            customerRequest.Email = "*****@*****.**";
            int expectedCustomerId = 17494445;

            string netsuiteCustomerId = NetSuiteController.GetNetSuiteCustomerId(customerRequest);

            Assert.Equal(expectedCustomerId, Convert.ToInt32(netsuiteCustomerId));
        }