Skip to content

Commit 3a1835e

Browse files
issues function (towards #8), also, pass data arg through other issues functions
1 parent c5c1864 commit 3a1835e

File tree

2 files changed

+47
-3
lines changed

2 files changed

+47
-3
lines changed

src/GitHub.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ export authenticate,
5353
repo,
5454
issue,
5555
create_issue,
56-
edit_issue
56+
edit_issue,
57+
issues
5758

5859

5960
include("utils.jl")

src/issues.jl

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,49 @@ function issue(auth::Authorization, owner::String, repo, num; headers = Dict(),
6969
end
7070

7171

72+
function issues(owner::String, repo; auth = AnonymousAuth(), options...)
73+
issues(auth, owner, repo; options...)
74+
end
75+
76+
function issues(owner::Owner, repo; auth = AnonymousAuth(), options...)
77+
issues(auth, owner.login, repo; options...)
78+
end
79+
80+
function issues(auth::Authorization, owner::String, repo; milestone = nothing,
81+
state = nothing,
82+
assignee = nothing,
83+
creator = nothing,
84+
mentioned = nothing,
85+
labels = nothing,
86+
sort = nothing,
87+
direction = nothing,
88+
since = nothing,
89+
headers = Dict(),
90+
data = Dict(),
91+
options...)
92+
authenticate_headers(headers, auth)
93+
94+
milestone != nothing && (data["milestone"] = milestone)
95+
state != nothing && (data["state"] = state)
96+
assignee != nothing && (data["assignee"] = assignee)
97+
creator != nothing && (data["creator"] = creator)
98+
mentioned != nothing && (data["mentioned"] = mentioned)
99+
labels != nothing && (data["labels"] = labels)
100+
sort != nothing && (data["sort"] = sort)
101+
direction != nothing && (data["direction"] = direction)
102+
since != nothing && (data["since"] = since)
103+
104+
r = get(URI(API_ENDPOINT; path = "/repos/$owner/$repo/issues");
105+
headers = headers,
106+
query = data,
107+
options...)
108+
109+
handle_error(r)
110+
111+
map!(i -> Issue(i), JSON.parse(r.data))
112+
end
113+
114+
72115
function create_issue(owner::String, repo, title; auth = AnonymousAuth(), options...)
73116
create_issue(auth, owner, repo, title; options...)
74117
end
@@ -82,10 +125,10 @@ function create_issue(auth::Authorization, owner::String, repo, title; body = no
82125
milestone = nothing,
83126
labels = nothing,
84127
headers = Dict(),
128+
data = Dict(),
85129
options...)
86130
authenticate_headers(headers, auth)
87131

88-
data = Dict()
89132
data["title"] = title
90133
body != nothing && (data["body"] = body)
91134
assignee != nothing && (data["assignee"] = assignee)
@@ -118,10 +161,10 @@ function edit_issue(auth::Authorization, owner::String, repo, num; title = nothi
118161
milestone = nothing,
119162
labels = nothing,
120163
headers = Dict(),
164+
data = Dict(),
121165
options...)
122166
authenticate_headers(headers, auth)
123167

124-
data = Dict()
125168
title != nothing && (data["title"] = title)
126169
body != nothing && (data["body"] = body)
127170
assignee != nothing && (data["assignee"] = assignee)

0 commit comments

Comments
 (0)