From 0b2ddf342266f58612a2e8055a9e2f6ee8bc938c Mon Sep 17 00:00:00 2001
From: Gilmoursa <gilmoursa@gmail.com>
Date: Mon, 28 Dec 2015 20:48:05 -0500
Subject: [PATCH 1/6] add zip code method

---
 lib/open_weather/api.rb  | 4 ++++
 lib/open_weather/base.rb | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/open_weather/api.rb b/lib/open_weather/api.rb
index 52b8e18..2d2ce5f 100644
--- a/lib/open_weather/api.rb
+++ b/lib/open_weather/api.rb
@@ -7,6 +7,10 @@ def city(city, options = {})
       new(options.merge(city: city)).retrieve
     end
 
+    def zip(zip, options ={})
+      new(options.merge(zip: zip +",us")).retrieve
+    end
+
     # City Id, an integer value. Eg, 2172797
     # Usage: OpenWeather::Current.city_id(2172797)
     def city_id(id, options = {})
diff --git a/lib/open_weather/base.rb b/lib/open_weather/base.rb
index ae64c5f..c4ef585 100644
--- a/lib/open_weather/base.rb
+++ b/lib/open_weather/base.rb
@@ -24,7 +24,7 @@ def success?
     private
 
     def extract_options!(options)
-      valid_options = [ :id, :lat, :lon, :cnt, :city, :lang, :units, :APPID,
+      valid_options = [ :id, :zip, :lat, :lon, :cnt, :city, :lang, :units, :APPID,
         :country, :bbox]
 
       options.keys.each { |k| options.delete(k) unless valid_options.include?(k) }

From 7970960040a543c51770bf3474f3a646b829cbfb Mon Sep 17 00:00:00 2001
From: Gilmoursa <gilmoursa@gmail.com>
Date: Mon, 28 Dec 2015 21:03:18 -0500
Subject: [PATCH 2/6] append country code to zip method

---
 lib/open_weather/api.rb  | 2 +-
 lib/open_weather/base.rb | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/open_weather/api.rb b/lib/open_weather/api.rb
index 2d2ce5f..887a464 100644
--- a/lib/open_weather/api.rb
+++ b/lib/open_weather/api.rb
@@ -8,7 +8,7 @@ def city(city, options = {})
     end
 
     def zip(zip, options ={})
-      new(options.merge(zip: zip +",us")).retrieve
+      new(options.merge(zip: zip)).retrieve
     end
 
     # City Id, an integer value. Eg, 2172797
diff --git a/lib/open_weather/base.rb b/lib/open_weather/base.rb
index c4ef585..86093e1 100644
--- a/lib/open_weather/base.rb
+++ b/lib/open_weather/base.rb
@@ -29,7 +29,11 @@ def extract_options!(options)
 
       options.keys.each { |k| options.delete(k) unless valid_options.include?(k) }
 
-      if options[:city] || options[:country]
+      if options[:zip]
+        options[:q] = "#{options[:zip]}, #{options[:country]}"
+        options.delete(:zip)
+        options.delete(:country)
+      elsif options[:city] || options[:country]
         options[:q] = "#{options[:country]},#{options[:city]}"
         options.delete(:city)
         options.delete(:country)

From 1226664daf698eae7d4bae32636e9e163340b3f0 Mon Sep 17 00:00:00 2001
From: Gilmoursa <gilmoursa@gmail.com>
Date: Mon, 28 Dec 2015 21:05:56 -0500
Subject: [PATCH 3/6] zip method includes country

---
 lib/open_weather/base.rb | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/lib/open_weather/base.rb b/lib/open_weather/base.rb
index 86093e1..c4ef585 100644
--- a/lib/open_weather/base.rb
+++ b/lib/open_weather/base.rb
@@ -29,11 +29,7 @@ def extract_options!(options)
 
       options.keys.each { |k| options.delete(k) unless valid_options.include?(k) }
 
-      if options[:zip]
-        options[:q] = "#{options[:zip]}, #{options[:country]}"
-        options.delete(:zip)
-        options.delete(:country)
-      elsif options[:city] || options[:country]
+      if options[:city] || options[:country]
         options[:q] = "#{options[:country]},#{options[:city]}"
         options.delete(:city)
         options.delete(:country)

From 90e07839f6f3989b175ae441848165f5ca3587d3 Mon Sep 17 00:00:00 2001
From: Gilmoursa <gilmoursa@gmail.com>
Date: Mon, 28 Dec 2015 21:17:03 -0500
Subject: [PATCH 4/6] update README with new zip method

---
 README.md | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 71ff053..6050b50 100644
--- a/README.md
+++ b/README.md
@@ -59,6 +59,9 @@ OpenWeather::Forecast.city("Cochin, IN")
 # get weather forecast by city name in fahrenheit
 OpenWeather::Forecast.city("Cochin, IN", units: 'imperial')
 
+# get weather forecast by zip code
+OpenWeather::Forecast.zip("33704")
+
 # get weather forecast by city id
 OpenWeather::Forecast.city_id("1273874")
 
@@ -81,7 +84,7 @@ OpenWeather::ForecastDaily.geocode(9.94, 76.26)
 OpenWeather::ForecastDaily.city_id("1273874", cnt: 6)
 ```
 
-Doucumentation about the weather forecast end-point:
+Documentation about the weather forecast end-point:
 http://openweathermap.org/forecast
 
 #### Using the API key

From ee28b066021ba92da2fdb0f04c67395d46464a77 Mon Sep 17 00:00:00 2001
From: Gilmoursa <gilmoursa@gmail.com>
Date: Mon, 28 Dec 2015 21:22:01 -0500
Subject: [PATCH 5/6] update api call formatting for zipcode must include
 country code

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 6050b50..25adeef 100644
--- a/README.md
+++ b/README.md
@@ -60,7 +60,7 @@ OpenWeather::Forecast.city("Cochin, IN")
 OpenWeather::Forecast.city("Cochin, IN", units: 'imperial')
 
 # get weather forecast by zip code
-OpenWeather::Forecast.zip("33704")
+OpenWeather::Forecast.zip("33704,US")
 
 # get weather forecast by city id
 OpenWeather::Forecast.city_id("1273874")

From 7eacf8a75f85e2eb403e838e9ff6a41c6a8e20ad Mon Sep 17 00:00:00 2001
From: Gilmoursa <gilmoursa@gmail.com>
Date: Mon, 28 Dec 2015 21:25:54 -0500
Subject: [PATCH 6/6] update comments for zip method line 10 and 11 api.rb

---
 lib/open_weather/api.rb | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/open_weather/api.rb b/lib/open_weather/api.rb
index 887a464..18323ad 100644
--- a/lib/open_weather/api.rb
+++ b/lib/open_weather/api.rb
@@ -7,6 +7,8 @@ def city(city, options = {})
       new(options.merge(city: city)).retrieve
     end
 
+    #Zip format : 33704,US
+    #Usage: OpenWeather::Current.zip('33704,Us')
     def zip(zip, options ={})
       new(options.merge(zip: zip)).retrieve
     end