Subscribe devices to a Topic

@param null $topicId
@param array $deviceTokens
@return \Psr\Http\Message\ResponseInterface
548112
public function subscribeDevicesToTopic($topicId = null, $deviceTokens = array())
    {
        if(!$topicId || empty($deviceTokens)){
            throw new \InvalidArgumentException("Please check arguments!");
        }

        return $this->client->addTopicSubscription($topicId, $deviceTokens);
    }
846395
protected function processTopicSubscription($topic_id, $recipients_tokens, $url)
    {
        if (!is_array($recipients_tokens))
            $recipients_tokens = [$recipients_tokens];

        return $this->guzzleClient->post(
            $url,
            [
                'headers' => [
                    'Authorization' => sprintf('key=%s', $this->apiKey),
                    'Content-Type' => 'application/json'
                ],
                'body' => json_encode([
                    'to' => '/topics/' . $topic_id,
                    'registration_tokens' => $recipients_tokens,
                ])
            ]
        );
    }
957427
public DevVarLongStringArray subscribe(final String deviceName) throws DevFailed {
        xlogger.entry();
        // If first time start the ZMQ management
        if (!isInitialized) {
            initialize();
        }

        // check if event is already subscribed
        final String fullName = EventUtilities.buildDeviceEventName(deviceName, EventType.INTERFACE_CHANGE_EVENT);
        EventImpl eventImpl = eventImplMap.get(fullName);
        if (eventImpl == null) {
            // If not already manage, create EventImpl object and add it to the map
            eventImpl = new EventImpl(DeviceImpl.SERVER_VERSION, fullName);
            eventImplMap.put(fullName, eventImpl);
        } else {
            eventImpl.updateSubscribeTime();
        }

        return buildConnectionParameters(fullName);
    }
1258571
def subscribe_topics(self):
        """"""
        base = self.topic
        subscribe = self.mqtt.subscribe

        # device topics
        subscribe(b"/".join((base, b"$stats/interval/set")))
        subscribe(b"/".join((self.settings.MQTT_BASE_TOPIC, b"$broadcast/#")))

        # node topics
        nodes = self.nodes
        for node in nodes:
            for topic in node.subscribe:
                topic = b"/".join((base, topic))
                # print('MQTT SUBSCRIBE: {}'.format(topic))
                subscribe(topic)
                self.topic_callbacks[topic] = node.callback
867782
public function sendNotification($deviceTokens)
    {
        $this->requestData['tokens'] = $deviceTokens;
        $this->requestData['send_to_all'] = false;
        return $this->create();
    }
805383
@Override
    public java.util.concurrent.Future<SubscribeResult> subscribeAsync(String topicArn, String protocol, String endpoint) {

        return subscribeAsync(new SubscribeRequest().withTopicArn(topicArn).withProtocol(protocol).withEndpoint(endpoint));
    }
829320
public function pub($topic, $data, $excludeUids = [])
    {
        Utility::CheckTopicName($topic);
        ProcessManager::getInstance()->getRpcCall(ClusterProcess::class, true)->my_pub($topic, $data, $excludeUids);
    }
240570
public Device addDevice(String id, String token) throws DuplicateDeviceException, NullIdException, NullDeviceTokenException, Exception {
		if ((id == null) || (id.trim().equals(""))) {
			throw new NullIdException();
		} else if ((token == null) || (token.trim().equals(""))) {
			throw new NullDeviceTokenException();
		} else {
			if (!this.devices.containsKey(id)) {
				token = token.trim().replace(" ", "");
				BasicDevice device = new BasicDevice(id, token, new Timestamp(Calendar.getInstance().getTime().getTime()));
				this.devices.put(id, device);
				return device;
			} else {
				throw new DuplicateDeviceException();
			}
		}
	}
810739
public function bindThirdPoi(array $deviceIdentifier, int $poiId, string $appId)
    {
        $params = [
            'device_identifier' => $deviceIdentifier,
            'poi_id' => $poiId,
            'type' => 2,
            'poi_appid' => $appId,
        ];

        return $this->httpPostJson('shakearound/device/bindlocation', $params);
    }
