Ejemplo n.º 1
0
 public List <string> GetSupportedContentTypesForFlatFiles(AmazonRegion region)
 {
     if (region == AmazonRegion.NorthAmerica || region == AmazonRegion.Europe)
     {
         return(new List <string> {
             "text/tab-separated-values; charset=iso-8859-1"
         });
     }
     else if (region == AmazonRegion.Japan)
     {
         return(new List <string> {
             "text/tab-separated-values; charset=Shift_JIS"
         });
     }
     else if (region == AmazonRegion.China)
     {
         return(new List <string> {
             "text/tab-separated-values;charset=UTF-8", "text/tab-separated-values;charset=UTF-16"
         });
     }
     else
     {
         throw new NotSupportedException(
                   $"Amazon region '{region.ToString()}' not supported by EasyMwsClient due to unknown ContentType that should be used to submit a feed to amazon");
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor to be used for UnitTesting/Mocking (in the absence of a dedicated DependencyInjection framework)
        /// </summary>
        internal FeedProcessor(AmazonRegion region, string merchantId, string mWSAuthToken, EasyMwsOptions options, IMarketplaceWebServiceClient mwsClient, IFeedSubmissionProcessor feedSubmissionProcessor, ICallbackActivator callbackActivator, IEasyMwsLogger logger)
            : this(region, merchantId, mWSAuthToken, options, mwsClient, logger)
        {
            _feedSubmissionProcessor = feedSubmissionProcessor;
            _callbackActivator       = callbackActivator;

            RegisterEvents();
        }
Ejemplo n.º 3
0
 internal FeedSubmissionProcessor(AmazonRegion region, string merchantId, string mWSAuthToken, IMarketplaceWebServiceClient marketplaceWebServiceClient, IEasyMwsLogger logger, EasyMwsOptions options)
 {
     _region     = region;
     _merchantId = merchantId;
     _options    = options;
     _logger     = logger;
     _marketplaceWebServiceClient = marketplaceWebServiceClient;
     _mWSAuthToken = mWSAuthToken;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructor to be used for UnitTesting/Mocking (in the absence of a dedicated DependencyInjection framework)
        /// </summary>
        internal ReportProcessor(AmazonRegion region, string merchantId, string mWSAuthToken, EasyMwsOptions options,
                                 IMarketplaceWebServiceClient mwsClient,
                                 IRequestReportProcessor requestReportProcessor, ICallbackActivator callbackActivator, IEasyMwsLogger logger)
            : this(region, merchantId, mWSAuthToken, options, mwsClient, logger)
        {
            _requestReportProcessor = requestReportProcessor;
            _callbackActivator      = callbackActivator;

            RegisterEvents();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Constructor to be used for UnitTesting/Mocking (in the absence of a dedicated DependencyInjection framework)
        /// </summary>
        internal EasyMwsClient(AmazonRegion region, string merchantId, string accessKeyId, string mwsSecretAccessKey, string mWSAuthToken,
                               IReportQueueingProcessor reportProcessor,
                               IFeedQueueingProcessor feedProcessor, IEasyMwsLogger easyMwsLogger,
                               EasyMwsOptions options)
            : this(region, merchantId, accessKeyId, mwsSecretAccessKey, mWSAuthToken, easyMwsLogger, options)
        {
            _reportProcessor = reportProcessor;
            _feedProcessor   = feedProcessor;

            RegisterEvents();
        }
Ejemplo n.º 6
0
        internal FeedProcessor(AmazonRegion region, string merchantId, string mWSAuthToken, EasyMwsOptions options, IMarketplaceWebServiceClient mwsClient, IEasyMwsLogger logger)
        {
            _region     = region;
            _merchantId = merchantId;
            _options    = options;
            _logger     = logger;

            _callbackActivator = _callbackActivator ?? new CallbackActivator();

            _feedSubmissionProcessor = _feedSubmissionProcessor ?? new FeedSubmissionProcessor(_region, _merchantId, mWSAuthToken, mwsClient, _logger, _options);

            RegisterEvents();
        }
Ejemplo n.º 7
0
 public ReportRequestFailedEventArgs(ReportRequestFailureReasonType requestFailureReason, AmazonRegion amazonRegion, DateTime lastAmazonRequestTimestamp, string lastAmazonStatus, string reportRequestId, string generatedReportId, ReportRequestPropertiesContainer reportRequestPropertiesContainer, string targetHandlerId, string targetHandlerArgs, string reportType)
 {
     RequestFailureReason             = requestFailureReason;
     AmazonRegion                     = amazonRegion;
     LastAmazonRequestTimestamp       = lastAmazonRequestTimestamp;
     LastAmazonStatus                 = lastAmazonStatus;
     ReportRequestId                  = reportRequestId;
     GeneratedReportId                = generatedReportId;
     ReportRequestPropertiesContainer = reportRequestPropertiesContainer;
     TargetHandlerId                  = targetHandlerId;
     TargetHandlerArgs                = targetHandlerArgs;
     ReportType = reportType;
 }
Ejemplo n.º 8
0
 public FeedRequestFailedEventArgs(FeedRequestFailureReasonType requestFailureReason, AmazonRegion amazonRegion, DateTime lastAmazonRequestTimestamp, string lastAmazonStatus, string feedSubmissionId, FeedSubmissionPropertiesContainer feedSubmissionPropertiesContainer, string targetHandlerId, string targetHandlerArgs, string feedContent, string feedType)
 {
     RequestFailureReason              = requestFailureReason;
     AmazonRegion                      = amazonRegion;
     LastAmazonRequestTimestamp        = lastAmazonRequestTimestamp;
     LastAmazonStatus                  = lastAmazonStatus;
     FeedSubmissionId                  = feedSubmissionId;
     FeedSubmissionPropertiesContainer = feedSubmissionPropertiesContainer;
     TargetHandlerId                   = targetHandlerId;
     TargetHandlerArgs                 = targetHandlerArgs;
     FeedContent = feedContent;
     FeedType    = feedType;
 }
Ejemplo n.º 9
0
        private MarketplaceWebServiceConfig CreateConfig(AmazonRegion region)
        {
            string rootUrl;

            switch (region)
            {
            case AmazonRegion.Australia:
                rootUrl = MwsEndpoint.Australia.RegionOrMarketPlaceEndpoint;
                break;

            case AmazonRegion.China:
                rootUrl = MwsEndpoint.China.RegionOrMarketPlaceEndpoint;
                break;

            case AmazonRegion.Europe:
                rootUrl = MwsEndpoint.Europe.RegionOrMarketPlaceEndpoint;
                break;

            case AmazonRegion.India:
                rootUrl = MwsEndpoint.India.RegionOrMarketPlaceEndpoint;
                break;

            case AmazonRegion.Japan:
                rootUrl = MwsEndpoint.Japan.RegionOrMarketPlaceEndpoint;
                break;

            case AmazonRegion.NorthAmerica:
                rootUrl = MwsEndpoint.NorthAmerica.RegionOrMarketPlaceEndpoint;
                break;

            case AmazonRegion.Brazil:
                rootUrl = MwsEndpoint.Brazil.RegionOrMarketPlaceEndpoint;
                break;

            default:
                throw new ArgumentException($"{region} is unknown - EasyMWS doesn't know the RootURL");
            }

            var config = new MarketplaceWebServiceConfig
            {
                ServiceURL = rootUrl
            };

            config = config.WithUserAgent("EasyMWS");

            return(config);
        }
Ejemplo n.º 10
0
        /// <param name="region">The region of the account. Required parameter. A finer grained region or country can be specified on a PropertiesContainer by specifying its marketplaceIdList constructor argument.</param>
        /// <param name="merchantId">Seller ID / Merchant ID. Required parameter.</param>
        /// <param name="accessKeyId">Amazon account access key. Required parameter. This key can either belong to a seller or to a developer account authorized by a seller. If the key belongs to a developer account authorized by the seller then also make sure to specify the MWSAuthToken argument.</param>
        /// <param name="mwsSecretAccessKey">Amazon account secret access key. Required parameter. This key can either belong to a seller or to a developer account authorized by a seller. If the key belongs to a developer account authorized by the seller then also make sure to specify the MWSAuthToken argument.</param>
        /// <param name="mwsAuthToken">MWS Authorization Token. Optional parameter. If the provided access keys belong to a developer account authorized by a seller, this argument is the MWS Authorization Token provided by the seller to the authorized developer.</param>
        /// <param name="easyMwsLogger">An optional IEasyMwsLogger instance that can provide access to logs. It is strongly recommended to use a logger implementation already existing in the EasyMws package.</param>
        /// <param name="options">Configuration options for EasyMwsClient</param>
        public EasyMwsClient(AmazonRegion region, string merchantId, string accessKeyId, string mwsSecretAccessKey, string mwsAuthToken = null,
                             IEasyMwsLogger easyMwsLogger = null, EasyMwsOptions options = null)
        {
            if (string.IsNullOrEmpty(merchantId) || string.IsNullOrEmpty(accessKeyId) ||
                string.IsNullOrEmpty(mwsSecretAccessKey))
            {
                throw new ArgumentNullException(
                          "One or more required parameters provided to initialize the EasyMwsClient were null or empty");
            }

            _amazonRegion = region;
            _merchantId   = merchantId;
            _options      = options ?? new EasyMwsOptions();

            _easyMwsLogger = easyMwsLogger ?? new EasyMwsLogger(isEnabled: false);
            var mwsClient = new MarketplaceWebServiceClient(accessKeyId, mwsSecretAccessKey, CreateConfig(_amazonRegion));

            _reportProcessor = _reportProcessor ?? new ReportProcessor(_amazonRegion, _merchantId, mwsAuthToken, _options, mwsClient, _easyMwsLogger);
            _feedProcessor   = _feedProcessor ?? new FeedProcessor(_amazonRegion, _merchantId, mwsAuthToken, _options, mwsClient, _easyMwsLogger);

            RegisterEvents();
        }
Ejemplo n.º 11
0
 private MwsEndpoint(string regionOrMarketPlace, AmazonRegion region) =>
 (RegionOrMarketPlaceEndpoint, Region) = (regionOrMarketPlace, region);
Ejemplo n.º 12
0
        internal override void WriteXml(XmlTextWriter xmlWriter)
        {
            xmlWriter.WriteStartElement("billing_info"); // Start: billing_info

            //if a recurly js token is supplied we don't want to send billing info here
            if (string.IsNullOrEmpty(TokenId))
            {
                xmlWriter.WriteStringIfValid("first_name", FirstName);
                xmlWriter.WriteStringIfValid("last_name", LastName);
                xmlWriter.WriteStringIfValid("company", Company);
                xmlWriter.WriteStringIfValid("name_on_account", NameOnAccount);
                xmlWriter.WriteStringIfValid("address1", Address1);
                xmlWriter.WriteStringIfValid("address2", Address2);
                xmlWriter.WriteStringIfValid("city", City);
                xmlWriter.WriteStringIfValid("state", State);
                xmlWriter.WriteStringIfValid("zip", PostalCode);
                xmlWriter.WriteStringIfValid("country", Country);
                xmlWriter.WriteStringIfValid("phone", PhoneNumber);
                xmlWriter.WriteStringIfValid("vat_number", VatNumber);
                xmlWriter.WriteStringIfValid("currency", Currency);

                if (!IpAddress.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("ip_address", IpAddress);
                }
                else
                {
                    Debug.WriteLine("Recurly Client Library: Recording IP Address is strongly recommended.");
                }

                if (!CreditCardNumber.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("number", CreditCardNumber);
                    xmlWriter.WriteElementString("month", ExpirationMonth.AsString());
                    xmlWriter.WriteElementString("year", ExpirationYear.AsString());

                    xmlWriter.WriteStringIfValid("verification_value", VerificationValue);
                }

                if (!AccountNumber.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("routing_number", RoutingNumber);
                    xmlWriter.WriteElementString("account_number", AccountNumber);
                    xmlWriter.WriteElementString("account_type", AccountType.ToString().EnumNameToTransportCase());
                }

                if (!PaypalBillingAgreementId.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("paypal_billing_agreement_id", PaypalBillingAgreementId);
                }

                if (!AmazonBillingAgreementId.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("amazon_billing_agreement_id", AmazonBillingAgreementId);
                }

                if (!AmazonRegion.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("amazon_region", AmazonRegion);
                }

                if (ExternalHppType.HasValue)
                {
                    xmlWriter.WriteElementString("external_hpp_type", ExternalHppType.Value.ToString().EnumNameToTransportCase());
                }

                if (!GatewayCode.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("gateway_code", GatewayCode);
                    xmlWriter.WriteElementString("gateway_token", GatewayToken);

                    // EnumNameToTransportCase() turns MasterCard into "master_card",
                    // but it needs to be "master" for the server to accept it.
                    // Check for this edge case before writing the card_type tag.
                    var card = CardType.ToString().EnumNameToTransportCase();
                    if (card == "master_card")
                    {
                        card = "master";
                    }

                    xmlWriter.WriteElementString("card_type", card);
                }
            }

            xmlWriter.WriteStringIfValid("token_id", TokenId);

            xmlWriter.WriteEndElement(); // End: billing_info
        }
Ejemplo n.º 13
0
 public static Connection CreateDynamo(string accessKey, string secretAccessKey, AmazonRegion region) =>
 new Connection(StorageProvider.DynamoDb, accessKey, secretAccessKey, string.Empty, string.Empty, region);
Ejemplo n.º 14
0
 public static Amazon.RegionEndpoint GetAmazonRegion(this AmazonRegion _)
 => Amazon.RegionEndpoint.GetBySystemName(GetAmazonSystemNameEx(_.ToString()));