Skip to content

Commit

Permalink
Merge pull request #15 from MortarStone/master
Browse files Browse the repository at this point in the history
Add headers to results and handle 429 error
  • Loading branch information
seven1m authored Sep 21, 2020
2 parents 070b6ce + 3871e80 commit 3568b59
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/pco/api/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def delete
def _build_response(result)
case result.status
when 200..299
result.body
res = result.body
res['headers'] = result.headers
res
when 400
fail Errors::BadRequest, result
when 401
Expand All @@ -82,6 +84,8 @@ def _build_response(result)
fail Errors::MethodNotAllowed, result
when 422
fail Errors::UnprocessableEntity, result
when 429
fail Errors::TooManyRequests, result
when 400..499
fail Errors::ClientError, result
when 500
Expand Down
1 change: 1 addition & 0 deletions lib/pco/api/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Forbidden < ClientError; end # 403
class NotFound < ClientError; end # 404
class MethodNotAllowed < ClientError; end # 405
class UnprocessableEntity < ClientError; end # 422
class TooManyRequests < ClientError; end # 429

class ServerError < BaseError; end # 500..599
class InternalServerError < ServerError; end # 500
Expand Down

0 comments on commit 3568b59

Please sign in to comment.