kakaxi 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/kakaxi.gemspec +1 -1
- data/lib/kakaxi/client.rb +13 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a872ce6556617daf9f2215400ec0dce065263ed9f3d95e9d8c0cb564779df11d
|
4
|
+
data.tar.gz: e2f67eeef2bf52c2bea1466582828122ecc3344ada7667f490b06c3da9fcec75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db5d869c9c32f50da5d88bf00da4b8dc03a380038f61364681f239c3b1769ef31e46eb7e3a223a380665a8bdad43c2ed89f962ada5b7bb430d8ac14b19bd3ce7
|
7
|
+
data.tar.gz: 2b502fb8515c118d5678312bb5b7edc94f04ebaa5d52dfe31104bad4aa9e9b7b2061e9de274bc852ef2057df088dc2a27d6793e8ced62dac74eecbf4b6fb449d
|
data/kakaxi.gemspec
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'kakaxi'
|
6
|
-
s.version = '0.0.
|
6
|
+
s.version = '0.0.4'
|
7
7
|
s.date = '2017-09-10'
|
8
8
|
s.summary = 'Library for calling kakaxi api by ruby'
|
9
9
|
s.description = 'Make it easy to use Kakaxi API by ruby'
|
data/lib/kakaxi/client.rb
CHANGED
@@ -6,7 +6,7 @@ require 'net/https'
|
|
6
6
|
module Kakaxi
|
7
7
|
class Client
|
8
8
|
COMMON_HEADER = { 'Content-Type' => 'application/json' }
|
9
|
-
BASE_URL = '
|
9
|
+
BASE_URL = 'https://kakaxi-data.me/api/v1/'
|
10
10
|
attr_reader :current_device, :temps, :temp_data, :token,
|
11
11
|
:farm, :devices, :humidities, :timelapses, :solar_radiations,
|
12
12
|
:rainfalls, :interval_photos, :interval_photo_data
|
@@ -35,8 +35,8 @@ module Kakaxi
|
|
35
35
|
@current_device = @devices[0]
|
36
36
|
end
|
37
37
|
|
38
|
-
def load_temps(days: 5, unit: 'celsius'
|
39
|
-
uri = URI.parse(BASE_URL + "kakaxi_devices/#{@current_device.id}/indicators/temperature?
|
38
|
+
def load_temps(days: 5, unit: 'celsius')
|
39
|
+
uri = URI.parse(BASE_URL + "kakaxi_devices/#{@current_device.id}/indicators/temperature?days=#{days}&unit=#{unit}")
|
40
40
|
temps = get(uri)['data']
|
41
41
|
Struct.new('TempMetaData', :size, :unit, :device_id)
|
42
42
|
@temps = temps.map do |temp|
|
@@ -45,8 +45,8 @@ module Kakaxi
|
|
45
45
|
@temp_data = Struct::TempMetaData.new(@temps.length, unit, @current_device.id)
|
46
46
|
end
|
47
47
|
|
48
|
-
def load_humidities(days: 5
|
49
|
-
uri = URI.parse(BASE_URL + "kakaxi_devices/#{@current_device.id}/indicators/humidity?
|
48
|
+
def load_humidities(days: 5)
|
49
|
+
uri = URI.parse(BASE_URL + "kakaxi_devices/#{@current_device.id}/indicators/humidity?days=#{days}")
|
50
50
|
humidities = get(uri)['data']
|
51
51
|
Struct.new('HumidityMetaData', :size, :device_id)
|
52
52
|
@humidities = humidities.map do |humidity|
|
@@ -60,8 +60,8 @@ module Kakaxi
|
|
60
60
|
@humidity_data = Struct::HumidityMetaData.new(@humidities.length, @current_device.id)
|
61
61
|
end
|
62
62
|
|
63
|
-
def load_solar_radiations(
|
64
|
-
uri = URI.parse(BASE_URL + "kakaxi_devices/#{@current_device.id}/indicators/solar_radiation?
|
63
|
+
def load_solar_radiations(days: 5)
|
64
|
+
uri = URI.parse(BASE_URL + "kakaxi_devices/#{@current_device.id}/indicators/solar_radiation?days=#{days}&unit=watt")
|
65
65
|
solar_radiations = get(uri)['data']
|
66
66
|
Struct.new('SolarRadiationMetaData', :size, :unit, :device_id)
|
67
67
|
@solar_radiations = solar_radiations.map do |solar_radiation|
|
@@ -74,8 +74,8 @@ module Kakaxi
|
|
74
74
|
@solar_radiation_data = Struct::SolarRadiationMetaData.new(@solar_radiations.length, 'watt', @current_device.id)
|
75
75
|
end
|
76
76
|
|
77
|
-
def load_rainfalls(days: 5
|
78
|
-
uri = URI.parse(BASE_URL + "kakaxi_devices/#{@current_device.id}/indicators/rainfall?
|
77
|
+
def load_rainfalls(days: 5)
|
78
|
+
uri = URI.parse(BASE_URL + "kakaxi_devices/#{@current_device.id}/indicators/rainfall?days=#{days}&unit=inch")
|
79
79
|
rainfalls = get(uri)['data']
|
80
80
|
Struct.new('RainfallMetaData', :size, :unit, :device_id)
|
81
81
|
@rainfalls = rainfalls.map do |rainfall|
|
@@ -84,8 +84,8 @@ module Kakaxi
|
|
84
84
|
@rainfall_data = Struct::RainfallMetaData.new(@rainfalls.length, 'inch', @current_device.id)
|
85
85
|
end
|
86
86
|
|
87
|
-
def load_timelapses(days: 5
|
88
|
-
uri = URI.parse(BASE_URL + "kakaxi_devices/#{@current_device.id}/indicators/timelapse?
|
87
|
+
def load_timelapses(days: 5)
|
88
|
+
uri = URI.parse(BASE_URL + "kakaxi_devices/#{@current_device.id}/indicators/timelapse?days=#{days}")
|
89
89
|
timelapses = get(uri)['data']
|
90
90
|
Struct.new('TimelapseMetaData', :size, :device_id)
|
91
91
|
@timelapses = timelapses.map do |timelapse|
|
@@ -157,12 +157,12 @@ module Kakaxi
|
|
157
157
|
|
158
158
|
def https(uri)
|
159
159
|
https = Net::HTTP.new(uri.host, uri.port)
|
160
|
-
|
160
|
+
https.use_ssl = true
|
161
161
|
https
|
162
162
|
end
|
163
163
|
|
164
164
|
def indicator_uri(device_id, indicator, days, unit)
|
165
|
-
URI.parse(BASE_URL + "kakaxi_devices/#{device_id}/indicators/#{indicator}?
|
165
|
+
URI.parse(BASE_URL + "kakaxi_devices/#{device_id}/indicators/#{indicator}?days=#{days}")
|
166
166
|
end
|
167
167
|
end
|
168
168
|
end
|