/// <summary>
        /// Gets the list subscribers.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="limit">The limit.</param>
        /// <param name="page">The page.</param>
        /// <param name="firstName">The first name to search for in the list.</param>
        /// <param name="lastName">The last name to search for in the list.</param>
        /// <param name="mobileNumber">The mobile number to search for in the list.</param>
        /// <param name="searchOperator">The search operator to use if multiple search params are provided.</param>
        /// <returns></returns>
        public SubscribersResponse GetListSubscribers(int id, int?limit = null, int?page = null, string firstName = null, string lastName = null, string mobileNumber = null, SearchOperator searchOperator = SearchOperator.AND, SubscriberStatus status = SubscriberStatus.ACTIVE)
        {
            var request = new RestRequest($"lists/{id}/subscribers");

            request.Method = Method.GET;

            if (limit.HasValue)
            {
                request.AddParameter("limit", limit, ParameterType.GetOrPost);
            }

            if (page.HasValue)
            {
                request.AddParameter("page", page, ParameterType.GetOrPost);
            }

            var searchParams = 0;

            if (!string.IsNullOrWhiteSpace(firstName))
            {
                request.AddParameter("first", firstName, ParameterType.GetOrPost);
                searchParams = searchParams + 1;
            }

            if (!string.IsNullOrWhiteSpace(lastName))
            {
                request.AddParameter("last", lastName, ParameterType.GetOrPost);
                searchParams = searchParams + 1;
            }

            if (!string.IsNullOrWhiteSpace(mobileNumber))
            {
                request.AddParameter("mobile_number", mobileNumber, ParameterType.GetOrPost);
                searchParams = searchParams + 1;
            }

            request.AddParameter("status", status.ToString(), ParameterType.GetOrPost);
            searchParams = searchParams + 1;

            if (searchParams > 1)
            {
                request.AddParameter("operator", searchOperator.ToString(), ParameterType.GetOrPost);
            }

            return(Execute <SubscribersResponse>(request));
        }
Ejemplo n.º 2
0
        public void Start()
        {
            log.Trace($"{nameof(Start)}() started.");
            log.Info($"Attemting to start subscriber for queue: {readQueue.Path}");

            if (status != SubscriberStatus.Paused && status != SubscriberStatus.Stopped)
            {
                log.Error($"Attempt to start subscription failed. {nameof(Start)}() method was called when status was : {status.ToString()}.");
                throw new InvalidOperationException($"Subscriber cannot be started. Current state is: {status.ToString()}.");
            }

            try
            {
                status = SubscriberStatus.Starting;

                if (!onCompleteRegistered)
                {
                    log.Trace("Registering OnPeakComplete.");
                    readQueue.PeekCompleted += OnPeakComplete;
                    onCompleteRegistered     = true;
                }
                else
                {
                    log.Trace("OnPeakComplete event already registered.");
                }

                readQueue.BeginPeek();
                status = SubscriberStatus.Started;

                log.Info($"Subscriber {readQueue.Path} started.");
            }
            catch (Exception ex)
            {
                status = SubscriberStatus.Stopped;
                log.Error($"Error while attemtping to start subscriber: {ex.Message}", ex);
                throw ex;
            }

            log.Trace($"{nameof(Start)}() complete.");
        }