165745
public function pushAPNMessageToList($appId, $contentId, $deviceTokenList)
    {
        $params = array();
        $params['action'] = 'apnPushToListAction';
        $params['appkey'] = $this->appkey;
        $params['appId'] = $appId;
        $params['contentId'] = $contentId;
        $params['DTL'] = $deviceTokenList;
        $needDetails = GTConfig::isPushListNeedDetails();
        $params['needDetails'] = $needDetails;
        return $this->httpPostJSON($this->host, $params);
    }
294169
public StoredChannel setTopicId(String topicId) {
    lock.lock();
    try {
      this.topicId = topicId;
    } finally {
      lock.unlock();
    }
    return this;
  }
886239
public function authorize(array $devices, string $productId, int $opType = 0)
    {
        $params = [
            'device_num' => count($devices),
            'device_list' => $devices,
            'op_type' => $opType,
            'product_id' => $productId,
        ];

        return $this->httpPostJson('device/authorize_device', $params);
    }
454303
public function getProducer($instanceId, $topicName)
    {
        if ($topicName == NULL || $topicName == "") {
            throw new InvalidArgumentException(400, "TopicName is null or empty");
        }
        return new MQProducer($this->client, $instanceId, $topicName);
    }
622403
public DeviceTokenEnvelope getDeviceToken(String deviceId) throws ApiException {
        ApiResponse<DeviceTokenEnvelope> resp = getDeviceTokenWithHttpInfo(deviceId);
        return resp.getData();
    }
574753
public function registerDevice(Token $token)
    {
        $this->sendInstallationPostRequest(
            '/v1/device-server',
            [
                'headers' => [
                    'X-Bunq-Client-Authentication' => $token->toString(),
                ],
                'json'    => [
                    'description'   => 'Bunq PHP API Client',
                    'secret'        => $this->apiKey,
                    'permitted_ips' => $this->permittedIps,
                ],
            ]
        );
    }
580214
public function mapDeviceMaker(string $deviceMaker, ?string $deviceName = null): ?string
    {
        return (new DeviceMakerMapper())->mapDeviceMaker($deviceMaker, $deviceName);
    }
596889
public function setDeviceStatus($deviceId, $state = null, $level = null)
    {
        $groupAction = 'NO';
        $devices = $this->getPairedDevices();
        foreach ($devices as $d) {
            if ($deviceId === $d['DeviceID']) {
                $groupAction = $d['IsGroupAction'];
            }
        }

        if (intval($level) > 0 && $state === 0) {
            $state = '1';
        }

        $capids = [];
        $capval = [];
        if ($state !== null) {
            $capids[] = '10006';
            $capval[] = $state;
        }
        if ($level !== null) {
            $capids[] = '10008';
            $capval[] = $level . ':0';
        }

        $capIdsString = implode(',', $capids);
        $capValString = implode(',', $capval);

        $service = $this->services['BridgeService']['serviceType'];
        $controlUrl = $this->services['BridgeService']['controlURL'];
        $method = 'SetDeviceStatus';
        $arguments = [
            'DeviceStatusList' => '&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;&lt;DeviceStatusList&gt;&lt;DeviceStatus&gt;&lt;IsGroupAction&gt;' .
                $groupAction .
                '&lt;/IsGroupAction&gt;&lt;DeviceID available=&quot;YES&quot;&gt;' .
                $deviceId .
                '&lt;/DeviceID&gt;&lt;CapabilityID&gt;' .
                $capIdsString .
                '&lt;/CapabilityID&gt;&lt;CapabilityValue&gt;' .
                $capValString .
                '&lt;/CapabilityValue&gt;&lt;LastEventTimeStamp&gt;0&lt;/LastEventTimeStamp&gt;&lt;/DeviceStatus&gt;&lt;/DeviceStatusList&gt;'
        ];

        $rs = $this->client->request($controlUrl, $service, $method, $arguments);
        $rs = $this->unwrapResponse($rs);

        if (isset($rs['s:Fault'])) {
            throw new \Exception('Failed to change bulb state. ' . print_r($rs, true));
        }

        return true;
    }