CloudServices/Notifications/Specification: Difference between revisions

Jump to navigation Jump to search
Line 131: Line 131:
{| class="wikitable"
{| class="wikitable"
|-
|-
! GET
! POST
! PUT
! DELETE
! Path
! Path
! Description
! Description
|-
|-
| style="text-align: center;"|
| style="text-align: center;"|X
| style="text-align: center;"|
| style="text-align: center;"|
| /notifications
| /notifications
| Used by web apps to send notifications. The body of the HTTP request should contain a JSON string of the following form:
| Methods: '''POST'''
Used by web apps to send notifications. The body of the HTTP request should contain a JSON string of the following form:
<pre>
<pre>
{"routing_key": "routing_key",
{"routing_key": "routing_key",
Line 150: Line 143:
  "payload": "notification message"}
  "payload": "notification message"}
</pre>
</pre>
All fields are mandatory.
 
|-
|-
| style="text-align: center;"| X
| style="text-align: center;"|
| style="text-align: center;"|
| style="text-align: center;"|
| /users/'''name'''/subscriptions
| /users/'''name'''/subscriptions
| Retrieves all subscriptions for the user with the specified name. Only the authenticated user corresponding to '''name''' has permission to view this list. The list is returned as a JSON string of the form:
| Methods: '''GET''', '''POST'''
Requires authentication.
GETting this retrieves all subscriptions for the user with the specified name. Appending a query string at the end of the URL (e.g. ''?app_host=mail.google.com&app_name=GMail'') will filter the results by the fields specified. This is useful for determining if a particular subscription exists for a given application name/host pair. The list is returned as a JSON string of the form:
<pre>
<pre>
[{"routing_key": "routing_key",
[{"routing_key": "routing_key",
   "app_name": "Name of app",
   "app_name": "Name of app",
   "app_host": "domain of app"},
   "app_host": "Domain of app",
  "reg_date": "Creation date"},
  ...
  ...
]
]
</pre>
</pre>
Each item in the JSON array corresponds to a subscription for the specified user.
Each item in the JSON array corresponds to a subscription for the specified user.
You can create a new subscription by POSTing to this resource with a HTTP body of the following form:
<pre>
{"app_name": "Application name",
"app_host": "Domain of web app"}
</pre>
If the application name and host field values are unique as a pair, the subscription is created and the following JSON string is returned:
<pre>
{"routing_key": "the routing key created"}
</pre>
|-
| /users/'''name'''/subscriptions/'''routing_key'''
|  Methods: '''GET''', '''DELETE'''
Requires authentication.
GETting this resource will return information about the subscription with the specified routing key. The returned information is of the following form:
<pre>
{"app_name": "Name of app",
"app_host": "Domain of app",
"reg_date": "Creation date"}
</pre>
If you are DELETEing this resource it will remove the subscription and send a notification to all of the user's other clients, telling them the subscription is no longer valid.
|-
|-
| style="text-align: center;"|
| style="text-align: center;"|
| style="text-align: center;"|X
| style="text-align: center;"|
| /users/'''name'''
| /users/'''name'''
| To PUT a user (i.e. create new user account) you'll need an HTTP body looking like the following:
| Methods: '''PUT'''
''Will eventually require a more secure method of creation, e.g. CAPTCHA''
 
To PUT a user (i.e. create new user account) you'll need an HTTP body looking like the following:
<pre>
<pre>
{"password": "user's account password"}
{"password": "user's account password"}
169

edits

Navigation menu