Skip to content

Instantly share code, notes, and snippets.

@th1agoalmeida
Created July 3, 2022 02:58
Show Gist options
  • Save th1agoalmeida/c095a63271bd2708ee4e6cbd4a9e18eb to your computer and use it in GitHub Desktop.
Save th1agoalmeida/c095a63271bd2708ee4e6cbd4a9e18eb to your computer and use it in GitHub Desktop.
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