Commit 24237b46 by David Robinson

Merge pull request #86 from LetsOrder/master

Added Installation channel subscription modification
parents 4db8a436 4a6bb305
......@@ -19,6 +19,35 @@ from parse_rest.query import QueryManager
class Installation(ParseResource):
ENDPOINT_ROOT = '/'.join([API_ROOT, 'installations'])
@classmethod
def _get_installation_url(cls, installation_id):
"""
Get the URL for RESTful operations on this particular installation
"""
return '/'.join([cls.ENDPOINT_ROOT, installation_id])
@classmethod
def update_channels(cls, installation_id, channels_to_add=set(),
channels_to_remove=set(), **kw):
"""
Allow an application to manually subscribe or unsubscribe an
installation to a certain push channel in a unified operation.
this is based on:
https://www.parse.com/docs/rest#installations-updating
installation_id: the installation id you'd like to add a channel to
channels_to_add: the name of the channel you'd like to subscribe the user to
channels_to_remove: the name of the channel you'd like to unsubscribe the user from
"""
installation_url = cls._get_installation_url(installation_id)
current_config = cls.GET(installation_url)
new_channels = list(set(current_config['channels']).union(channels_to_add).difference(channels_to_remove))
cls.PUT(installation_url, channels=new_channels)
class Push(ParseResource):
ENDPOINT_ROOT = '/'.join([API_ROOT, 'push'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment