def remove(self): self._ensure_exists() remove_subscription_api_request = RemoveSubscriptionApiRequest() remove_subscription_api_request.subscription_id(self._id) api_request = ApiRequest(self._api) api_request.action('%s/unsubscribe' % self._get_subscription_type()) api_request.set('subscriptionId', self._id) api_request.remove_subscription_request( remove_subscription_api_request) api_request.execute('Unsubscribe failure.') self._id = None
def unsubscribe_notifications(self): self._ensure_exists() action = 'notification/insert' self._ensure_subscription_exists(action) subscription_id = self._subscription_id(action) remove_subscription_api_request = RemoveSubscriptionApiRequest() remove_subscription_api_request.subscription_id(subscription_id) api_request = ApiRequest(self._api) api_request.action('notification/unsubscribe') api_request.set('subscriptionId', subscription_id) api_request.remove_subscription_request( remove_subscription_api_request) api_request.execute('Unsubscribe notifications failure.') self._remove_subscription(action, subscription_id)
def unsubscribe_update_commands(self): self._ensure_exists() action = 'command/update' self._ensure_subscription_exists(action) subscription_id = self._subscription_id(action) remove_subscription_api_request = RemoveSubscriptionApiRequest() remove_subscription_api_request.subscription_id(subscription_id) api_request = ApiRequest(self._api) api_request.action('command/unsubscribe') api_request.set('subscriptionId', subscription_id) api_request.remove_subscription_request( remove_subscription_api_request) api_request.execute('Unsubscribe update commands failure.') self._remove_subscription(action, subscription_id)
def unsubscribe_notifications(self, device_ids): action = 'notification/insert' self.ensure_subscription_exists(action, device_ids) subscription_ids, subscription_calls = self._unsubscribe( action, device_ids) for subscription_id in subscription_ids: remove_subscription_api_request = RemoveSubscriptionApiRequest() remove_subscription_api_request.subscription_id(subscription_id) api_request = ApiRequest(self) api_request.action('notification/unsubscribe') api_request.set('subscriptionId', subscription_id) api_request.remove_subscription_request( remove_subscription_api_request) api_request.execute('Unsubscribe notifications failure.') self.remove_subscription(action, subscription_id) timestamp = self.get_info()['server_timestamp'] for subscription_call in subscription_calls: subscription_call['timestamp'] = timestamp self.subscribe_notifications(**subscription_call)