tomorrowio_rb 0.0.1 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb80619cdd8fb1802e47a1b94fc525c579b051a595ede4b7e33b5e297a4c6205
4
- data.tar.gz: 12395f9419111238bc4c1f796e43aa1482b7c54660aacc6db38d3dcbb127ecf5
3
+ metadata.gz: 755bdab30c734df598fc0b9de45f63fbc0dfbc6730dcbd560fa39c3cdfedd566
4
+ data.tar.gz: 04622c8355659e9ff0df021f5167c9a024325c5adf881856e2f746101edf566f
5
5
  SHA512:
6
- metadata.gz: 3e926fa92dd16811df3303042b8428de341430a20848e7f0cccb70f981e339151181c51655474113e059bec32e69c82688f6fc7283bb3ed269cfbf8853425bde
7
- data.tar.gz: e8a3e47cc2107af05eb088f07e8b78cf9ed928f8f81314cd5427a58ae98c5a98317aa64f4774656293f1cfe2dd10537cd9741a176d4faac0a891580210ca8b26
6
+ metadata.gz: 1e9f005bb58ccb7ee7f5d913d0f218b10305a347e32b6aca9403a4b8b531f246b751cf850c099b6237d6e3c308ecb9c28f0955a859d2e1987fd3bc610037fc38
7
+ data.tar.gz: 801927921423c19038d5c2d72451f71ce262ebb78cb5242d44d158b56061d05c4e0bfc54e9b5a2a8faad5e2165376d0e69ba24ef76c2081a03d753da517bcc83
@@ -0,0 +1,27 @@
1
+ module Tomorrowiorb
2
+ module Configuration
3
+ DEFAULT_API_ENDPOINT = 'https://api.tomorrow.io/v4'
4
+
5
+ attr_writer :api_endpoint
6
+ attr_writer :api_key
7
+
8
+ # Yield self to be able to configure Tomorrowiorb with block-style configuration.
9
+ #
10
+ # Example:
11
+ #
12
+ # Tomorrowiorb.configure do |configuration|
13
+ # configuration.api_key = 'this-is-your-api-key'
14
+ # end
15
+ def configure
16
+ yield self
17
+ end
18
+
19
+ def api_endpoint
20
+ @api_endpoint ||= DEFAULT_API_ENDPOINT
21
+ end
22
+
23
+ def api_key
24
+ @api_key
25
+ end
26
+ end
27
+ end
data/lib/tomorrowio_rb.rb CHANGED
@@ -1,4 +1,4 @@
1
- require_relative 'configuration.rb'
1
+ require 'configuration.rb'
2
2
  require 'faraday'
3
3
  require 'json'
4
4
 
@@ -6,7 +6,7 @@ module Tomorrowiorb
6
6
  extend Configuration
7
7
 
8
8
  class << self
9
- def forecast(location, timesteps=nil, units=nil)
9
+ def forecast(location, timesteps=["1d"], units="metric")
10
10
  connection = Faraday.new(
11
11
  url: "#{Tomorrowiorb.api_endpoint}/weather/forecast",
12
12
  params: {
@@ -15,9 +15,11 @@ module Tomorrowiorb
15
15
  },
16
16
  headers: {'Content-Type' => 'application/json'}
17
17
  )
18
- req.params['timesteps'] = timesteps if timesteps
19
- req.params['units'] = units if units
20
- response = connection.get('')
18
+ response = connection.get('') do |req|
19
+ req.options.params_encoder = Faraday::FlatParamsEncoder
20
+ req.params['timesteps'] = timesteps
21
+ req.params['units'] = units
22
+ end
21
23
 
22
24
  return TomorrowioResponse.new(response.status,response.headers, response.body)
23
25
  end
@@ -42,4 +44,4 @@ module Tomorrowiorb
42
44
  @body
43
45
  end
44
46
  end
45
- end
47
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tomorrowio_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cedric Wille
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-21 00:00:00.000000000 Z
11
+ date: 2023-11-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby wrapper for the Tomorrow.io weather API, currently only the forecast
14
14
  endpoint.
@@ -17,6 +17,7 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - lib/configuration.rb
20
21
  - lib/tomorrowio_rb.rb
21
22
  homepage: https://github.com/cwille97/tomorrowio_rb
22
23
  licenses: