Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
Move query objects out of path, Fixes #76
Browse files Browse the repository at this point in the history
  • Loading branch information
pksunkara committed Dec 8, 2013
1 parent fe1ce37 commit 3df282d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 29 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var ghsearch = client.search();
```js ```js
var client = github.client(); var client = github.client();


client.get('/users/pksunkara', function (err, status, body) { client.get('/users/pksunkara', {}, function (err, status, body, headers) {
console.log(body); //json object console.log(body); //json object
}); });
``` ```
Expand All @@ -41,7 +41,7 @@ client.get('/users/pksunkara', function (err, status, body) {
```js ```js
var client = github.client('someaccesstoken'); var client = github.client('someaccesstoken');


client.get('/user', function (err, status, body) { client.get('/user', {}, function (err, status, body, headers) {
console.log(body); //json object console.log(body); //json object
}); });
``` ```
Expand All @@ -54,7 +54,7 @@ var client = github.client({
password: 'password' password: 'password'
}); });


client.get('/user', function (err, status, body) { client.get('/user', {}, function (err, status, body, headers) {
console.log(body); //json object console.log(body); //json object
}); });
``` ```
Expand All @@ -67,7 +67,7 @@ var client = github.client({
secret: 'abcdefghijk' secret: 'abcdefghijk'
}); });


client.get('/user', function (err, status, body) { client.get('/user', {}, function (err, status, body, headers) {
console.log(body); //json object console.log(body); //json object
}); });
``` ```
Expand Down
17 changes: 11 additions & 6 deletions lib/octonode/repo.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions lib/octonode/search.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions src/octonode/repo.coffee
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Repo
if !cb? and cbOrRef if !cb? and cbOrRef
cb = cbOrRef cb = cbOrRef
cbOrRef = 'master' cbOrRef = 'master'
@client.get "/repos/#{@name}/readme?ref=#{cbOrRef}", (err, s, b, h) -> @client.get "/repos/#{@name}/readme", {ref: cbOrRef}, (err, s, b, h) ->
return cb(err) if err return cb(err) if err
if s isnt 200 then cb(new Error("Repo readme error")) else cb null, b, h if s isnt 200 then cb(new Error("Repo readme error")) else cb null, b, h


Expand All @@ -131,7 +131,7 @@ class Repo
if !cb? and cbOrRef if !cb? and cbOrRef
cb = cbOrRef cb = cbOrRef
cbOrRef = 'master' cbOrRef = 'master'
@client.get "/repos/#{@name}/contents/#{path}?ref=#{cbOrRef}", (err, s, b, h) -> @client.get "/repos/#{@name}/contents/#{path}", {ref: cbOrRef}, (err, s, b, h) ->
return cb(err) if err return cb(err) if err
if s isnt 200 then cb(new Error("Repo contents error")) else cb null, b, h if s isnt 200 then cb(new Error("Repo contents error")) else cb null, b, h


Expand Down Expand Up @@ -168,9 +168,8 @@ class Repo
if !cb? and cbOrRecursive if !cb? and cbOrRecursive
cb = cbOrRecursive cb = cbOrRecursive
cbOrRecursive = false cbOrRecursive = false
url = "/repos/#{@name}/git/trees/#{sha}" param = {recursive: 1} if cbOrRecursive
url += "?recursive=1" if cbOrRecursive @client.get "/repos/#{@name}/git/trees/#{sha}", param, (err, s, b, h) ->
@client.get url, (err, s, b, h) ->
return cb(err) if err return cb(err) if err
if s isnt 200 then cb(new Error("Repo tree error")) else cb null, b, h if s isnt 200 then cb(new Error("Repo tree error")) else cb null, b, h


Expand Down
14 changes: 7 additions & 7 deletions src/octonode/search.coffee
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ class Search


# Search repositories # Search repositories
repos: (keyword, language, start_page, cb) -> repos: (keyword, language, start_page, cb) ->
param = '' param = {}
param+= "language=#{language}&" if language param['language'] = language if language
param+= "start_page=#{start_page}&" if start_page param['start_page'] = start_page if start_page


@client.get "/legacy/repos/search/#{keyword}?#{param}", (err, s, b, h) -> @client.get "/legacy/repos/search/#{keyword}", param, (err, s, b, h) ->
return cb(err) if err 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.repositories, h


# Search users # Search users
users: (keyword, start_page, cb) -> users: (keyword, start_page, cb) ->
param = '' param = {}
param+= "start_page=#{start_page}&" if start_page param['start_page'] = start_page if start_page


@client.get "/legacy/user/search/#{keyword}?#{param}", (err, s, b, h) -> @client.get "/legacy/user/search/#{keyword}", param, (err, s, b, h) ->
return cb(err) if err 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.users, h


Expand Down

0 comments on commit 3df282d

Please sign in to comment.