Esempio n. 1
0
        /// <summary>
        /// Returns a list of <see cref="PushChannelSubscription"/> for the current channel, filtered by the currently set clientId and deviceId.
        /// </summary>
        /// <param name="listRequest">A custom <see cref="ListSubscriptionsRequest"/> can be passed. However the current clientId and deviceId are always used. It's mainly to provide further parameters.
        /// If more flexibility is required, please use AblyRest.Push.Admin.ChannelSubscriptions.ListAsync.</param>
        /// <returns>A PaginatedResult of PushChannelSubscription.</returns>
        /// <exception cref="AblyException">Throws an exception if the local device is not activated. Please make sure Push.Activate() has completed.</exception>
        public async Task <PaginatedResult <PushChannelSubscription> > ListSubscriptions(ListSubscriptionsRequest listRequest = null)
        {
            var request = listRequest ?? ListSubscriptionsRequest.Empty();

            var localDevice = _rest.Device;

            if (localDevice?.DeviceIdentityToken is null)
            {
                // TODO: What error code should we use here
                throw new AblyException(
                          $"Cannot list channel subscriptions for '{ChannelName}' because the device is missing deviceIdentityToken. Please call AblyRest.Push.Activate() and wait for it to complete.");
            }

            if (localDevice.ClientId.IsNotEmpty())
            {
                request.ClientId = localDevice.ClientId;
            }

            if (localDevice.Id.IsNotEmpty())
            {
                request.DeviceId = localDevice.Id;
            }

            request.Channel = ChannelName;
            request.ExtraParameters.Add("concatFilters", "true");

            return(await _rest.Push.Admin.ChannelSubscriptions.ListAsync(request));
        }
Esempio n. 2
0
        /// <inheritdoc />
        async Task <PaginatedResult <PushChannelSubscription> > IPushChannelSubscriptions.ListAsync(ListSubscriptionsRequest requestFilter)
        {
            var request = _restClient.CreateGetRequest(ChannelSubUrl);

            request.AddQueryParameters(requestFilter.ToQueryParams());

            return(await _restClient.ExecutePaginatedRequest(request, ListChannelSubscriptions));

            async Task <PaginatedResult <PushChannelSubscription> > ListChannelSubscriptions(PaginatedRequestParams requestParams)
            {
                var paginatedRequest = _restClient.CreateGetRequest(ChannelSubUrl);

                paginatedRequest.AddQueryParameters(requestParams.GetParameters());
                return(await _restClient.ExecutePaginatedRequest(paginatedRequest, ListChannelSubscriptions));
            }
        }