-
Notifications
You must be signed in to change notification settings - Fork 4
/
registrations.clj
100 lines (86 loc) · 3.36 KB
/
registrations.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
(ns happygapi.classroom.registrations
"Google Classroom API: registrations.
Manages classes, rosters, and invitations in Google Classroom.
See: https://developers.google.com/classroom/api/reference/rest/v1/registrations"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn create$
"https://developers.google.com/classroom/api/reference/rest/v1/registrations/create
Required parameters: none
Optional parameters: none
Body:
{:cloudPubsubTopic {:topicName string},
:expiryTime string,
:feed {:courseRosterChangesInfo CourseRosterChangesInfo,
:courseWorkChangesInfo CourseWorkChangesInfo,
:feedType string},
:registrationId string}
Creates a `Registration`, causing Classroom to start sending notifications
from the provided `feed` to the destination provided in `cloudPubSubTopic`.
Returns the created `Registration`. Currently, this will be the same as
the argument, but with server-assigned fields such as `expiry_time` and
`id` filled in.
Note that any value specified for the `expiry_time` or `id` fields will be
ignored.
While Classroom may validate the `cloudPubSubTopic` and return errors on a
best effort basis, it is the caller's responsibility to ensure that it
exists and that Classroom has permission to publish to it.
This method may return the following error codes:
* `PERMISSION_DENIED` if:
* the authenticated user does not have permission to receive
notifications from the requested field; or
* the credential provided does not include the appropriate scope for
the requested feed.
* another access error is encountered.
* `INVALID_ARGUMENT` if:
* no `cloudPubsubTopic` is specified, or the specified
`cloudPubsubTopic` is not valid; or
* no `feed` is specified, or the specified `feed` is not valid.
* `NOT_FOUND` if:
* the specified `feed` cannot be located, or the requesting user does
not have permission to determine whether or not it exists; or
* the specified `cloudPubsubTopic` cannot be located, or Classroom has
not been granted permission to publish to it."
{:scopes ["https://www.googleapis.com/auth/classroom.push-notifications"]}
[auth args body]
{:pre [(util/has-keys? args #{})]}
(util/get-response
(http/post
(util/get-url
"https://classroom.googleapis.com/"
"v1/registrations"
#{}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn delete$
"https://developers.google.com/classroom/api/reference/rest/v1/registrations/delete
Required parameters: registrationId
Optional parameters: none
Deletes a `Registration`, causing Classroom to stop sending notifications
for that `Registration`."
{:scopes ["https://www.googleapis.com/auth/classroom.push-notifications"]}
[auth args]
{:pre [(util/has-keys? args #{:registrationId})]}
(util/get-response
(http/delete
(util/get-url
"https://classroom.googleapis.com/"
"v1/registrations/{registrationId}"
#{:registrationId}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))