Skip to content
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

Tagless final refactor #344

Merged
merged 52 commits into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
fa918f6
initial refactoring from free monad to tagless final
bond15 Jan 21, 2020
0999a71
Added Algebras
bond15 Jan 21, 2020
1da6deb
Refactored HttpClient, temporarily bypassing HttpRequestBuilderExtens…
bond15 Jan 22, 2020
714c191
moving /free/domain to /taglessFinal/domain
bond15 Jan 22, 2020
3bbd9cf
Adding interpreters for algebras. Interpreters target the /api classes
bond15 Jan 22, 2020
9c3c9e4
reformatted/linted, remove ADTs from algebras, added more implicit ru…
bond15 Jan 22, 2020
5dc5eb5
updated algebra signatures to match existing api, removed accessToken…
bond15 Jan 23, 2020
1cbc83e
Modified intepreters to fit new algebra definitions and take accessT…
bond15 Jan 23, 2020
0a4abd2
removing free monad implementation
bond15 Jan 23, 2020
295d91e
updating GHWorkflow and Github
bond15 Jan 23, 2020
0f0ba40
for Rafa review
bond15 Jan 23, 2020
87c2f7e
pre merge
bond15 Jan 24, 2020
3bedc4e
Resolved merge conflicts
bond15 Jan 24, 2020
21a1f07
Updated F type constraint F[_]: Applicative -> F[_]: ConcurrentEffect
bond15 Jan 28, 2020
e949ade
For Rafa comment, progress on replacing scalaj-http with http4s
bond15 Jan 28, 2020
85c63c1
For Rafa review and refactor
bond15 Jan 28, 2020
a8ef4fa
applied some refactoring to have clean layers
Jan 29, 2020
20ff5d2
Merge pull request #333 from 47deg/rafactoring
bond15 Jan 29, 2020
bdc110f
Adding toFutue and toId syntax for IO[A]
bond15 Jan 30, 2020
36f8c32
removing unit tests associated with deleted classes
bond15 Jan 30, 2020
52bc263
For Rafa Review, unit tests
bond15 Jan 30, 2020
466f5c0
updating unit tests for interpreters
bond15 Jan 30, 2020
a31b48d
unit test linting
bond15 Jan 31, 2020
e9c5823
refactoring integration test to match new api usage
bond15 Jan 31, 2020
20ee2f5
updating unit and integration test base spec
bond15 Jan 31, 2020
a8de484
linting and updating scala version 2.13 and blaze client
bond15 Jan 31, 2020
32658ed
fixing TestData for integration test
bond15 Feb 1, 2020
aa5ee03
Updateding FakeResponses for Decoder testing
bond15 Feb 1, 2020
834acb2
fix integration test, pull GITHUB4S_ACCESS_TOKEN from sys env
bond15 Feb 1, 2020
4771d05
upgrades some models
Feb 4, 2020
377584d
Revert "upgrades some models"
Feb 4, 2020
bfca4fd
fixes the unit tests
Feb 4, 2020
c62f26a
removes commented import
Feb 4, 2020
8866eb3
fixes the decoders issue for the new http client
Feb 5, 2020
bbedaef
proves the organization's members with the proper token
Feb 5, 2020
3a22ec6
enables commented suites
Feb 5, 2020
0953a07
ignores temporally a test because we are getting permission issues
Feb 5, 2020
245aaf4
Updating documentation, initial draft
bond15 Feb 5, 2020
e8fb004
Update contributing.md
bond15 Feb 13, 2020
e9efcbb
fixing github doc links
bond15 Feb 13, 2020
09800c7
cleaning interpreter imports, retarget issue for testing (123 -> 17)
bond15 Feb 13, 2020
2fc2974
remove old api tests
bond15 Feb 13, 2020
97a05a0
remove mock-server dependency, change http4s version
bond15 Feb 13, 2020
f85cce5
switching to compile-only check in documentation. mdoc:silent -> mdoc…
bond15 Feb 13, 2020
2a95927
Merge branch 'master' into taglessFinalRefactor
Feb 17, 2020
2275c96
Address Ben F. PR comments
bond15 Feb 17, 2020
146733d
Merge branch 'taglessFinalRefactor' of https://github.com/47deg/githu…
bond15 Feb 17, 2020
3e91049
Address Lawrence's PR comments
bond15 Feb 18, 2020
ca172fe
Address Anna M. PR Comments
bond15 Feb 18, 2020
7e9bdcc
Address Ana G. PR comments
bond15 Feb 18, 2020
531fd2c
Address Juan Pedro PR comments
bond15 Feb 20, 2020
42e0fd1
test remove label
bond15 Feb 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,12 @@ lazy val github4s =
)
.settings(coreDeps: _*)

