View Code? Open in Web Editor
NEW
✨ Ruby bindings for Calendly API.
Home Page: https://rubygems.org/gems/calendlyr
License: MIT License
calendlyr's People
Contributors
Watchers
calendlyr's Issues
Some methods like client.me
and client.organization
generates a response that probably don't change in the future. Maybe it's a good point caching those responses. Add a reload method for User model to fetch an updated response.
@araluce If you are not planning to add something specific for each response code, this code can be much DRYer 👌🏼
def handle_response ( response )
body = JSON . parse ( response . read_body )
case response . code
when 400
raise Error , "#{ body [ "title" ] } . #{ body [ "message" ] } "
when 401
raise Error , "#{ body [ "title" ] } . #{ body [ "message" ] } "
when 403
raise Error , "#{ body [ "title" ] } . #{ body [ "message" ] } "
when 404
raise Error , "#{ body [ "title" ] } . #{ body [ "message" ] } "
when 429
raise Error , "#{ body [ "title" ] } . #{ body [ "message" ] } "
when 500
raise Error , "#{ body [ "title" ] } . #{ body [ "message" ] } "
when 503
raise Error , "#{ body [ "title" ] } . #{ body [ "message" ] } "
else
body
end
end