Exemplo n.º 1
0
 /// <summary>
 /// Create client.
 /// </summary>
 /// <param name="accessKey">Access Key</param>
 /// <param name="secretKey">Secret Key</param>
 /// <param name="config">configuration</param>
 public FBAInventoryServiceMWSClient(String accessKey, String secretKey, FBAInventoryServiceMWSConfig config)
 {
     connection = config.CopyConnection();
     connection.AwsAccessKeyId = accessKey;
     connection.AwsSecretKeyId = secretKey;
     connection.LibraryVersion = libraryVersion;
     servicePath = config.ServicePath;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Constructs FBAInventoryServiceMWSClient with AWS Access Key ID and AWS Secret Key
 /// </summary>
 /// <param name="awsAccessKeyId">AWS Access Key ID</param>
 /// <param name="awsSecretAccessKey">AWS Secret Access Key</param>
 /// <param name="config">configuration</param>
 public FBAInventoryServiceMWSClient(String awsAccessKeyId, String awsSecretAccessKey, FBAInventoryServiceMWSConfig config)
 {
     this.awsAccessKeyId     = awsAccessKeyId;
     this.awsSecretAccessKey = awsSecretAccessKey;
     if (!config.IsSetUserAgent())
     {
         throw new FBAInventoryServiceMWSException("Missing required value: User-Agent.");
     }
     this.config = config;
 }
Exemplo n.º 3
0
 private void buildUserAgentHeader(
     string applicationName,
     string applicationVersion,
     FBAInventoryServiceMWSConfig config)
 {
     config.SetUserAgentHeader(
         applicationName,
         applicationVersion,
         "C#",
         "CLI", Environment.Version.ToString(),
         "Platform", Environment.OSVersion.Platform + "/" + Environment.OSVersion.Version,
         "MWSClientVersion", MWS_CLIENT_VERSION);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Constructs FBAInventoryServiceMWSClient with AWS Access Key ID and AWS Secret Key
        /// an application name, and application version.
        /// </summary>
        /// <param name="awsAccessKeyId">AWS Access Key ID</param>
        /// <param name="awsSecretAccessKey">AWS Secret Access Key</param>
        /// <param name="applicationName">Application Name</param>
        /// <param name="applicationVersion">Application Version</param>
        /// <param name="applicationVersion">Custom Configuration (User-Agent not set)</param>
        public FBAInventoryServiceMWSClient(
            String awsAccessKeyId,
            String awsSecretAccessKey,
            String applicationName,
            String applicationVersion,
            FBAInventoryServiceMWSConfig config)
        {
            this.awsAccessKeyId     = awsAccessKeyId;
            this.awsSecretAccessKey = awsSecretAccessKey;
            this.config             = config;

            buildUserAgentHeader(applicationName, applicationVersion, config);
        }
Exemplo n.º 5
0
 /// <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 FBAInventoryServiceMWSClient(
     string accessKey,
     string secretKey,
     string applicationName,
     string applicationVersion,
     FBAInventoryServiceMWSConfig config)
 {
     connection = config.CopyConnection();
     connection.AwsAccessKeyId     = accessKey;
     connection.AwsSecretKeyId     = secretKey;
     connection.ApplicationName    = applicationName;
     connection.ApplicationVersion = applicationVersion;
     connection.LibraryVersion     = libraryVersion;
     servicePath = config.ServicePath;
 }
        public static void MainOldSample(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;
            }
        }
        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;
            }
        }