Last active
March 4, 2020 19:53
-
-
Save kouyaf77/7c54877feaba44a69c1dad7d32717247 to your computer and use it in GitHub Desktop.
GoodExampleClient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'faraday' | |
class GoodExampleClient | |
DEFAULT_URL = 'https://example.com'.freeze | |
def get(url=DEFAULT_URL) | |
r = Faraday.get url | |
Response.new(r.body, r.status) | |
end | |
class Response | |
attr_reader :body, :status | |
def initialize(body, status) | |
@body = body | |
@status = status | |
end | |
def success? | |
status == 200 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment