Exemplo n.º 1
0
        public MwsFulfillmentInventoryApi(string sellerId, string marketPlaceId, string accessKeyId, string secretAccessKeyId)
        {
            m_sellerId      = sellerId;
            m_marketPlaceId = marketPlaceId;

            FBAInventoryServiceMWSConfig configService = new FBAInventoryServiceMWSConfig().WithServiceURL(c_fbaInventoryServiceUrl);

            configService.SetUserAgentHeader(string.Empty, string.Empty, "C#");

            m_service = new FBAInventoryServiceMWSClient(
                accessKeyId,
                secretAccessKeyId,
                string.Empty,
                string.Empty,
                configService);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get Service Status
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnGetServiceStatus_Click(object sender, RoutedEventArgs e)
        {
            string SellerId           = CommonValue.strMerchantId;
            string MarketplaceId      = CommonValue.strMarketplaceId;
            string AccessKeyId        = CommonValue.strAccessKeyId;
            string SecretKeyId        = CommonValue.strSecretKeyId;
            string ApplicationVersion = CommonValue.strApplicationVersion;
            string ApplicationName    = CommonValue.strApplicationName;
            string MWSAuthToken       = CommonValue.strMWSAuthToken;
            string strbuff            = string.Empty;

            FBAInventoryServiceMWSConfig config = new FBAInventoryServiceMWSConfig();

            config.ServiceURL = CommonValue.strServiceURL;

            FBAInventoryServiceMWSClient client = new FBAInventoryServiceMWSClient(
                AccessKeyId,
                SecretKeyId,
                ApplicationName,
                ApplicationVersion,
                config);
            GetServiceStatusRequest request = new GetServiceStatusRequest();

            request.SellerId     = SellerId;
            request.Marketplace  = MarketplaceId;
            request.MWSAuthToken = MWSAuthToken;
            GetServiceStatusResponse response = client.GetServiceStatus(request);

            if (response.IsSetGetServiceStatusResult())
            {
                GetServiceStatusResult getServiceStatusResult = response.GetServiceStatusResult;
                if (getServiceStatusResult.IsSetStatus())
                {
                    strbuff = "Status:" + getServiceStatusResult.Status;
                }
            }
            txtGetServiceStatus.Text = strbuff;
        }
Exemplo n.º 3
0
        public void syn(Shop shop)
        {
            if (shop.InventoryQueryStartDateTime == null)
            {
                shop.InventoryQueryStartDateTime = AppConstant.inventoryQueryStartDateTime;
            }

            if (inventoryQueryStartDateTime == null)
            {
                this.inventoryQueryStartDateTime = shop.InventoryQueryStartDateTime.Value;
            }
            this.sellerId     = shop.SellerId;
            this.mwsAuthToken = shop.MwsAuthToken;
            shopId            = shop.Id;
            shopMarketplaceId = shop.ShopMarketplaceId;
            FBAInventoryServiceMWSConfig config = new FBAInventoryServiceMWSConfig();

            config.ServiceURL = serviceURL;
            client            = new FBAInventoryServiceMWSClient(accessKey, secretKey, appName, appVersion, config);
            doSyn();
            inventoryQueryStartDateTime = DateTime.Now.AddMinutes(-5);
            ShopService.updateInventoryQueryStartDateTime(shop.Id, inventoryQueryStartDateTime.Value);
        }
Exemplo n.º 4
0
        public SellerInventorySupplyList()
        {
            /************************************************************************
             * Access Key ID and Secret Acess Key ID, obtained from:
             * http://mws.amazon.com
             ***********************************************************************/

            String accessKeyId     = "AKIAJ2IS6ZEEGQPJV7WA";
            String secretAccessKey = "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";

            /************************************************************************
             * Marketplace and Seller IDs are required parameters for all
             * MWS calls.
             ***********************************************************************/


            /************************************************************************
             * The application name and version are included in each MWS call's
             * HTTP User-Agent field. These are required fields.
             ***********************************************************************/
            const string applicationName    = "<Your Application Name>";
            const string applicationVersion = "<Your Application Version or Build Number or Release Date>";

            /************************************************************************
             * Uncomment to try advanced configuration options. Available options are:
             *
             *  - Proxy Host and Proxy Port
             *  - MWS Service endpoint URL
             *  - User Agent String to be sent to FBA Inventory Service MWS  service
             *
             ***********************************************************************/
            FBAInventoryServiceMWSConfig config = new FBAInventoryServiceMWSConfig();

            //config.ProxyHost = "https://PROXY_URL";
            //config.ProxyPort = 9090;
            //
            // IMPORTANT: Uncomment out the appropiate line for the country you wish
            // to sell in:
            //
            // US
            config.ServiceURL = MWSServer.Properties.Settings.Default["US_ServiceURL"].ToString();
            //config.ServiceURL = "https://mws.amazonservices.com/FulfillmentInventory/2010-10-01/";
            // UK
            // config.ServiceURL = "https://mws.amazonservices.co.uk/FulfillmentInventory/2010-10-01/";
            // Germany
            // config.ServiceURL = "https://mws.amazonservices.de/FulfillmentInventory/2010-10-01/";
            // France
            // config.ServiceURL = "https://mws.amazonservices.fr/FulfillmentInventory/2010-10-01/";
            // Japan
            // config.ServiceURL = "https://mws.amazonservices.jp/FulfillmentInventory/2010-10-01/";
            // China
            // config.ServiceURL = "https://mws.amazonservices.com.cn/FulfillmentInventory/2010-10-01/";

            // ProxyPort=-1 ; MaxErrorRetry=3
            config.SetUserAgentHeader(
                applicationName,
                applicationVersion,
                "C#",
                "-1", "3");

            /************************************************************************
             * Instantiate Implementation of FBA Inventory Service MWS
             ***********************************************************************/
            service =
                new FBAInventoryServiceMWSClient(
                    accessKeyId,
                    secretAccessKey,
                    applicationName,
                    applicationVersion,
                    config);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Get Next Inventory List Supply
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnListInventorySupplyByNextToken_Click(object sender, RoutedEventArgs e)
        {
            string SellerId           = CommonValue.strMerchantId;
            string MarketplaceId      = CommonValue.strMarketplaceId;
            string AccessKeyId        = CommonValue.strAccessKeyId;
            string SecretKeyId        = CommonValue.strSecretKeyId;
            string ApplicationVersion = CommonValue.strApplicationVersion;
            string ApplicationName    = CommonValue.strApplicationName;
            string MWSAuthToken       = CommonValue.strMWSAuthToken;
            string strbuff            = string.Empty;

            FBAInventoryServiceMWSConfig config = new FBAInventoryServiceMWSConfig();

            config.ServiceURL = CommonValue.strServiceURL;

            FBAInventoryServiceMWSClient client = new FBAInventoryServiceMWSClient(
                AccessKeyId,
                SecretKeyId,
                ApplicationName,
                ApplicationVersion,
                config);
            ListInventorySupplyRequest request = new ListInventorySupplyRequest();

            request.SellerId           = SellerId;
            request.Marketplace        = MarketplaceId;
            request.MWSAuthToken       = MWSAuthToken;
            request.QueryStartDateTime = DateTime.Now.AddMonths(1);
            request.ResponseGroup      = "Detailed";

            ListInventorySupplyResponse response = client.ListInventorySupply(request);

            if (response.IsSetListInventorySupplyResult())
            {
                ListInventorySupplyResult listInventorySupplyResult = response.ListInventorySupplyResult;
                if (listInventorySupplyResult.IsSetInventorySupplyList())
                {
                    if (listInventorySupplyResult.NextToken != null)
                    {
                        ListInventorySupplyByNextTokenRequest request1 = new ListInventorySupplyByNextTokenRequest();
                        request1.SellerId     = SellerId;
                        request1.Marketplace  = MarketplaceId;
                        request1.MWSAuthToken = MWSAuthToken;
                        request1.NextToken    = listInventorySupplyResult.NextToken;

                        ListInventorySupplyByNextTokenResponse response1 = client.ListInventorySupplyByNextToken(request1);
                        if (response1.IsSetListInventorySupplyByNextTokenResult())
                        {
                            ListInventorySupplyByNextTokenResult listInventorySupplyByNextTokenResult = response1.ListInventorySupplyByNextTokenResult;
                            if (listInventorySupplyByNextTokenResult.IsSetInventorySupplyList())
                            {
                                InventorySupplyList    inventorySupplyList = listInventorySupplyByNextTokenResult.InventorySupplyList;
                                List <InventorySupply> memberList          = inventorySupplyList.member;
                                if (memberList.Count > 0)
                                {
                                    foreach (InventorySupply member in memberList)
                                    {
                                        if (member.IsSetTotalSupplyQuantity())
                                        {
                                            strbuff += "Amount:" + member.TotalSupplyQuantity;
                                        }
                                    }
                                }
                                else
                                {
                                    strbuff = "Not find next stock information.";
                                }
                            }
                        }
                    }
                }
            }
            txtListInventorySupplyByNextToken.Text = strbuff;
        }
        /**
         * Samples for FBA Inventory Service MWS functionality
         */
        public static void Main(string [] args)
        {
            Console.WriteLine("===========================================");
            Console.WriteLine("Welcome to FBA Inventory Service MWS Samples!");
            Console.WriteLine("===========================================");

            Console.WriteLine("To get started:");
            Console.WriteLine("===========================================");
            Console.WriteLine("  - Fill in your MWS credentials");
            Console.WriteLine("  - Uncomment sample you're interested in trying");
            Console.WriteLine("  - Set request with desired parameters");
            Console.WriteLine("  - Hit F5 to run!");
            Console.WriteLine();

            Console.WriteLine("===========================================");
            Console.WriteLine("Samples Output");
            Console.WriteLine("===========================================");
            Console.WriteLine();

            /************************************************************************
             * Access Key ID and Secret Acess Key ID, obtained from:
             * http://mws.amazon.com
             ***********************************************************************/
            String accessKeyId     = "AKIAJ2IS6ZEEGQPJV7WA";
            String secretAccessKey = "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";

            /************************************************************************
             * Marketplace and Seller IDs are required parameters for all
             * MWS calls.
             ***********************************************************************/
            const string marketplaceId = "ATVPDKIKX0DER";
            const string sellerId      = "A2TYS339AQK0NU";

            /************************************************************************
             * The application name and version are included in each MWS call's
             * HTTP User-Agent field. These are required fields.
             ***********************************************************************/
            const string applicationName    = "<Your Application Name>";
            const string applicationVersion = "<Your Application Version or Build Number or Release Date>";

            /************************************************************************
             * Uncomment to try advanced configuration options. Available options are:
             *
             *  - Proxy Host and Proxy Port
             *  - MWS Service endpoint URL
             *  - User Agent String to be sent to FBA Inventory Service MWS  service
             *
             ***********************************************************************/
            FBAInventoryServiceMWSConfig config = new FBAInventoryServiceMWSConfig();

            //config.ProxyHost = "https://PROXY_URL";
            //config.ProxyPort = 9090;
            //
            // IMPORTANT: Uncomment out the appropiate line for the country you wish
            // to sell in:
            //
            // US
            config.ServiceURL = "https://mws.amazonservices.com/FulfillmentInventory/2010-10-01/";
            // UK
            // config.ServiceURL = "https://mws.amazonservices.co.uk/FulfillmentInventory/2010-10-01/";
            // Germany
            // config.ServiceURL = "https://mws.amazonservices.de/FulfillmentInventory/2010-10-01/";
            // France
            // config.ServiceURL = "https://mws.amazonservices.fr/FulfillmentInventory/2010-10-01/";
            // Japan
            // config.ServiceURL = "https://mws.amazonservices.jp/FulfillmentInventory/2010-10-01/";
            // China
            // config.ServiceURL = "https://mws.amazonservices.com.cn/FulfillmentInventory/2010-10-01/";

            // ProxyPort=-1 ; MaxErrorRetry=3
            config.SetUserAgentHeader(
                applicationName,
                applicationVersion,
                "C#",
                "-1", "3");

            /************************************************************************
             * Instantiate Implementation of FBA Inventory Service MWS
             ***********************************************************************/
            FBAInventoryServiceMWS service =
                new FBAInventoryServiceMWSClient(
                    accessKeyId,
                    secretAccessKey,
                    applicationName,
                    applicationVersion,
                    config);

            // FBAInventoryServiceMWS service = new FBAInventoryServiceMWSClient(accessKeyId, secretAccessKey, config);

            /************************************************************************
             * Uncomment to try out Mock Service that simulates FBA Inventory Service MWS
             * responses without calling FBA Inventory Service MWS  service.
             *
             * Responses are loaded from local XML files. You can tweak XML files to
             * experiment with various outputs during development
             *
             * XML files available under FBAInventoryServiceMWS\Mock tree
             *
             ***********************************************************************/
            // FBAInventoryServiceMWS service = new FBAInventoryServiceMWSMock();

            /************************************************************************
             * Uncomment to invoke List Inventory Supply By Next Token Action
             ***********************************************************************/
            // ListInventorySupplyByNextTokenRequest request = new ListInventorySupplyByNextTokenRequest();
            // @TODO: set request parameters here
            // request.SellerId = sellerId;
            // request.Marketplace = marketplaceId;

            // ListInventorySupplyByNextTokenSample.InvokeListInventorySupplyByNextToken(service, request);

            /************************************************************************
             * Uncomment to invoke List Inventory Supply Action
             ***********************************************************************/
            ListInventorySupplyRequest request = new ListInventorySupplyRequest();

            // @TODO: set request parameters here
            request.SellerId    = sellerId;
            request.Marketplace = marketplaceId;

            request.QueryStartDateTime = DateTime.Parse("2014-06-15");
            ListInventorySupplySample.InvokeListInventorySupply(service, request);

            /************************************************************************
             * Uncomment to invoke Get Service Status Action
             ***********************************************************************/
            // GetServiceStatusRequest request = new GetServiceStatusRequest();
            // @TODO: set request parameters here
            // request.SellerId = sellerId;
            // request.Marketplace = marketplaceId;

            // GetServiceStatusSample.InvokeGetServiceStatus(service, request);
            Console.WriteLine();
            Console.WriteLine("===========================================");
            Console.WriteLine("End of output. You can close this window");
            Console.WriteLine("===========================================");

            System.Threading.Thread.Sleep(50000);
        }
Exemplo n.º 7
0
        public static void Main(string[] args)
        {
            // TODO: Set the below configuration variables before attempting to run

            // Developer AWS access key
            string accessKey = "replaceWithAccessKey";

            // Developer AWS secret key
            string secretKey = "replaceWithSecretKey";

            // The client application name
            string appName = "CSharpSampleCode";

            // The client application version
            string appVersion = "1.0";

            // The endpoint for region service and version (see developer guide)
            // ex: https://mws.amazonservices.com
            string serviceURL = "replaceWithServiceURL";

            // Create a configuration object
            FBAInventoryServiceMWSConfig config = new FBAInventoryServiceMWSConfig();

            config.ServiceURL = serviceURL;
            // Set other client connection configurations here if needed
            // Create the client itself
            FBAInventoryServiceMWS client = new FBAInventoryServiceMWSClient(accessKey, secretKey, appName, appVersion, config);

            FBAInventoryServiceMWSSample sample = new FBAInventoryServiceMWSSample(client);

            // Uncomment the operation you'd like to test here
            // TODO: Modify the request created in the Invoke method to be valid

            try
            {
                IMWSResponse response = null;
                // response = sample.InvokeGetServiceStatus();
                // response = sample.InvokeListInventorySupply();
                // response = sample.InvokeListInventorySupplyByNextToken();
                Console.WriteLine("Response:");
                ResponseHeaderMetadata rhmd = response.ResponseHeaderMetadata;
                // We recommend logging the request id and timestamp of every call.
                Console.WriteLine("RequestId: " + rhmd.RequestId);
                Console.WriteLine("Timestamp: " + rhmd.Timestamp);
                string responseXml = response.ToXML();
                Console.WriteLine(responseXml);
            }
            catch (FBAInventoryServiceMWSException ex)
            {
                // Exception properties are important for diagnostics.
                ResponseHeaderMetadata rhmd = ex.ResponseHeaderMetadata;
                Console.WriteLine("Service Exception:");
                if (rhmd != null)
                {
                    Console.WriteLine("RequestId: " + rhmd.RequestId);
                    Console.WriteLine("Timestamp: " + rhmd.Timestamp);
                }
                Console.WriteLine("Message: " + ex.Message);
                Console.WriteLine("StatusCode: " + ex.StatusCode);
                Console.WriteLine("ErrorCode: " + ex.ErrorCode);
                Console.WriteLine("ErrorType: " + ex.ErrorType);
                throw ex;
            }
        }