Skip to content
This repository has been archived by the owner on Dec 27, 2018. It is now read-only.

Commit

Permalink
Fixes #4 #5
Browse files Browse the repository at this point in the history
  • Loading branch information
emmenko committed Feb 27, 2014
1 parent e657269 commit a6fdf6b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/coffee/oauth2.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ class OAuth2
timeout: @_options.timeout
rejectUnauthorized: @_options.rejectUnauthorized

@logger.info 'Retrieving access_token...'
@logger.debug request_options, 'Retrieving access_token...'
@_doRequest(request_options, callback)

_doRequest: (options, callback) ->
request options, (e, r, b) =>
@logger.error e if e
@logger.debug request: r.request, response: r, 'OAuth response'
@logger.debug {request: r.request, response: r}, 'OAuth response'
callback(e, r, b)

###
Expand Down
19 changes: 11 additions & 8 deletions src/coffee/rest.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,28 @@ class Rest
return

GET: (resource, callback) ->
@logger.info "Project '#{@_options.config.project_key}'", 'GET', resource
params =
resource: resource
method: 'GET'
resource: resource
@logger.debug _.extend {}, params,
project: @_options.config.project_key
@_preRequest(params, callback)

POST: (resource, payload, callback) ->
@logger.info "Project '#{@_options.config.project_key}'", 'POST', resource, payload
params =
resource: resource
method: 'POST'
resource: resource
body: payload
@logger.debug _.extend {}, params,
project: @_options.config.project_key
@_preRequest(params, callback)

DELETE: (resource, callback) ->
@logger.info "Project '#{@_options.config.project_key}'", 'DELETE', resource
params =
resource: resource
method: 'DELETE'
resource: resource
@logger.debug _.extend {}, params,
project: @_options.config.project_key
@_preRequest(params, callback)

PUT: -> throw new Error 'Not implemented yet'
Expand Down Expand Up @@ -85,7 +88,7 @@ class Rest
access_token = body.access_token
@_options.access_token = access_token
@_options.headers['Authorization'] = "Bearer #{@_options.access_token}"
@logger.info 'New access_token received', access_token
@logger.debug 'New access_token received', access_token
# call itself again (this time with the access_token)
_req(0)
else
Expand All @@ -107,7 +110,7 @@ class Rest
_doRequest: (options, callback) ->
request options, (e, r, b) =>
@logger.error e if e
@logger.debug request: r.request, response: r, 'Rest response'
@logger.debug {request: r.request, response: r}, 'Rest response'
callback(e, r, b)

###
Expand Down

0 comments on commit a6fdf6b

Please sign in to comment.