示例#1
0
 /// <summary>
 /// Create client.
 /// </summary>
 /// <param name="accessKey">Access Key</param>
 /// <param name="secretKey">Secret Key</param>
 /// <param name="config">configuration</param>
 public FBAInboundServiceMWSClient(String accessKey, String secretKey, FBAInboundServiceMWSConfig config)
 {
     connection = config.CopyConnection();
     connection.AwsAccessKeyId = accessKey;
     connection.AwsSecretKeyId = secretKey;
     connection.LibraryVersion = libraryVersion;
     servicePath = config.ServicePath;
 }
示例#2
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 FBAInboundServiceMWSClient(
     string accessKey,
     string secretKey,
     string applicationName,
     string applicationVersion,
     FBAInboundServiceMWSConfig config)
 {
     connection = config.CopyConnection();
     connection.AwsAccessKeyId     = accessKey;
     connection.AwsSecretKeyId     = secretKey;
     connection.ApplicationName    = applicationName;
     connection.ApplicationVersion = applicationVersion;
     connection.LibraryVersion     = libraryVersion;
     servicePath = config.ServicePath;
 }
    private List<AsinPrepData> GetDataFromMws(List<string> requestedAsins)
    {
      List<AsinPrepData> asinData = new List<AsinPrepData>();

      string accessKey = System.Configuration.ConfigurationManager.AppSettings["MwsAccK"];
      string secretKey = System.Configuration.ConfigurationManager.AppSettings["MwsSecK"];
      string sellerId = System.Configuration.ConfigurationManager.AppSettings["MwsSeller"];
      string marketplaceId = System.Configuration.ConfigurationManager.AppSettings["MwsMktpl"];

      FBAInboundServiceMWSConfig config = new FBAInboundServiceMWSConfig();
      config.ServiceURL = "https://mws.amazonservices.com ";
      config.SetUserAgentHeader("CMA", "1.0", "C#", new string[] { });
      FBAInboundServiceMWSClient client = new FBAInboundServiceMWSClient(accessKey, secretKey, config);

      FBAInboundServiceMWS.Model.GetPrepInstructionsForASINRequest request = new FBAInboundServiceMWS.Model.GetPrepInstructionsForASINRequest();
      request.AsinList = new FBAInboundServiceMWS.Model.AsinList();
      request.AsinList.Id = requestedAsins;
      request.SellerId = System.Configuration.ConfigurationManager.AppSettings["MwsSeller"];
      request.ShipToCountryCode = "US";

      FBAInboundServiceMWS.Model.GetPrepInstructionsForASINResponse response = new FBAInboundServiceMWS.Model.GetPrepInstructionsForASINResponse();


      try { response = client.GetPrepInstructionsForASIN(request); } catch (Exception e) {}
      while (response.ResponseHeaderMetadata == null || response.ResponseHeaderMetadata.QuotaRemaining < 1000)
      {
        if (response.ResponseHeaderMetadata == null)
        {
          this.StatusDescription = string.Format("No response given to MWS Request");
        }
        else
          this.StatusDescription = string.Format("API Quota reached. Remaining: {0} of {1}, Resets: {2},", response.ResponseHeaderMetadata.QuotaRemaining, response.ResponseHeaderMetadata.QuotaMax, response.ResponseHeaderMetadata.QuotaResetsAt.Value.ToShortTimeString());

        Thread.Sleep(20000);
        try { response = client.GetPrepInstructionsForASIN(request); } catch (Exception e) { }
      }

      foreach (var result in response.GetPrepInstructionsForASINResult.ASINPrepInstructionsList.ASINPrepInstructions)
      {
        if (result.IsSetASIN())
        {
          AsinPrepData asinPrep = new AsinPrepData();
          asinPrep.Asin = result.ASIN;

          if (result.IsSetBarcodeInstruction())
          {
            if (result.BarcodeInstruction.Equals("RequiresFNSKULabel"))
              asinPrep.Labelling = "Required";
            else if (result.BarcodeInstruction.Equals("MustProvideSellerSKU"))
              asinPrep.Labelling = "Undetermined";
          }

          if (result.IsSetPrepGuidance())
          {
            if (result.PrepGuidance.Equals("SeePrepInstructionsList"))
            {
              // prep exists
              if (result.IsSetPrepInstructionList())
              {
                foreach (var prep in result.PrepInstructionList.PrepInstruction)
                {
                  asinPrep.Prep += prep;
                }
              }
            }
            else if (result.PrepGuidance.Equals("NoAdditionalPrepRequired"))
            {
              asinPrep.Prep = "None";
            }
            else if (result.PrepGuidance.Equals("ConsultHelpDocuments"))
            {
              asinPrep.Prep = "Undetermined";
            }

          }

          asinData.Add(asinPrep);
        }
        
        
      }

      return asinData;
    }