wdt-skywise-forecast 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/wdt/skywise/forecast/version.rb +1 -1
- data/lib/wdt/skywise/forecast.rb +21 -14
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a5630468679794086ef17b9c19252bcf321b122
|
4
|
+
data.tar.gz: c96acdb2e1883790bbffe222e4a0cd2658dc9113
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddb2dd44d62069150bf7fc467b2481154e035706c45a6eb0c88bbe22424d6417cb9f65205547d8bf003420ca7e7b3558f9f1905b5fa0e680ef5879ccbc789f0a
|
7
|
+
data.tar.gz: 9af18a4685da809250cd7431fe123df8e795f69218dc651b05c2e42af4d4775998a4c87b0ce145f7eb1d8ffff52cc86ab17444f5889a557cec11164aa9f81f00
|
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# WDT Skywise API
|
2
|
+
[![Code Climate](https://codeclimate.com/github/coryp/wdt-skywise-forecast/badges/gpa.svg)](https://codeclimate.com/github/coryp/wdt-skywise-forecast)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/wdt-skywise-forecast.svg)](https://badge.fury.io/rb/wdt-skywise-forecast)
|
2
4
|
[![Build Status](https://travis-ci.org/coryp/wdt-skywise-forecast.svg?branch=master)](https://travis-ci.org/coryp/wdt-skywise-forecast)
|
3
5
|
[![Coverage Status](https://coveralls.io/repos/github/coryp/wdt-skywise-forecast/badge.svg?branch=master)](https://coveralls.io/github/coryp/wdt-skywise-forecast?branch=master)
|
4
6
|
|
@@ -38,8 +40,8 @@ Get weather data:
|
|
38
40
|
|
39
41
|
weather_data = wdt_client.weather_for(ZIP: '32128')
|
40
42
|
|
41
|
-
weather_data.success #
|
42
|
-
weather_data.error #
|
43
|
+
weather_data.success # => true
|
44
|
+
weather_data.error # => nil
|
43
45
|
|
44
46
|
weather_data.response.present? # => true
|
45
47
|
|
data/lib/wdt/skywise/forecast.rb
CHANGED
@@ -30,20 +30,9 @@ module Wdt
|
|
30
30
|
|
31
31
|
def weather_for(options)
|
32
32
|
# validate parameter combinations
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
if options.has_key?(:CITY) && ( !options.has_key?(:STATE) && !options.has_key?(:COUNTRY))
|
38
|
-
return Wdt::Skywise::Forecast::Response.new({error: "STATE or COUNTRY must be provided with CITY", success: false} )
|
39
|
-
end
|
40
|
-
|
41
|
-
if options.has_key?(:LAT) && !options.has_key?(:LONG)
|
42
|
-
return Wdt::Skywise::Forecast::Response.new({error: "LONG must be provided with LAT", success: false} )
|
43
|
-
end
|
44
|
-
|
45
|
-
if options.has_key?(:LONG) && !options.has_key?(:LAT)
|
46
|
-
return Wdt::Skywise::Forecast::Response.new({error: "LAT must be provided with LONG", success: false} )
|
33
|
+
valid = validate_options(options)
|
34
|
+
if !valid[:success]
|
35
|
+
return Wdt::Skywise::Forecast::Response.new({error: valid[:error], success: valid[:success]} )
|
47
36
|
end
|
48
37
|
|
49
38
|
# set format and units defaults
|
@@ -62,6 +51,24 @@ module Wdt
|
|
62
51
|
end
|
63
52
|
|
64
53
|
private
|
54
|
+
def validate_options(options)
|
55
|
+
success = true
|
56
|
+
if options.empty?
|
57
|
+
error = "No parameters specified"
|
58
|
+
success = false
|
59
|
+
elsif options.has_key?(:CITY) && ( !options.has_key?(:STATE) && !options.has_key?(:COUNTRY))
|
60
|
+
error = "STATE or COUNTRY must be provided with CITY"
|
61
|
+
success = false
|
62
|
+
elsif options.has_key?(:LAT) && !options.has_key?(:LONG)
|
63
|
+
error = "LONG must be provided with LAT"
|
64
|
+
success = false
|
65
|
+
elsif options.has_key?(:LONG) && !options.has_key?(:LAT)
|
66
|
+
error = "LAT must be provided with LONG"
|
67
|
+
success = false
|
68
|
+
end
|
69
|
+
{error: error, success: success}
|
70
|
+
end
|
71
|
+
|
65
72
|
def auth
|
66
73
|
{app_id: Wdt::Skywise::Forecast::Client.app_id, app_key: Wdt::Skywise::Forecast::Client.app_key}
|
67
74
|
end
|