-
Notifications
You must be signed in to change notification settings - Fork 4
/
subscriptions.clj
112 lines (100 loc) · 3.42 KB
/
subscriptions.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
101
102
103
104
105
106
107
108
109
110
111
112
(ns happygapi.youtube.subscriptions
"YouTube Data API: subscriptions.
Supports core YouTube features, such as uploading videos, creating and managing playlists, searching for content, and much more.
See: https://developers.google.com/youtube/v3api/reference/rest/v3/subscriptions"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn delete$
"https://developers.google.com/youtube/v3api/reference/rest/v3/subscriptions/delete
Required parameters: id
Optional parameters: none
Deletes a subscription."
{:scopes ["https://www.googleapis.com/auth/youtube"
"https://www.googleapis.com/auth/youtube.force-ssl"
"https://www.googleapis.com/auth/youtubepartner"]}
[auth args]
{:pre [(util/has-keys? args #{:id})]}
(util/get-response
(http/delete
(util/get-url
"https://www.googleapis.com/youtube/v3/"
"subscriptions"
#{:id}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn insert$
"https://developers.google.com/youtube/v3api/reference/rest/v3/subscriptions/insert
Required parameters: part
Optional parameters: none
Body:
{:contentDetails {:activityType string,
:newItemCount integer,
:totalItemCount integer},
:etag string,
:id string,
:kind string,
:snippet {:channelId string,
:channelTitle string,
:description string,
:publishedAt string,
:resourceId ResourceId,
:thumbnails ThumbnailDetails,
:title string},
:subscriberSnippet {:channelId string,
:description string,
:thumbnails ThumbnailDetails,
:title string}}
Adds a subscription for the authenticated user's channel."
{:scopes ["https://www.googleapis.com/auth/youtube"
"https://www.googleapis.com/auth/youtube.force-ssl"
"https://www.googleapis.com/auth/youtubepartner"]}
[auth args body]
{:pre [(util/has-keys? args #{:part})]}
(util/get-response
(http/post
(util/get-url
"https://www.googleapis.com/youtube/v3/"
"subscriptions"
#{:part}
args)
(merge-with
merge
{:content-type :json,
:body (json/generate-string body),
:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))
(defn list$
"https://developers.google.com/youtube/v3api/reference/rest/v3/subscriptions/list
Required parameters: part
Optional parameters: forChannelId, onBehalfOfContentOwnerChannel, channelId, myRecentSubscribers, pageToken, mine, id, order, mySubscribers, onBehalfOfContentOwner, maxResults
Returns subscription resources that match the API request criteria."
{:scopes ["https://www.googleapis.com/auth/youtube"
"https://www.googleapis.com/auth/youtube.force-ssl"
"https://www.googleapis.com/auth/youtube.readonly"
"https://www.googleapis.com/auth/youtubepartner"]}
[auth args]
{:pre [(util/has-keys? args #{:part})]}
(util/get-response
(http/get
(util/get-url
"https://www.googleapis.com/youtube/v3/"
"subscriptions"
#{:part}
args)
(merge-with
merge
{:throw-exceptions false,
:query-params args,
:accept :json,
:as :json}
auth))))