-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Comment API #127
Support Comment API #127
Conversation
Codecov Report
@@ Coverage Diff @@
## master #127 +/- ##
=========================================
- Coverage 88.44% 88.1% -0.34%
=========================================
Files 38 38
Lines 528 555 +27
Branches 2 2
=========================================
+ Hits 467 489 +22
- Misses 61 66 +5
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments, my main concern is the way we've added the new algebras, I've created a new issue to tackle that (#129). Please, move the operations to the Issues algebra/api
Good work overall
docs/src/main/tut/comments.md
Outdated
Github4s supports the [Comments API](https://developer.github.com/v3/activity/comments/). As a result, | ||
with github4s, you can: | ||
|
||
- [Set a thread subscription](#set-a-thread-subscription) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😏 "Set a thread subscription"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any idea how that can be there 😋
docs/src/main/tut/comments.md
Outdated
To create a comment: | ||
|
||
```scala | ||
val editComment = Github(accessToken).comments.edit("47deg", "github4s", 20,"this is the new comment") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-- val editComment = Github(accessToken).comments.edit("47deg", "github4s", 20,"this is the new comment")
++ val editComment = Github(accessToken).comments.edit("47deg", "github4s", 20, "this is the new comment")
docs/src/main/tut/comments.md
Outdated
To create a comment: | ||
|
||
```scala | ||
val createcomment = Github(accessToken).comments.create("47deg", "github4s", 123,"this is the comment") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-- val createcomment = Github(accessToken).comments.create("47deg", "github4s", 123,"this is the comment")
++ val createcomment = Github(accessToken).comments.create("47deg", "github4s", 123, "this is the comment")
docs/src/main/tut/comments.md
Outdated
- `id`: The comment id | ||
- `body`: The new comment description | ||
|
||
To create a comment: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-- To create a comment:
++ To edit a comment:
docs/src/main/tut/comments.md
Outdated
## Delete a Comment | ||
|
||
|
||
You can create a comment for an issue whit the next parameters: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete
docs/src/main/tut/comments.md
Outdated
|
||
See [the API doc](https://developer.github.com/v3/activity/comments/#set-a-thread-subscription) for full reference. | ||
|
||
As you can see, a few features of the pull request endpoint are missing. As a result, if you'd like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments
instead of pull request
@@ -27,5 +27,6 @@ object app { | |||
type COGH05[A] = Coproduct[GitDataOp, COGH04, A] | |||
type COGH06[A] = Coproduct[PullRequestOp, COGH05, A] | |||
type COGH07[A] = Coproduct[NotificationOp, COGH06, A] | |||
type GitHub4s[A] = Coproduct[StatusOp, COGH07, A] | |||
type COGH08[A] = Coproduct[CommentOp, COGH07, A] | |||
type GitHub4s[A] = Coproduct[StatusOp, COGH08, A] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment algebra should be inside of Issue algebra
* @param repo name of the repo | ||
* @param number Issue number | ||
* @param body Comment body | ||
* @return a GHResponse with the created Status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created Comment
* @param repo name of the repo | ||
* @param id Comment id | ||
* @param body Comment body | ||
* @return a GHResponse with the edit Status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edited Comment
* @param owner of the repo | ||
* @param repo name of the repo | ||
* @param id Comment id | ||
* @return a GHResponse with the delete Status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted Comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 , a few minors regarding the doc
docs/src/main/tut/issue.md
Outdated
@@ -138,4 +142,62 @@ The `result` on the right is a [SearchIssuesResult][issue-scala]. | |||
|
|||
See [the API doc](https://developer.github.com/v3/search/#search-issues) for full reference. | |||
|
|||
## Create a Comment | |||
|
|||
You can create a comment for an issue whit the next parameters: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the following parameters
docs/src/main/tut/issue.md
Outdated
## Edit a Comment | ||
|
||
|
||
You can edit a comment from an issue whit the next parameters: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
docs/src/main/tut/issue.md
Outdated
## Delete a Comment | ||
|
||
|
||
You can delete a comment from an issue whit the next parameters: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
|
||
import scalaj.http._ | ||
import scalaj.http.{Http, HttpOptions, HttpRequest, HttpResponse, _} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just scalaj.http._
would suffice, no?
docs/src/main/tut/issue.md
Outdated
@@ -138,4 +142,62 @@ The `result` on the right is a [SearchIssuesResult][issue-scala]. | |||
|
|||
See [the API doc](https://developer.github.com/v3/search/#search-issues) for full reference. | |||
|
|||
## Create a Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have a separate section for comments? like
Issue API
...
Issues
Create an issue
...
Comments
Create a comment
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it
Either.right(GHResult((): Unit, r.code, toLowerCase(r.headers))) | ||
|
||
def decodeEntity[A](r: HttpResponse[String])(implicit D: Decoder[A]): GHResponse[A] = | ||
decode[A](r.body).fold( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI, I think you can use bimap
(from cats.functor.Bifunctor[Either]
) instead of fold
and Either.left
and Either.right
.
Something like (untested) :
decode[A](r.body).bimap(
e => JsonParsingException(e.getMessage, r.body),
result => GHResult(result, r.code, toLowerCase(r.headers))
)
Similarly in HttpRequestBuilderExtensionJS.scala.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't knew bimap, it's really cool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Great work!
Fixes #106 Create, Edit and Delete Comments