Skip to content

Instantly share code, notes, and snippets.

@kouyaf77
Last active March 4, 2020 19:53
Show Gist options
  • Save kouyaf77/7c54877feaba44a69c1dad7d32717247 to your computer and use it in GitHub Desktop.
Save kouyaf77/7c54877feaba44a69c1dad7d32717247 to your computer and use it in GitHub Desktop.
GoodExampleClient
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