lazy val catsEffect =
(project in file("cats-effect"))
.settings(moduleName := "github4s-cats-effect")
.settings(catsEffectDependencies: _*)
.dependsOn(github4s)

/////////////////////
//// ALL MODULES ////
/////////////////////

lazy val allModules: Seq[ProjectReference] = Seq(github4s, catsEffect)
lazy val allModules: Seq[ProjectReference] = Seq(github4s)

lazy val allModulesDeps: Seq[ClasspathDependency] =
allModules.map(ClasspathDependency(_, None))
Expand Down
27 changes: 0 additions & 27 deletions cats-effect/src/main/scala/github4s/cats/effect/implicits.scala

This file was deleted.

This file was deleted.

35 changes: 19 additions & 16 deletions docs/docs/activity.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@ with Github4s, you can interact with:
- [List stargazers](#list-stargazers)
- [List starred repositories](#list-starred-repositories)

The following examples assume the following imports and token:
The following examples use `cats.effect.IO` and assume the following imports and token:

```scala mdoc:silent
import github4s.Github
import github4s.Github._
import github4s.implicits._
import github4s.GithubIOSyntax._
import cats.effect.IO
import scala.concurrent.ExecutionContext.Implicits.global

implicit val IOContextShift = IO.contextShift(global)
val accessToken = sys.env.get("GITHUB4S_ACCESS_TOKEN")
```

They also make use of `cats.Id`, but any type container implementing `MonadError[M, Throwable]` will do.

Support for `cats.Id`, `cats.Eval`, and `Future` are
provided out of the box when importing `github4s.implicits._`.
They also make use of `cats.Id`, but any type container `F` implementing `ConcurrentEffect` will do.

LiftIO syntax for `cats.Id` and `Future` are provided in `GithubIOSyntax`.


## Notifications

Expand All @@ -44,9 +47,9 @@ You can subscribe or unsubscribe using `setThreadSub`; it takes as arguments:
- `subscribed`: Determines if notifications should be received from this thread.
- `ignored`: Determines if all notifications should be blocked from this thread.

```scala
val threadSub = Github(accessToken).activities.setThreadSub(5, true, false)
threadSub.exec[cats.Id]() match {
```scala mdoc:compile-only
val threadSub = Github[IO](accessToken).activities.setThreadSub(5, true, false)
threadSub.unsafeRunSync match {
case Left(e) => println(s"Something went wrong: ${e.getMessage}")
case Right(r) => println(r.result)
}
Expand All @@ -68,9 +71,9 @@ You can list the users starring a specific repository with `listStargazers`; it

To list the stargazers of 47deg/github4s:

```scala mdoc:silent
val listStargazers = Github(accessToken).activities.listStargazers("47deg", "github4s", true)
listStargazers.exec[cats.Id]() match {
```scala mdoc:compile-only
val listStargazers = Github[IO](accessToken).activities.listStargazers("47deg", "github4s", true)
listStargazers.unsafeRunSync match {
case Left(e) => println(s"Something went wrong: ${e.getMessage}")
case Right(r) => println(r.result)
}
Expand All @@ -95,9 +98,9 @@ the repo was last pushed to), optional.

To list the starred repositories for user `rafaparadela`:

```scala mdoc:silent
val listStarredRepositories = Github(accessToken).activities.listStarredRepositories("rafaparadela", true)
listStarredRepositories.exec[cats.Id]() match {
```scala mdoc:compile-only
val listStarredRepositories = Github[IO](accessToken).activities.listStarredRepositories("rafaparadela", true)
listStarredRepositories.unsafeRunSync match {
case Left(e) => println(s"Something went wrong: ${e.getMessage}")
case Right(r) => println(r.result)
}
Expand All @@ -112,4 +115,4 @@ As you can see, a few features of the activity endpoint are missing.

As a result, if you'd like to see a feature supported, feel free to create an issue and/or a pull request!

[activity-scala]: https://github.com/47deg/github4s/blob/master/github4s/shared/src/main/scala/github4s/free/domain/Activity.scala
[activity-scala]: https://github.com/47deg/github4s/blob/master/github4s/src/main/scala/github4s/domain/Activity.scala
bond15 marked this conversation as resolved.
Show resolved Hide resolved
30 changes: 18 additions & 12 deletions docs/docs/auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ The following examples assume the following imports:

```scala mdoc:silent
import github4s.Github
import github4s.Github._
import github4s.implicits._
import github4s.GithubIOSyntax._
import cats.effect.IO
import scala.concurrent.ExecutionContext.Implicits.global

implicit val IOContextShift = IO.contextShift(global)
```
They also make use of `cats.Id`, but any type container `F` implementing `ConcurrentEffect` will do.

LiftIO syntax for `cats.Id` and `Future` are provided in `GithubIOSyntax`.

**NOTE**: In the examples you will see `Github(None)`
because if you are authenticating for the first time you don't have any access token yet.
Expand All @@ -36,15 +42,15 @@ You can create a new authorization token using `newAuth`; it takes as arguments:
- `client_id`: the 20 character OAuth app client key for which to create the token.
- `client_secret`: the 40 character OAuth app client secret for which to create the token.

```scala
val newAuth = Github(None).auth.newAuth(
```scala mdoc:compile-only
val newAuth = Github[IO](None).auth.newAuth(
"rafaparadela",
"invalidPassword",
List("public_repo"),
"New access token",
"e8e39175648c9db8c280",
"1234567890")
newAuth.exec[cats.Id]() match {
newAuth.unsafeRunSync match {
case Left(e) => println(s"Something went wrong: ${e.getMessage}")
case Right(r) => println(r.result)
}
Expand All @@ -65,12 +71,12 @@ You can authorize a url using `authorizeUrl`; it takes as arguments:
- `redirect_uri`: the URL in your app where users will be sent to after authorization.
- `scopes`: attached to the token, for more information see [the scopes doc](https://developer.github.com/v3/oauth/#scopes).

```scala
val authorizeUrl = Github(None).auth.authorizeUrl(
```scala mdoc:compile-only
val authorizeUrl = Github[IO](None).auth.authorizeUrl(
"e8e39175648c9db8c280",
"http://localhost:9000/_oauth-callback",
List("public_repo"))
authorizeUrl.exec[cats.Id]() match {
authorizeUrl.unsafeRunSync match {
case Left(e) => println(s"Something went wrong: ${e.getMessage}")
case Right(r) => println(r.result)
}
Expand All @@ -93,14 +99,14 @@ You can get an access token using `getAccessToken`; it takes as arguments:
- `redirect_uri`: the URL in your app where users will be sent after authorization.
- `state`: the unguessable random string you optionally provided in [Create a new authorization token](#create-a-new-authorization-token).

```scala mdoc:silent
val getAccessToken = Github(None).auth.getAccessToken(
```scala mdoc:compile-only
val getAccessToken = Github[IO](None).auth.getAccessToken(
"e8e39175648c9db8c280",
"1234567890",
"code",
"http://localhost:9000/_oauth-callback",
"status")
getAccessToken.exec[cats.Id]() match {
getAccessToken.unsafeRunSync match {
case Left(e) => println(s"Something went wrong: ${e.getMessage}")
case Right(r) => println(r.result)
}
Expand All @@ -114,4 +120,4 @@ As you can see, a few features of the authorization endpoint are missing.

As a result, if you'd like to see a feature supported, feel free to create an issue and/or a pull request!

[auth-scala]: https://github.com/47deg/github4s/blob/master/github4s/shared/src/main/scala/github4s/free/domain/Authorization.scala
[auth-scala]: https://github.com/47deg/github4s/blob/master/github4s/src/main/scala/github4s/domain/Authorization.scala
Loading