Created
July 3, 2022 02:58
-
-
Save ch1ago/c095a63271bd2708ee4e6cbd4a9e18eb to your computer and use it in GitHub Desktop.
This file contains hidden or 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 'uri' | |
require 'json' | |
require 'net/http' | |
# https://dog.ceo/dog-api/ | |
class DogCeoAPI | |
def self.get_random_mocked | |
{ | |
"message" => "https://images.dog.ceo/breeds/terrier-welsh/lucy.jpg", | |
"status" => "success" | |
} | |
end | |
def self.get_random | |
uri = URI('https://dog.ceo/api/breeds/image/random') | |
response = Net::HTTP.get_response(uri) | |
JSON.parse(response.body) | |
end | |
end | |
end | |
p DogCeoAPI.get_random_mocked | |
p DogCeoAPI.get_random |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment