Пример #1
0
        /// <summary>
        /// Constructor for testing purposes to inject dependencies.
        /// </summary>
        public ServiceRewardsProgramCardEnrollmentController(
            ICardOperations cardOperations)
        {
            if (cardOperations == null)
            {
                throw new ArgumentNullException("cardOperations");
            }

            this.cardOperations = cardOperations;
        }
Пример #2
0
 private void InitSubApis()
 {
     _userOperations      = new UserTemplate(RestTemplate, IsAuthorized);
     _cardOperations      = new CardTemplate(RestTemplate, IsAuthorized);
     _microOperations     = new MicroTemplate(RestTemplate, IsAuthorized);
     _followerOperations  = new FollowerTemplate(RestTemplate, IsAuthorized);
     _followingOperations = new FollowingTemplate(RestTemplate, IsAuthorized);
     _activityOperations  = new ActivityTemplate(RestTemplate, IsAuthorized);
     _highfiveOperations  = new HighfiveTemplate(RestTemplate, IsAuthorized);
 }
Пример #3
0
 public void Raise(ICardOperations cardOperations)
 {
     using (var producer = new ProducerBuilder <Null, string>(_producerConfig).Build())
     {
         var eventMessage = JsonConvert.SerializeObject(cardOperations);
         producer.ProduceAsync(Environment.GetEnvironmentVariable("CardLinked"), new Message <Null, string> {
             Value = eventMessage
         });
         producer.Flush(TimeSpan.FromSeconds(10));
     }
 }
Пример #4
0
        /// <summary>
        /// Retrieves the PartnerCardIds for any MasterCard that has not yet been filtered.
        /// </summary>
        /// <param name="cardOperations">
        /// The object to use to perform card operations.
        /// </param>
        /// <param name="context">
        /// The context of the worker action being executed.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// * Parameter cardOperations cannot be null.
        /// -OR-
        /// * Parameter context cannot be null.
        /// </exception>
        /// <returns>
        /// A list of PartnerCardIds for any MasterCard that has not yet been filtered.
        /// </returns>
        public static IEnumerable <string> RetrieveUnfilteredMasterCards(ICardOperations cardOperations,
                                                                         CommerceContext context)
        {
            if (cardOperations == null)
            {
                throw new ArgumentNullException("cardOperations",
                                                "Parameter cardOperations cannot be null.");
            }

            if (context == null)
            {
                throw new ArgumentNullException("context", "Parameter context cannot be null.");
            }

            context.Log.Verbose("Retrieving PartnerCardIDs for MasterCards that have not yet been filtered.");
            return(cardOperations.RetrieveUnfilteredMasterCards());
        }
Пример #5
0
        /// <summary>
        /// Adds to the data store the filtering date for the MasterCards cards in the specified list.
        /// </summary>
        /// <param name="filteredMasterCards">
        /// The list of MasterCard cards whose filtering data to add to the data store.
        /// </param>
        /// <param name="cardOperations">
        /// The object to use to perform card operations.
        /// </param>
        /// <param name="context">
        /// The context of the worker action being executed.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// * Parameter cardOperations cannot be null.
        /// -OR-
        /// * Parameter context cannot be null.
        /// </exception>
        /// <returns>
        /// The ResultCode corresponding to the result of the data store call.
        /// </returns>
        public static ResultCode AddFilteredMasterCards(IEnumerable <string> filteredMasterCards,
                                                        ICardOperations cardOperations,
                                                        CommerceContext context)
        {
            if (cardOperations == null)
            {
                throw new ArgumentNullException("cardOperations",
                                                "Parameter cardOperations cannot be null.");
            }

            if (context == null)
            {
                throw new ArgumentNullException("context", "Parameter context cannot be null.");
            }

            context.Log.Verbose("Adding to the data store the filtering date for the list of previously unfiltered MasterCard cards.");
            return(cardOperations.AddFilteredMasterCards(filteredMasterCards));
        }
Пример #6
0
        /// <summary>
        /// Adds the card in the context for the user in the context to this partner.
        /// </summary>
        /// <returns>
        /// A task that will yield the result code for the operation.
        /// </returns>
        public async Task <ResultCode> AddCardAsync()
        {
            ResultCode result;

            // If the card has a PAN token, see if a Visa ID has already been allocated for that PAN token. We do this because Visa rejects
            //  registering a card that had previously been registered to a different account. This approach allows us to differentiate false
            //  positives (i.e. Visa rejects a card for which we already have the Visa partner card ID somewhere in our DB) from true positives
            //  (i.e. Visa rejects a card erroneously as far as we can tell.)

            ICardOperations cardOperations = CommerceOperationsFactory.CardOperations(Context);

            //Since we will comment FDC code, FDC PAN token will not be assigned to a card. So the code below is commented since RetrieveVisaPartnerCardId will never return any card
            //without FDC PAN token

            /*
             * Card card = (Card)Context[Key.Card];
             * string visaPartnerCardId = cardOperations.RetrieveVisaPartnerCardId();
             * if (String.IsNullOrWhiteSpace(visaPartnerCardId) == false)
             * {
             *  PartnerCardInfo partnerCardInfo = GetVisaCardInfo(card);
             *  partnerCardInfo.PartnerCardId = visaPartnerCardId;
             *  partnerCardInfo.PartnerCardSuffix = "00";
             *  result = ResultCode.Created;
             *  result = Task.FromResult(result).Result;
             * }
             * else
             */
            {
                var userEnrolledWithVisa = false;
                var cards = cardOperations.RetrieveCards();
                if (cards != null)
                {
                    userEnrolledWithVisa = cards.Any(c => c.CardBrand == CardBrand.Visa);
                }
                result = await InvokeVisaAddCard(userEnrolledWithVisa);
            }

            return(result);
        }
 public CardsController(ICardOperations cardOperations, ILogger <CardsController> logger)
 {
     _cardOperations = cardOperations;
     _logger         = logger;
 }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the SharedCardLogic class.
 /// </summary>
 /// <param name="context">
 /// The context of the current API call.
 /// </param>
 /// <param name="cardOperations">
 /// The object to use to perform operations on cards.
 /// </param>
 public SharedCardLogic(CommerceContext context,
                        ICardOperations cardOperations)
 {
     Context        = context;
     CardOperations = cardOperations;
 }
Пример #9
0
        private void InitSubApis()
        {
            _userOperations = new UserTemplate(RestTemplate, IsAuthorized);
			_cardOperations = new CardTemplate(RestTemplate, IsAuthorized);
			_microOperations = new MicroTemplate(RestTemplate, IsAuthorized);
			_followerOperations = new FollowerTemplate(RestTemplate, IsAuthorized);
			_followingOperations = new FollowingTemplate(RestTemplate, IsAuthorized);
			_activityOperations = new ActivityTemplate(RestTemplate, IsAuthorized);
			_highfiveOperations = new HighfiveTemplate(RestTemplate, IsAuthorized);
        }