﻿// Code generated by Microsoft (R) AutoRest Code Generator 0.9.7.0
// Changes may cause incorrect behavior and will be lost if the code is regenerated.

using Newtonsoft.Json.Linq;

namespace DocumentDBRestApi.Models
{
    /// <summary>
    /// 
    /// </summary>
    public class QueryResourceResponseBody
    {
        /// <summary>
        ///     Optional. The number of items returned.
        /// </summary>
        public int? Count { get; set; }

        /// <summary>
        ///     Optional. The resource id for the collection used within the query
        /// </summary>
        public string Rid { get; set; }

        /// <summary>
        ///     Optional. The date of the request The date is expressed in
        ///     Coordinated Universal Time format.
        /// </summary>
        public string Date { get; set; }

        /// <summary>
        ///     Optional. The array containing the query results.
        /// </summary>
        public string ResourceArray { get; set; }

        /// <summary>
        ///     Optional. This is a unique identifier for the operation. It can be
        ///     used for tracing execution of DocumentDB requests.
        /// </summary>
        public string XMSActivityID { get; set; }

        /// <summary>
        ///     Optional. This is an opaque string returned when the query has
        ///     potentially more items to be retrieved.
        ///     <para>
        ///         The
        ///         x-ms-continuation can be included in subsequent requests as a
        ///         request header to resume execution of the
        ///         query.
        ///     </para>
        ///     <para>
        ///         Clients can fetch subsequent pages of results
        ///         by echoing the x-ms-continuation header as another request. In
        ///         order to read all results, clients must repeat this process until
        ///         an empty x-ms-continuation is returned.
        ///     </para>
        /// </summary>
        public string XMSContinuation { get; set; }

        /// <summary>
        ///     Optional. The number of item returned by the operation.
        /// </summary>
        public int? XMSItemCount { get; set; }

        /// <summary>
        ///     Optional. This is the number of request units (RU) consumed by the
        ///     operation
        /// </summary>
        public int? XMSRequestCharge { get; set; }

        /// <summary>
        ///     Optional. The session token to be used for subsequent requests.
        ///     Used for session consistency
        /// </summary>
        public string XMSSessionToken { get; set; }

        /// <summary>
        ///     Deserialize the object
        /// </summary>
        public virtual void DeserializeJson(JToken inputObject)
        {
            if (inputObject != null && inputObject.Type != JTokenType.Null)
            {
                var countValue = inputObject["_count"];
                if (countValue != null && countValue.Type != JTokenType.Null)
                {
                    Count = (int) countValue;
                }
                var ridValue = inputObject["_rid"];
                if (ridValue != null && ridValue.Type != JTokenType.Null)
                {
                    Rid = (string) ridValue;
                }
                var dateValue = inputObject["Date"];
                if (dateValue != null && dateValue.Type != JTokenType.Null)
                {
                    Date = (string) dateValue;
                }
                var resourceArrayValue = inputObject["Resource_array"];
                if (resourceArrayValue != null && resourceArrayValue.Type != JTokenType.Null)
                {
                    ResourceArray = (string) resourceArrayValue;
                }
                var xMSActivityIDValue = inputObject["x-ms-activity-id"];
                if (xMSActivityIDValue != null && xMSActivityIDValue.Type != JTokenType.Null)
                {
                    XMSActivityID = (string) xMSActivityIDValue;
                }
                var xMSContinuationValue = inputObject["x-ms-continuation"];
                if (xMSContinuationValue != null && xMSContinuationValue.Type != JTokenType.Null)
                {
                    XMSContinuation = (string) xMSContinuationValue;
                }
                var xMSItemCountValue = inputObject["x-ms-item-count"];
                if (xMSItemCountValue != null && xMSItemCountValue.Type != JTokenType.Null)
                {
                    XMSItemCount = (int) xMSItemCountValue;
                }
                var xMSRequestChargeValue = inputObject["x-ms-request-charge"];
                if (xMSRequestChargeValue != null && xMSRequestChargeValue.Type != JTokenType.Null)
                {
                    XMSRequestCharge = (int) xMSRequestChargeValue;
                }
                var xMSSessionTokenValue = inputObject["x-ms-session-token"];
                if (xMSSessionTokenValue != null && xMSSessionTokenValue.Type != JTokenType.Null)
                {
                    XMSSessionToken = (string) xMSSessionTokenValue;
                }
            }
        }
    }
}