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

Missing Test and Docs #132

Merged
merged 11 commits into from May 17, 2017
Merged

Missing Test and Docs #132

merged 11 commits into from May 17, 2017

Conversation

AdrianRaFo
Copy link
Contributor

@AdrianRaFo AdrianRaFo commented May 15, 2017

From #131 , this PR covers:

  • activity: Docs missing return value
  • auth: Missing Docs
  • gist : Missing description integration test
  • gitdata: Missing Docs, Missing integration test
  • issue: Doc missing return value in comments
  • pullrequest: Docs misssing return value, Missing unit test
  • repo: Missing unit test
  • user: Missing Docs

Copy link
Contributor

@BenFradet BenFradet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass on the doc 👍

Github4s supports the [Authentication API](https://developer.github.com/v3/oauth_authorizations/). As a result,
with github4s, you can:

- [New authentication](#new-authentication)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a new authorization token would be better I think

with github4s, you can:

- [New authentication](#new-authentication)
- [Authorize url](#authorize-url)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Authorize a URL


- [New authentication](#new-authentication)
- [Authorize url](#authorize-url)
- [Get access token](#get-access-token)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get an access token


## Authentication

### New authentication
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a new authorization token



Call to request a new authorization given a basic authentication, the returned object Authorization includes an
access token
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newAuth can be used to request a new auth token given basic authentication, the returned [Authorization][auth-scala] includes the created token. It takes as arguments:

def getAuth: GHIO[GHResponse[User]] = O.getAuthUser(accessToken)

The `result` on the right is the corresponding [List[User]][user-scala].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User

The `result` on the right is the corresponding [List[User]][user-scala].

See [the API doc](https://developer.github.com/v3/activity/notifications/#set-a-thread-subscription) for full reference.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong link

*/
def getUsers(since: Int, pagination: Option[Pagination] = None): GHIO[GHResponse[List[User]]] =
O.getUsers(since, pagination, accessToken)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

The `result` on the right is the corresponding [List[User]][user-scala].

See [the API doc](https://developer.github.com/v3/activity/notifications/#set-a-thread-subscription) for full reference.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

See [the API doc](https://developer.github.com/v3/activity/notifications/#set-a-thread-subscription) for full reference.

As you can see, a few features of the activity endpoint are missing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user

@AdrianRaFo
Copy link
Contributor Author

Thanks for the feedback. A big part of the changes requested are from the wip

@BenFradet
Copy link
Contributor

@AdrianRaFo I thought you still wanted a review since you requested reviewers, my bad.

set default pagination

```

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could remove this sentence too

# Authentication API

Github4s supports the [Authentication API](https://developer.github.com/v3/oauth_authorizations/). As a result,
with github4s, you can:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-with github4s
+with Github4s


### Create a new authorization token

Used to request a new auth token given basic authentication
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

. at the end of the sentence.


Used to request a new auth token given basic authentication

You can create a tree using `newAuth`, it takes as arguments:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can create a tree?

delete default pagination
Copy link
Contributor

@BenFradet BenFradet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made another pass on the last commit 👍 .

I'm also wondering about the change to the default pagination?


```scala
val newAuth = Github(accessToken).auth.newAuth(
val newAuth = Github(None).auth.newAuth(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this for indicating that no token is required? If so it might be nice to document it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's None because you don't have any accessToken yet, anyway i'm going to document it

@@ -63,16 +60,16 @@ See [the API doc](https://developer.github.com/v3/oauth_authorizations/#create-a

### Authorize a url

Generates the authorize url with a random state, both are returned within Authorize object
Generates the authorize url with a random state, both are returned within Authorize object.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

within an Authorize object.

## Issues

### Create an issue

You can create an issue using `createIssue`, it takes as arguments:

- the repository coordinates (owner and name of the repository)
- the content of the issue (title and body)
- the repository coordinates (owner and name of the repository).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is owner and name in the other doc (true for the others in issue.md)

@codecov-io
Copy link

codecov-io commented May 16, 2017

Codecov Report

Merging #132 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #132   +/-   ##
=====================================
  Coverage      88%    88%           
=====================================
  Files          36     36           
  Lines         550    550           
  Branches        2      2           
=====================================
  Hits          484    484           
  Misses         66     66
Impacted Files Coverage Δ
...b4s/shared/src/main/scala/github4s/api/Users.scala 100% <ø> (ø) ⬆️
...src/main/scala/github4s/free/algebra/UserOps.scala 100% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5d381ac...aac6509. Read the comment docs.

add Github(None) explanation

### Get an access token

Requests an access token based on the code retrieved in the [Create a new authorization token](#create-a-new-authorization-token) step of the oAuth process
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.


See [the API doc](https://developer.github.com/v3/oauth/#web-application-flow) for full reference.

As you can see, a few features of the activity endpoint are missing.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence should be changed, we're not in the activity section, right?


Support for `cats.Id`, `cats.Eval` and `Future` (the only supported option for scala-js) are
provided out of the box when importing `github4s.{js,jvm}.Implicits._`.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove the two paragraphs above?

provided out of the box when importing `github4s.{js,jvm}.Implicits._`.


## Git Data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

See [the API doc](https://developer.github.com/v3/git/blobs/#create-a-blob) for full reference.

## Trees

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed with @BenFradet . We could some background about trees here:

As you probably know, Git can be considered as a tree structure. Each commit creates a new node in that tree. Even we could assume that all the Git commands or methods provided by the API, are just tools that serve to navigate on this tree and to manipulate it.

In the next sections, let's see how Github4s API provides some methods to wrap the Github API.


See [the API doc](https://developer.github.com/v3/git/tags/#create-a-tag-object) for full reference.

As you can see, a few features of the repository endpoint are missing.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

```

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, do we need the next two paragraphs?

### Get a user

Get information for a particular user
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

### Get an authenticated user

Get information of the authenticated user
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

@juanpedromoreno juanpedromoreno removed the request for review from fedefernandez May 16, 2017 11:18
@juanpedromoreno juanpedromoreno changed the title WIP Missing test and docs Missing Test and Docs May 16, 2017
@juanpedromoreno
Copy link
Member

This is great, thanks @AdrianRaFo !

giphy

Let's wait to @BenFradet for final review though :)

Copy link
Contributor

@BenFradet BenFradet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few nits regarding the doc but this looks great! 👍

@@ -0,0 +1,123 @@
---
layout: docs
title: Authentication API
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is tangential / should be treated in another issue/pr but I wonder if we shouldn't rename the API Authorization instead of Authentication to better stick to what github is saying, what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, we could file an issue to tackle it before releasing the next version.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on it 👍

**NOTE**: In the examples you will see `Github(None)`
because if you are authenticating for the first time you don't have any accessToken yet.

## Authentication
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This level isn't needed since this API only deals with auth

// if you're using ScalaJS, replace occurrences of HttpResponse by SimpleHttpResponse
//import github4s.js.Implicits._
//import fr.hmil.roshttp.response.SimpleHttpResponse

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty line

```

**NOTE**: In the examples you will see `Github(None)`
because if you are authenticating for the first time you don't have any accessToken yet.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

access token


### Authorize a url

Generates the authorize url with a random state, both are returned within an Authorize object.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"an authorized URL" and "[Authorize][auth-scala]"

@@ -100,9 +99,10 @@ createPullRequestData.exec[cats.Id, HttpResponse[String]]() match {
}
```

On the other hand, we can pass a `issue` id (through `NewPullRequestIssue` object) instead of the title and the body to get this parameter of the issue
On the other hand, we can pass a `issue` id (through `NewPullRequestIssue` object)
instead of the title and the body to get this parameter of the issue.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand, we can pass an issue id (through a NewPullRequestIssue object) instead of the title and body.


**NOTE**: This option deletes the issue
**NOTE**: This option deletes the issue.

```scala
val createPullRequestIssue = Github(accessToken).pullRequests.create("47deg", "github4s", NewPullRequestIssue("105"),"my-branch","base-branch",Some(true))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no spaces between params and weird indent

### Get an authenticated user

Get information of the authenticated user.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add: "making the API call" at the end of the sentence

def getUsers(
accessToken: Option[String] = None,
headers: Map[String, String] = Map(),
since: Int,
pagination: Option[Pagination] = None
pagination: Option[Pagination] = Some(httpClient.defaultPagination)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious as to why the change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just have setted the same default pagination for all APIs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get back to None, I don't see any benefit changing it .

@@ -87,6 +108,82 @@ class ReposSpec extends BaseSpec {
)
}

"Repos.listcommit" should "call to httpClient.get with the right parameters" in {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

listCommits

@BenFradet
Copy link
Contributor

@AdrianRaFo do you need me to have another look?

@AdrianRaFo
Copy link
Contributor Author

AdrianRaFo commented May 17, 2017

feel free to do it or approve it for merge

Copy link
Contributor

@BenFradet BenFradet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 👍

@juanpedromoreno juanpedromoreno merged commit 02be2ca into master May 17, 2017
@juanpedromoreno juanpedromoreno deleted the arf-131-Missing-test-docs branch May 17, 2017 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants