/
assets.clj
65 lines (56 loc) · 1.82 KB
/
assets.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
(ns happygapi.poly.assets
"Poly API: assets.
The Poly API provides read access to assets hosted on <a href=\"https://poly.google.com\">poly.google.com</a> to all, and upload access to <a href=\"https://poly.google.com\">poly.google.com</a> for whitelisted accounts.
See: https://developers.google.com/poly/api/reference/rest/v1/assets"
(:require [cheshire.core :as json]
[clj-http.client :as http]
[happy.util :as util]))
(defn get$
"https://developers.google.com/poly/api/reference/rest/v1/assets/get
Required parameters: name
Optional parameters: none
Returns detailed information about an asset given its name.
PRIVATE assets are returned only if
the currently authenticated user (via OAuth token) is the author of the
asset."
{:scopes nil}
[auth parameters]
{:pre [(util/has-keys? parameters #{:name})]}
(util/get-response
(http/get
(util/get-url
"https://poly.googleapis.com/"
"v1/{+name}"
#{:name}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))
(defn list$
"https://developers.google.com/poly/api/reference/rest/v1/assets/list
Required parameters: none
Optional parameters: keywords, orderBy, format, curated, category, pageToken, maxComplexity, pageSize
Lists all public, remixable assets. These are assets with an access level
of PUBLIC and published under the
CC-By license."
{:scopes nil}
[auth parameters]
{:pre [(util/has-keys? parameters #{})]}
(util/get-response
(http/get
(util/get-url
"https://poly.googleapis.com/"
"v1/assets"
#{}
parameters)
(merge-with
merge
{:throw-exceptions false,
:query-params parameters,
:accept :json,
:as :json}
auth))))