예제 #1
0
        /// <summary>
        /// Update card
        /// </summary>
        /// <param name="card">Card</param>
        /// <returns>Card</returns>
        public Card Update(Card card)
        {
            card.SetRequiredFields(new List <string> {
                GlobalConstants.ProfileId,
                GlobalConstants.Id
            });
            card.CheckRequiredFields();
            card.SetRequiredFields(new List <string> {
            });
            card.SetOptionalFields(new List <string> {
                GlobalConstants.CardExpiry,
                GlobalConstants.NickName,
                GlobalConstants.MerchantRefNum,
                GlobalConstants.HolderName,
                GlobalConstants.BillingAddressId
            });

            Request request = new Request(
                method: RequestType.Put,
                uri: PrepareUri("/profiles/" + card.ProfileId() + "/cards/" + card.Id()),
                body: card
                );

            dynamic response = _client.ProcessRequest(request);

            Card returnVal = new Card(response);

            returnVal.ProfileId(card.ProfileId());
            return(returnVal);
        }
        private bool CardsAreEquivalent(Card card1, Card card2)
        {
            if (!card1.Id().Equals(card2.Id()) ||
                !card1.LastDigits().Equals(card2.LastDigits()) ||
                !card1.CardExpiry().Month().Equals(card2.CardExpiry().Month()) ||
                !card1.CardExpiry().Year().Equals(card2.CardExpiry().Year()))
            {
                return(false);
            }

            return(true);
        }
예제 #3
0
        /// <summary>
        /// Delete card
        /// </summary>
        /// <param name="card">Card</param>
        /// <returns>bool</returns>
        public bool Delete(Card card)
        {
            card.SetRequiredFields(new List <string> {
                GlobalConstants.ProfileId,
                GlobalConstants.Id
            });
            card.CheckRequiredFields();

            Request request = new Request(
                method: RequestType.Delete,
                uri: PrepareUri("/profiles/" + card.ProfileId() + "/cards/" + card.Id()),
                body: card
                );

            _client.ProcessRequest(request);

            return(true);
        }
예제 #4
0
        /// <summary>
        /// Get card
        /// </summary>
        /// <param name="card">Card</param>
        /// <returns>Card</returns>
        public Card Get(Card card)
        {
            card.SetRequiredFields(new List <string> {
                GlobalConstants.ProfileId,
                GlobalConstants.Id
            });
            card.CheckRequiredFields();

            Request request = new Request(
                method: RequestType.Get,
                uri: PrepareUri("/profiles/" + card.ProfileId() + "/cards/" + card.Id())
                );

            dynamic response = _client.ProcessRequest(request);

            Card returnVal = new Card(response);

            returnVal.ProfileId(card.ProfileId());
            return(returnVal);
        }