@@ -2,13 +2,13 @@ package io.chrisdavenport.github.endpoints
2
2
3
3
import cats .data ._
4
4
import cats .effect ._
5
+ import fs2 .Stream
5
6
import io .chrisdavenport .github .data .Repositories ._
6
- import org .http4s ._
7
7
import org .http4s .implicits ._
8
8
import org .http4s .client .Client
9
9
import io .chrisdavenport .github .Auth
10
- import io .chrisdavenport .github .data .SearchResult
11
- import io .chrisdavenport .github .data .SearchResult .{ Order , Sort }
10
+ import io .chrisdavenport .github .data .{ Order , SearchResult , Sort }
11
+ import io .chrisdavenport .github .data .Users . User
12
12
import io .chrisdavenport .github .internals .GithubMedia ._
13
13
import io .chrisdavenport .github .internals .RequestConstructor
14
14
@@ -17,20 +17,47 @@ object Search {
17
17
/**
18
18
* Repository Search Endpoint
19
19
* https://developer.github.com/v3/search/#search-repositories
20
+ * @param q The search query string
21
+ * @param sort The sorting method
22
+ * @param order The sorting order
23
+ * @param auth The authentication mechanism
24
+ * @tparam F The effect type
20
25
*/
21
26
def repository [F [_]: Sync ](
22
27
q : String ,
23
- sort : Option [Sort ],
28
+ sort : Option [Sort . Repository ],
24
29
order : Option [Order ],
25
30
auth : Option [Auth ]
26
- ): Kleisli [F , Client [F ], SearchResult [Repo ]] =
27
- RequestConstructor .runRequestWithNoBody [F , SearchResult [Repo ]](
31
+ ): Kleisli [Stream [ F , * ] , Client [F ], SearchResult [Repo ]] =
32
+ RequestConstructor .runPaginatedRequest [F , SearchResult [Repo ]](
28
33
auth,
29
- Method .GET ,
30
34
(uri " search " / " repositories" )
31
35
.withQueryParam(" q" , q)
32
36
.withOptionQueryParam(" sort" , sort.flatMap(Sort .toOptionalParam))
33
37
.withOptionQueryParam(" order" , order.flatMap(Order .toOptionalParam))
34
38
)
35
39
40
+ /**
41
+ * User Search Endpoint
42
+ * https://developer.github.com/v3/search/#search-users
43
+ * @param q The search query string
44
+ * @param sort The sorting method
45
+ * @param order The sorting order
46
+ * @param auth The authentication mechanism
47
+ * @tparam F The effect type
48
+ */
49
+ def users [F [_]: Sync ](
50
+ q : String ,
51
+ sort : Option [Sort .User ],
52
+ order : Option [Order ],
53
+ auth : Option [Auth ]
54
+ ): Kleisli [Stream [F , * ], Client [F ], SearchResult [User ]] =
55
+ RequestConstructor .runPaginatedRequest[F , SearchResult [User ]](
56
+ auth,
57
+ (uri " search " / " users" )
58
+ .withQueryParam(" q" , q)
59
+ .withOptionQueryParam(" sort" , sort.flatMap(Sort .toOptionalParam))
60
+ .withOptionQueryParam(" order" , order.flatMap(Order .toOptionalParam))
61
+ )
62
+
36
63
}
0 commit comments