Skip to content

NoForkinWay/build_your_own_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# README

This program is an API digestible by other programs. It pulls from two separate APIs: (1) Weather Underground (2) api.giphy.com. Our API allows a user to enter thier zipcode, receive a weather condition based on the information entered, and returns a giph based on the given weather condition.

##How it works:

Pulling weather conditions based on zipcode:

def condition
  @response["current_observation"]["weather"]
end

private def get_response
  key = ENV['WUNDERGROUND_KEY']
  HTTParty.get("http://api.wunderground.com/api/#{YOUR KEY HERE}/conditions/q/#{@zip}.json")
end

=====>>>>

def condition_gif
  @response["data"].sample["images"]["fixed_height"]["url"]
end

private def get_response
  forecast = CurrentCondition.new(@zip).condition

  if forecast.match(/(rain)/i)
    HTTParty.get("http://api.giphy.com/v1/gifs/search?q={#{forecast}}&YOUR API KEY HERE")

    ^^ finds the condition of weather in your zipcode and uses regex to extract the key words to match with the corrisponding gif! (There is a series of if else statments to match the current condition)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published