private async Task <ResponsePage <ConnectedDevice> > ListConnectedDevicesFunc(QueryOptions options)
        {
            try
            {
                var resp = await DeviceDirectoryApi.DeviceListAsync(limit : options.Limit, order : options.Order, after : options.After, filter : options.Filter?.FilterString, include : options.Include);

                var respDevices = new ResponsePage <ConnectedDevice>(after: resp.After, hasMore: resp.HasMore, totalCount: resp.TotalCount);
                foreach (var device in resp.Data)
                {
                    respDevices.Add(ConnectedDevice.Map(device, this));
                }

                return(respDevices);
            }
            catch (device_directory.Client.ApiException e)
            {
                throw new CloudApiException(e.ErrorCode, e.Message, e.ErrorContent);
            }
        }
        /// <summary>
        /// Lists all connected devices.
        /// </summary>
        /// <param name="options"><see cref="QueryOptions"/></param>
        /// <returns>The list of connected devices.</returns>
        /// <exception cref="CloudApiException">CloudApiException</exception>
        /// <example>
        /// <code>
        /// try
        /// {
        ///     var options = new QueryOptions();
        ///     options.Filter.Add("createdAt", new DateTime(2017, 1, 1), FilterOperator.GreaterOrEqual);
        ///     options.Filter.Add("createdAt", new DateTime(2018, 1, 1), FilterOperator.LessOrEqual);
        ///     var devices = connectApi.ListConnectedDevices(options);
        ///     foreach (var item in devices)
        ///     {
        ///         Console.WriteLine(item);
        ///     }
        /// }
        /// catch (CloudApiException)
        /// {
        ///     throw;
        /// }
        /// </code>
        /// </example>
        public PaginatedResponse <QueryOptions, ConnectedDevice> ListConnectedDevices(QueryOptions options = null)
        {
            if (options == null)
            {
                options = new QueryOptions();
            }

            if (options.Filter == null)
            {
                options.Filter = new Filter();
            }

            options.Filter.Add("state", "registered");

            try
            {
                return(new PaginatedResponse <QueryOptions, ConnectedDevice>(ListConnectedDevicesFunc, options));
            }
            catch (CloudApiException)
            {
                throw;
            }
        }