/// <summary>
        /// Parse the Message for a NotificationDataResponse
        /// </summary>
        /// <param name="response"></param>
        /// <returns></returns>
        protected override GCheckoutResponse ParseResponse(string response)
        {
            NotificationHistoryResponse retVal = null;

            try {
                retVal = new NotificationHistoryResponse(response);
            }
            catch (Exception ex) {
                string token = null;
                if (retVal != null)
                {
                    token = retVal.NextPageToken;
                }
                Log.Err("NotificationHistoryRequest ParseResponse:" + ex.Message);
                throw new NotificationHistoryException(retVal, token, ex);
            }

            //now process the additional results.
            if (retVal.HasMoreResults && RetrieveAllNotifications)
            {
                ProcessAdditionalTokens(retVal);
            }

            return(retVal);
        }
Example #2
0
 /// <summary>
 /// Add an additional response.
 /// </summary>
 /// <remarks>This is used when processing the nextpagetoken.
 /// We are able to combine multiple messages together.</remarks>
 /// <param name="response">The response to add to this message</param>
 public void AddAdditionalResponse(NotificationHistoryResponse response)
 {
     AutoGen.NotificationHistoryResponse theResponse
         = response.Response as AutoGen.NotificationHistoryResponse;
     if (theResponse != null)
     {
         _additionalResponses.Add(theResponse);
         _notificationResponses = null;
     }
     else
     {
         //TODO wrap the error in a specific error to allow people to obtain the message that blew up.
         throw new NotificationHistoryException(response, response.NextPageToken, null);
     }
 }
        /// <summary>
        /// perform additional queries as needed.
        /// </summary>
        /// <param name="response"></param>
        private void ProcessAdditionalTokens(NotificationHistoryResponse response)
        {
            NotificationHistoryResponse currentResponse = response;

            while (string.IsNullOrEmpty(currentResponse.NextPageToken) == false)
            {
                NotificationHistoryRequest newRequest
                    = new NotificationHistoryRequest(MerchantID, MerchantKey,
                                                     Environment.ToString(), response.NextPageToken);
                try {
                    NotificationHistoryResponse nextResponse = newRequest.Send()
                                                               as NotificationHistoryResponse;
                    response.AddAdditionalResponse(nextResponse);
                    currentResponse = nextResponse;
                }
                catch (Exception ex) {
                    Log.Err("NotificationHistoryRequest ProcessAdditionalTokens:" + ex.Message);
                    throw new NotificationHistoryException(response, response.NextPageToken, ex);
                }
            }
        }