/// <summary> /// Create client. /// </summary> /// <param name="accessKey">Access Key</param> /// <param name="secretKey">Secret Key</param> /// <param name="config">configuration</param> public MarketplaceWebServiceOrdersClient(String accessKey, String secretKey, MarketplaceWebServiceOrdersConfig config) { connection = config.CopyConnection(); connection.AwsAccessKeyId = accessKey; connection.AwsSecretKeyId = secretKey; connection.LibraryVersion = libraryVersion; servicePath = config.ServicePath; }
/// <summary> /// Create client. /// </summary> /// <param name="accessKey">Access Key</param> /// <param name="secretKey">Secret Key</param> /// <param name="applicationName">Application Name</param> /// <param name="applicationVersion">Application Version</param> /// <param name="config">configuration</param> public MarketplaceWebServiceOrdersClient( string accessKey, string secretKey, string applicationName, string applicationVersion, MarketplaceWebServiceOrdersConfig config) { connection = config.CopyConnection(); connection.AwsAccessKeyId = accessKey; connection.AwsSecretKeyId = secretKey; connection.ApplicationName = applicationName; connection.ApplicationVersion = applicationVersion; connection.LibraryVersion = libraryVersion; servicePath = config.ServicePath; }
static void Main(string[] args) { // SAM: update customer list fist //CustomerDAL.AddCustomer(config); MarketplaceWebServiceOrdersConfig config = new MarketplaceWebServiceOrdersConfig(); config.ServiceURL = ConfigurationHelper.ServiceURL; // Set other client connection configurations here if needed // Create the client itself MarketplaceWebServiceOrders client = new MarketplaceWebServiceOrdersClient(ConfigurationHelper.AccessKey, ConfigurationHelper.SecretKey, ConfigurationHelper.AppName, ConfigurationHelper.Version, config); MarketplaceWebServiceOrdersSample amazonOrders = new MarketplaceWebServiceOrdersSample(client); // AddAmazonASIN(); // UpdateAmazonPricingData(); // UpdateAmazonInventoryData(); // return; // Setup the orders service client try { IMWSResponse response = null; response = amazonOrders.InvokeListOrders(true); // send argument true to get last 4 days worth of orders ResponseHeaderMetadata rhmd = response.ResponseHeaderMetadata; Console.WriteLine("RequestId: " + rhmd.RequestId); Console.WriteLine("Timestamp: " + rhmd.Timestamp); var orderResponse = response as ListOrdersResponse; var invoiceNo = OrderDAL.GetMaxInvoiceNum(ConfigurationHelper.ConnectionString, "ACGA-"); foreach (var order in orderResponse.ListOrdersResult.Orders) { order.BuyerEmail = order.BuyerEmail.Replace("marketplace.amazon.com", "AutoCareGuys.com"); if (order.OrderStatus.ToLower() != "unshipped") { continue; } Console.WriteLine("Checking Unshipped Amazon order :" + order.AmazonOrderId); //** SAM: Find if this order already exists (but unshipped) var existingOrder = OrderDAL.FetchOrders(ConfigurationHelper.ConnectionString, ord => ord.po_no == order.AmazonOrderId); if (existingOrder.Count > 0) { Console.WriteLine(" Order exists " + existingOrder[0].orderno); continue; } // Add order var orderItemResponse = amazonOrders.InvokeListOrderItems(order.AmazonOrderId); order.OrderItem = orderItemResponse.ListOrderItemsResult.OrderItems; var customerId = CreateCustomer(order); if (customerId > 0) { var mappedOrder = MapAmazonOrder(order, customerId, ref invoiceNo); } } } catch (Exception ex) { Console.WriteLine("Error occurred " + ex.Message); Console.ReadKey(); } }