Returns the processed response to PUBSUB NUMSUB.

@param array $channels List of channels

@return array
1955
protected static function processNumsub(array $channels)
    {
        $processed = array();
        $count = count($channels);

        for ($i = 0; $i < $count; ++$i) {
            $processed[$channels[$i]] = $channels[++$i];
        }

        return $processed;
    }
1068433
public function getAllSubscriptions()
    {
        $limit = RequestInterface::MAX_LIST_LIMIT;
        $offset = 0;
        $subscriptions = [[]];

        while (true) {
            $subscriptionBatch = $this->getSubscriptionsResponse($offset);
            $subscriptions[] = $subscriptionBatch;
            $offset += $limit;
            if (\count($subscriptionBatch) < $limit) {
                break;
            }
        }

        return \array_merge(...$subscriptions);
    }
973700
public function getHttpResponse(array $headers = [])
    {
        $client = new Client();
        $urls = $this->getUrl();

        return $client->request('GET', $urls[0], ['stream' => true, 'headers' => $headers]);
    }
919605
public function getSubscriptionsCount()
    {
        $cache = Podium::getInstance()->podiumCache->getElement('user.subscriptions', $this->id);
        if ($cache === false) {
            $cache = (new Query)->from(Subscription::tableName())->where([
                    'user_id' => $this->id,
                    'post_seen' => Subscription::POST_NEW
                ])->count();
            Podium::getInstance()->podiumCache->setElement('user.subscriptions', $this->id, $cache);
        }
        return $cache;
    }
158600
public static function listAllDiscountCouponsAsync(array $parameters = [])
    {
        return self::listAllDiscountCouponsAsyncWithHttpInfo($page, $size, $sort)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }
1212731
protected function getChannels($channels)
    {
        $channels = trim($channels);

        if (empty($channels)) {
            throw new InvalidArgumentException('No channel found.');
        }

        return $channels === '*' ? [] : explode(',', $channels);
    }
890221
public function pubSubLoop($channels, callable $callback)
    {
        $pubsub = new PubSub\Consumer($this, $callback);

        if (\is_string($channels)) {
            $channels = ['subscribe' => [$channels]];
        }

        if (isset($channels['subscribe'])) {
            $pubsub->subscribe($channels['subscribe']);
        }

        if (isset($channels['psubscribe'])) {
            $pubsub->psubscribe($channels['psubscribe']);
        }

        return $pubsub;
    }
50294
public function channelsList($limit = 25, $offset = 0)
    {
        return $this->auth->request(
            'GET',
            '/channels.json',
            array('query' => array('limit' => (int) $limit, 'offset' => (int) $offset))
        );
    }
1342085
public function createMultiple(array $subscribers)
    {
        $defaults = ['language' => 'sv', 'update_on_duplicate' => true, 'tags' => [], 'automation' => false];

        $subscribers = array_merge($defaults, $subscribers);

        foreach ($subscribers['subscribers'] as $subscriber) {
            $this->assertValidSubscriberParams($subscriber);
        }

        $params = [
            'automation' =>  $subscribers['automation'],
            'update_on_duplicate' => $subscribers['update_on_duplicate'],
            'tags' => $subscribers['tags']
        ];

        $params['subscribers'] = array_map(function($subscriber){
            return $this->getSubscriberParams($subscriber);
        }, $subscribers['subscribers']);

        $request = new Request('subscribers');
        $request->setParams($params);

        $response = $this->client->post($request);

        $this->assertSuccessResponse($response);

        return $response->getData();
    }
1307969
public function getSubscription(array $options = array())
    {
        $params = $this->defaultRequestParams();
        $params['body'] = $options;

        $response = $this->call('acquia.agent.subscription', $params);
        return Subscription::loadFromResponse($this->networkId, $this->networkKey, $response);
    }
1366337
protected static function get_hold_channels($channels)
    {
        $ichannels = array();
        foreach ($channels as $channel) {
            if (is_string($channel)) {
                $channel = new Channel($channel);
            }
            $ichannel = array();
            $ichannel['name'] = $channel->name;
            if (!is_null($channel->prev_id)) {
                $ichannel['prev-id'] = $channel->prev_id;
            }
            $ichannels[] = $ichannel;
        }
        return $ichannels;
    }
1341004
public function getChannelCfg($channel)
    {
        if (!isset($this->channels[$channel])) {
            throw new \Erebot\NotFoundException('No such channel');
        }
        return $this->channels[$channel];
    }
1088360
private function validateChannel($channels = [], $returnAsArray = true)
    {
        if ($returnAsArray) {
            if (is_string($channels)) {
                $channels = [$channels];
            }
            if (empty($channels)) {
                return ['public'];
            }
            foreach ($channels as $channel) {
                if (strpos($channel, ' ') !== false) {
                    throw new InvalidChannelException('No spaces are allowed in channel names.');
                }
            }

            return json_encode($channels);
        } else {
            if (empty($channels)) {
                return 'public';
            }
            if (strpos($channels, ' ') !== false) {
                throw new InvalidChannelException('No spaces are allowed in channel names.');
            }

            return $channels;
        }
    }
141496
public function subscribe($channel, callable $handler)
    {
        $subscription = $this->getSubscriptionForChannel($channel);

        $isSubscriptionLoopActive = true;
        $isPauseEnabled = $this->returnImmediately && ($this->returnImmediatelyPause > 0);

        while ($isSubscriptionLoopActive) {
            $messages = $subscription->pull([
                'grpcOptions' => [
                    'timeoutMillis' => null,
                ],
                'maxMessages' => $this->maxMessages,
                'returnImmediately' => $this->returnImmediately,
            ]);
            if ($isPauseEnabled && empty($messages)) {
                usleep($this->returnImmediatelyPause);
                continue;
            }
            foreach ($messages as $message) {
                /** @var Message $message */
                $payload = Utils::unserializeMessagePayload($message->data());

                if ($payload === 'unsubscribe') {
                    $isSubscriptionLoopActive = false;
                } else {
                    call_user_func($handler, $payload);
                }

                $subscription->acknowledge($message);
            }
        }
    }
374904
public function responseNews(array $articles)
    {
        if (isset($articles['title'])) {
            $articles = [$articles];
        }
        $response = [
            'MsgType' => 'news',
            'ArticleCount' => count($articles),
        ];
        foreach ($articles as $article) {
            $response['Articles'][] = [
                'Title' => $article['title'],
                'Description' => $article['description'],
                'PicUrl' => $article['picUrl'],
                'Url' => $article['url']
            ];
        }
        return $response;
    }
976753
public function getSubscriptions($limit = 100, $offset = 0)
    {
        /** @var SubscriptionFbApi $response */
        $response = $this->call(new Request('subscription.get', array(), $limit, $offset), 'DVelopment\FastBill\Model\SubscriptionFbApi');

        return $response->getResponse()->getSubscriptions();
    }
1224668
public function list_current_channels()
    {
        if (!$this->is_loggedin) {
            return false;
        }

        $response = $this->exec_curl('/api/s/' . $this->site . '/stat/current-channel');

        return $this->process_response($response);
    }