/// <summary>
 ///     Sends a set user properties request. Implicitly creates the user if it's not already there.
 ///      Properties could be empty.
 /// </summary>
 /// <param name="uid">ID of the user</param>
 /// <param name="properties">properties a map of all the properties to be associated with the user, could be empty</param>
 /// <param name="eventTime">eventTime timestamp of the event</param>
 /// <returns></returns>
 public async Task<ApiResponse> SetUserAsync(string uid, Dictionary<string, object> properties = null,
     DateTime eventTime = default(DateTime))
 {
     if (eventTime == default(DateTime))
         eventTime = DateTime.Now;
     var model = new EventModel
     {
         EventValue = "$set",
         EntityId = uid,
         EntityType = "user",
         EventTime = eventTime,
         Properties = properties
     };
     return await ExecuteAsync<ApiResponse>(EventQ, Method.POST, model);
 }
        /// <summary>
        ///     Deletes a item.
        /// </summary>
        /// <param name="iid">iid ID of the item</param>
        /// <param name="eventTime">eventTime timestamp of the event</param>
        /// <returns><see cref="ApiResponse"/></returns>
        public ApiResponse DeleteItem(string iid, DateTime eventTime = default(DateTime))
        {
            if (eventTime == default(DateTime))
                eventTime = DateTime.Now;
            var model = new EventModel
            {
                EventValue = "$delete",
                EntityType = "item",
                EventTime = eventTime,
                EntityId = iid,

            };
            return Execute<ApiResponse>(EventQ, Method.POST, model);
        }
        /// <summary>
        ///     Records a user-action-on-item event.
        /// </summary>
        /// <param name="action">action name of the action performed</param>
        /// <param name="uid">uid ID of the user</param>
        /// <param name="iid">iid ID of the item</param>
        /// <param name="properties">properties a map of properties associated with this action</param>
        /// <param name="eventTime">eventTime timestamp of the event</param>
        /// <returns><see cref="ApiResponse"/></returns>
        public ApiResponse UserActionItem(string action, string uid, string iid,
                Dictionary<string, object> properties = null, DateTime eventTime = default(DateTime))
        {
            if (eventTime == default(DateTime))
                eventTime = DateTime.Now;

            var model = new EventModel
            {
                EventValue = action,
                EntityType = "user",
                EntityId = uid,
                TargetEntityType = "item",
                TargetEntityId = iid,
                Properties = properties,
                EventTime = eventTime,
            };
            return Execute<ApiResponse>(EventQ, Method.POST, model);
        }
        /// <summary>
        ///     Sends a delete item request.
        /// </summary>
        /// <param name="iid"> iid ID of the item</param>
        /// <param name="eventTime">eventTime timestamp of the event</param>
        /// <returns><see cref="Task"/></returns>
        public async Task<ApiResponse> DeleteItemAsync(string iid, DateTime eventTime = default(DateTime))
        {
            if (eventTime == default(DateTime))
                eventTime = DateTime.Now;
            var model = new EventModel
            {
                EventValue = "$delete",
                EntityType = "item",
                EventTime = eventTime,
                EntityId = iid,

            };
            return await ExecuteAsync<ApiResponse>(EventQ, Method.POST, model);
            //return await CreateEventAsync();
        }
 /// <summary>
 ///     Unsets properties of a item. The list must not be empty.
 /// </summary>
 /// <param name="iid">iid ID of the item</param>
 /// <param name="properties">properties a list of all the properties to unset</param>
 /// <param name="eventTime">eventTime timestamp of the event</param>
 /// <returns><see cref="ApiResponse"/></returns>
 public ApiResponse UnsetItem(string iid, List<string> properties, DateTime eventTime = default(DateTime))
 {
     if (eventTime == default(DateTime))
         eventTime = DateTime.Now;
     var model = new EventModel
     {
         EventValue = "$unset",
         EntityType = "item",
         EventTime = eventTime,
         EntityId = iid
     };
     return Execute<ApiResponse>(EventQ, Method.POST, model);
 }
 /// <summary>
 ///      Sets properties of a item. Implicitly creates the item if it's not already there.
 ///      Properties could be empty.   
 /// </summary>
 /// <param name="iid"> iid ID of the item</param>
 /// <param name="properties">properties a map of all the properties to be associated with the item, could be empty</param>
 /// <param name="eventTime"> eventTime timestamp of the event</param>
 /// <returns><see cref="ApiResponse"/></returns>
 public ApiResponse SetItem(string iid, Dictionary<string, object> properties, DateTime eventTime = default(DateTime))
 {
     if (eventTime == default(DateTime))
         eventTime = DateTime.Now;
     var model = new EventModel
     {
         EventValue = "$set",
         EntityId = iid,
         EntityType = "item",
         EventTime = eventTime,
         Properties = properties
     };
     return Execute<ApiResponse>(EventQ, Method.POST, model);
 }
        /// <summary>
        ///     Sends a delete user request.
        /// </summary>
        /// <param name="uid">uid ID of the user</param>
        /// <param name="eventTime">eventTime timestamp of the event</param>
        /// <returns><see cref="Task"/></returns>
        public async Task<ApiResponse> DeleteUserAsync(string uid, DateTime eventTime = default(DateTime))
        {
            if (eventTime == default(DateTime))
                eventTime = DateTime.Now;
            var model = new EventModel
            {
                EventValue = "$delete",
                EntityId = uid,
                EntityType = "user",
                EventTime = eventTime
            };
            return await ExecuteAsync<ApiResponse>(EventQ, Method.POST, model);

        }
 /// <summary>
 ///     Unsets properties of a user. The list must not be empty.
 /// </summary>
 /// <param name="uid">uid ID of the user</param>
 /// <param name="properties"></param>
 /// <param name="eventTime">eventTime timestamp of the event</param>
 /// <returns><see cref="ApiResponse"/></returns>
 public ApiResponse UnsetUser(string uid, Dictionary<string, object> properties, DateTime eventTime = default(DateTime))
 {
     if (eventTime == default(DateTime))
         eventTime = DateTime.Now;
     var model = new EventModel
     {
         EventValue = "$unset",
         EntityType = "user",
         EntityId = uid,
         EventTime = eventTime,
     };
     return Execute<ApiResponse>(EventQ, Method.POST, model);
 }