-
Notifications
You must be signed in to change notification settings - Fork 11
/
users.clj
118 lines (97 loc) · 3.17 KB
/
users.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
113
114
115
116
117
118
(ns tentacles.users
"Implement the Github Users API: http://developer.github.com/v3/users/"
(:refer-clojure :exclude [keys])
(:use [tentacles.core :only [api-call no-content?]]))
(defn users
"Get info about all users."
[& [options]]
(api-call :get "users" nil options))
(defn user
"Get info about a user."
[user & [options]]
(api-call :get "users/%s" [user] options))
(defn me
"Get info about the currently authenticated user."
[& [options]]
(api-call :get "user" nil options))
(defn edit-user
"Edit the currently authenticated user.
Options are:
name -- User's name.
email -- User's email.
blog -- Link to user's blog.
location -- User's location.
hireable -- Looking for a job?
bio -- User's biography."
[options]
(api-call :patch "user" nil options))
(defn emails
"List the authenticated user's emails."
[options]
(api-call :get "user/emails" nil options))
(defn add-emails
"Add email address(es) to the authenticated user. emails is either
a string or a sequence of emails addresses."
[emails options]
(api-call :post "user/emails" nil (assoc options :raw emails)))
(defn delete-emails
"Delete email address(es) from the authenticated user. Emails is either
a string or a sequence of email addresses."
[emails options]
(no-content? (api-call :delete "user/emails" nil (assoc options :raw emails))))
(defn followers
"List a user's followers."
[user & [options]]
(api-call :get "users/%s/followers" [user] options))
(defn my-followers
"List the authenticated user's followers."
[options]
(api-call :get "user/followers" nil options))
(defn following
"List the users a user is following."
[user & [options]]
(api-call :get "users/%s/following" [user] options))
(defn my-following
"List the users the authenticated user is following."
[options]
(api-call :get "user/following" nil options))
(defn following?
"Check if the authenticated user is following another user."
[user options]
(no-content? (api-call :get "user/following/%s" [user] options)))
(defn follow
"Follow a user."
[user options]
(no-content? (api-call :put "user/following/%s" [user] options)))
(defn unfollow
"Unfollow a user."
[user options]
(no-content? (api-call :delete "user/following/%s" [user] options)))
(defn user-keys
"List the user's public keys."
[user & [options]]
(api-call :get "users/%s/keys" [user] options))
(defn keys
"List the authenticated user's public keys."
[options]
(api-call :get "user/keys" nil options))
(defn specific-key
"Get a specific key from the authenticated user."
[id options]
(api-call :get "user/keys/%s" [id] options))
(defn create-key
"Create a new public key."
[title key options]
(api-call :post "user/keys" nil (assoc options :title title :key key)))
(defn delete-key
"Delete a public key."
[id options]
(no-content? (api-call :delete "user/keys/%s" [id] options)))
(defn my-teams
"List the currently authenticated user's teams across all organizations"
[& [options]]
(api-call :get "user/teams" nil options))
(defn repos
"All repositories for a user."
[user & [options]]
(api-call :get "users/%s/repos" [user] options))