Permalink
Browse files

Converted whole search into api v3, fixes #87

  • Loading branch information...
1 parent 40dc371 commit 5247e53d4b51d53ba9f4d5848d902b39dbfb5291 @pksunkara committed Jan 24, 2014
Showing with 44 additions and 52 deletions.
  1. +21 −5 README.md
  2. +11 −27 lib/octonode/search.js
  3. +12 −20 src/octonode/search.coffee
View
@@ -895,25 +895,41 @@ ghteam.member('pksunkara'); //boolean
#### Search issues
```js
-ghsearch.issues('pksunkara/hub', 'open', 'git', callback); //array of issues
+ghsearch.issues({
+ q: 'windows+state:open+repo:pksunkara/hub',
+ sort: 'created'
+ order: 'asc'
+}, callback); //array of search results
```
#### Search repositories
```js
-ghsearch.repos('git', 'javascript', 1, callback); //array of repositories
+ghsearch.repos({
+ q: 'hub+language:go',
+ sort: 'created',
+ order: 'asc'
+}, callback); //array of search results
```
#### Search users
```js
-ghsearch.users('git', callback); //array of users
+ghsearch.users({
+ q: 'tom+followers:>100',
+ sort: 'created',
+ order: 'asc'
+}, callback); //array of search results
```
-#### Search emails
+#### Search code
```js
-ghsearch.emails('pavan.sss1991@gmail.com', callback); //user
+ghsearch.code({
+ q: 'auth+in:file+repo:pksunkara/hub',
+ sort: 'created',
+ order: 'asc'
+}, callback); //array of search results
```
## Testing
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -12,36 +12,28 @@ class Search
constructor: (@client) ->
# Search issues
- issues: (repo, state, keyword, cb) ->
- state = 'open' if state isnt 'closed'
- @client.get "/search/issues/#{repo}/#{state}/#{keyword}", (err, s, b, h) ->
+ issues: (params, cb) ->
+ @client.get "/search/issues", params, (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('Search issues error')) else cb null, b.issues, h
+ if s isnt 200 then cb(new Error('Search issues error')) else cb null, b, h
# Search repositories
- repos: (keyword, language, start_page, cb) ->
- param = {}
- param['language'] = language if language
- param['start_page'] = start_page if start_page
-
- @client.get "/search/repositories/#{keyword}", param, (err, s, b, h) ->
+ repos: (params, cb) ->
+ @client.get "/search/repositories", params, (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('Search repos error')) else cb null, b.repositories, h
+ if s isnt 200 then cb(new Error('Search repos error')) else cb null, b, h
# Search users
users: (keyword, start_page, cb) ->
- param = {}
- param['start_page'] = start_page if start_page
-
- @client.get "/search/users/#{keyword}", param, (err, s, b, h) ->
+ @client.get "/search/users", params, (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('Search users error')) else cb null, b.users, h
+ if s isnt 200 then cb(new Error('Search users error')) else cb null, b, h
- # Search emails
- emails: (email, cb) ->
- @client.get "/legacy/user/email/#{email}", (err, s, b, h) ->
+ # Search code
+ code: (params, cb) ->
+ @client.get "/search/code", params, (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('Search email error')) else cb null, b.user, h
+ if s isnt 200 then cb(new Error('Search email error')) else cb null, b, h
# Export module
module.exports = Search

0 comments on commit 5247e53

Please sign in to comment.