Class used for handling the deserialisation of the Trigger HTTP response.
Пример #1
0
        /// <summary>
        /// Constructs a new instance of a TriggerResult based upon a passed in Rest Response
        /// </summary>
        /// <param name="response">The Rest Response which will form the basis of this Trigger Result</param>
        /// <param name="responseContent">The response content as a string</param>
        public TriggerResult(HttpResponseMessage response, string responseContent) : base(response, responseContent)
        {
            EventIdData eventIdData = null;

            try
            {
                eventIdData = JsonConvert.DeserializeObject <EventIdData>(responseContent);
            }
            catch (Exception)
            {
                string msg = $"The response body from the Pusher HTTP endpoint could not be parsed as JSON: {Environment.NewLine}{response.Content}";
                throw new TriggerResponseException(msg);
            }

            EventIds = new ReadOnlyDictionary <string, string>(eventIdData.event_ids);
        }
Пример #2
0
        /// <summary>
        /// Constructs a new instance of a TriggerResult based upon a passed in Rest Response
        /// </summary>
        /// <param name="response">The Rest Response which will form the basis of this Trigger Result</param>
        public TriggerResult(IRestResponse response) : base(response)
        {
            EventIdData eventIdData = null;

            try
            {
                eventIdData = JsonConvert.DeserializeObject <EventIdData>(response.Content);
            }
            catch (Exception)
            {
                string msg =
                    string.Format("The response body from the Pusher HTTP endpoint could not be parsed as JSON: {0}{1}",
                                  Environment.NewLine,
                                  response.Content);
                throw new TriggerResponseException(msg);
            }

            _eventIds = new ReadOnlyDictionary <string, string>(eventIdData.event_ids);
        }