Skip to content

Commit

Permalink
issues function (towards #8), also, pass data arg through other issue…
Browse files Browse the repository at this point in the history
…s functions
  • Loading branch information
WestleyArgentum committed Mar 2, 2014
1 parent c5c1864 commit 3a1835e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/GitHub.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export authenticate,
repo,
issue,
create_issue,
edit_issue
edit_issue,
issues


include("utils.jl")
Expand Down
47 changes: 45 additions & 2 deletions src/issues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,49 @@ function issue(auth::Authorization, owner::String, repo, num; headers = Dict(),
end


function issues(owner::String, repo; auth = AnonymousAuth(), options...)
issues(auth, owner, repo; options...)
end

function issues(owner::Owner, repo; auth = AnonymousAuth(), options...)
issues(auth, owner.login, repo; options...)
end

function issues(auth::Authorization, owner::String, repo; milestone = nothing,
state = nothing,
assignee = nothing,
creator = nothing,
mentioned = nothing,
labels = nothing,
sort = nothing,
direction = nothing,
since = nothing,
headers = Dict(),
data = Dict(),
options...)
authenticate_headers(headers, auth)

milestone != nothing && (data["milestone"] = milestone)
state != nothing && (data["state"] = state)
assignee != nothing && (data["assignee"] = assignee)
creator != nothing && (data["creator"] = creator)
mentioned != nothing && (data["mentioned"] = mentioned)
labels != nothing && (data["labels"] = labels)
sort != nothing && (data["sort"] = sort)
direction != nothing && (data["direction"] = direction)
since != nothing && (data["since"] = since)

r = get(URI(API_ENDPOINT; path = "/repos/$owner/$repo/issues");
headers = headers,
query = data,
options...)

handle_error(r)

map!(i -> Issue(i), JSON.parse(r.data))
end


function create_issue(owner::String, repo, title; auth = AnonymousAuth(), options...)
create_issue(auth, owner, repo, title; options...)
end
Expand All @@ -82,10 +125,10 @@ function create_issue(auth::Authorization, owner::String, repo, title; body = no
milestone = nothing,
labels = nothing,
headers = Dict(),
data = Dict(),
options...)
authenticate_headers(headers, auth)

data = Dict()
data["title"] = title
body != nothing && (data["body"] = body)
assignee != nothing && (data["assignee"] = assignee)
Expand Down Expand Up @@ -118,10 +161,10 @@ function edit_issue(auth::Authorization, owner::String, repo, num; title = nothi
milestone = nothing,
labels = nothing,
headers = Dict(),
data = Dict(),
options...)
authenticate_headers(headers, auth)

data = Dict()
title != nothing && (data["title"] = title)
body != nothing && (data["body"] = body)
assignee != nothing && (data["assignee"] = assignee)
Expand Down

0 comments on commit 3a1835e

Please sign in to comment.