sleepiq 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: baa8c91485795d2ccd9ffbc45823cef841e33dc497fbf9a4be19b1cc1b7b6e24
4
- data.tar.gz: 2d3e8af55460dd8b89fccf4cda928a51432196082b1841686984d11a0b590b18
3
+ metadata.gz: bb40d4f6d384d6598c5eb5ec58b75ccfb0a13fec9c97afe70a12aa5acdc3e39c
4
+ data.tar.gz: 90c08cbb707980e1945bb2e624e8fe824263b46079a5b2adb84c1f15f8c337a3
5
5
  SHA512:
6
- metadata.gz: 6d33150cdf0de6ba676a7e572974b6440b6e81db85c3293779cfbd16dd05e6d16b9d108872c0f60499e364238050f090a790fb0d5d25b1bfb42628f51a5edb8a
7
- data.tar.gz: 536d0c1b30855031ef354176ba39a63e91e8166262824e9bf473459709cb45c177e133a288e1eeb325a8cecc533a5e013b0de4dd1cf9b88a179d94ab47b31d37
6
+ metadata.gz: 6ae787bccb1cbfa093871ef2b4272786dd3bdc43eb810daf27cfb18cc18800b6a49b717dd51d4fd599695200bfa0eb9ecc127596af10320c47fa994b7d4c8aff
7
+ data.tar.gz: d7dfce0803af55ccc512aa069332622c7ad24a38450024e3bf547010cb020a5d858190032e140dd9153e4d033e3b87ef8cb6b857f99c57534a48f82593c76d5c
data/CHANGELOG.md CHANGED
@@ -1,4 +1,6 @@
1
1
  # SleepIQ Changelog
2
+ ## v0.2.2
3
+ Bug fixes
2
4
 
3
5
  ## V0.2.0
4
6
  * Removed dalli(memcached logic)
@@ -11,11 +11,16 @@ module SleepIQ
11
11
  include SleepIQ::Pump
12
12
  include SleepIQ::Sleeper
13
13
 
14
- def initialize(**opts)
14
+ def initialize(**opts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
15
15
  @username = opts[:username].nil? ? ENV['sleepiq_username'] : opts[:username]
16
16
  @password = opts[:password].nil? ? ENV['sleepiq_password'] : opts[:password]
17
+ @key = opts[:key]
18
+ @awsalb = opts[:awsalb]
19
+ @sessid = opts[:sessid]
20
+ @bedid = opts[:bedid]
21
+
22
+ login if @key.nil? || @awsalb.nil? || @sessid.nil?
17
23
 
18
- login
19
24
  @conn = Faraday.new(
20
25
  url: 'https://api.sleepiq.sleepnumber.com',
21
26
  headers: default_headers,
@@ -26,7 +31,7 @@ module SleepIQ
26
31
  conn.adapter :net_http
27
32
  end
28
33
 
29
- @bedid = family_status['beds'][0]['bedId']
34
+ @bedid = family_status['beds'][0]['bedId'] if @bedid.nil?
30
35
  end
31
36
 
32
37
  def login(username = @username, password = @password) # rubocop:disable Metrics/AbcSize
@@ -50,8 +55,8 @@ module SleepIQ
50
55
  raise "status code was #{result.status}" unless result.status == 200
51
56
 
52
57
  result.headers['set-cookie'].split(' ').each do |k, _v|
53
- @sessid = k.split('=')[1].delete_suffix(';')
54
- @awsalb = k.split('=')[1].delete_suffix(';')
58
+ @sessid = k.split('=')[1].delete_suffix(';') if k.include? 'JSESSIONID'
59
+ @awsalb = k.split('=')[1].delete_suffix(';') if k.include? 'AWSALB'
55
60
  end
56
61
  @key = result.body['key']
57
62
  end
@@ -1,3 +1,3 @@
1
1
  module SleepIQ
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.2.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sleepiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - esity
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-25 00:00:00.000000000 Z
11
+ date: 2020-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler