sleepiq 0.1.1 → 0.2.0

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: d02cd8e4d6fec822afae9f946a42ee7a2bc9e7f25ad9705e512ca1a981b33ad6
4
- data.tar.gz: 9e71d60d9a527fd449ae32f876f79bb7f04e3cee1717efd019076b2fd2539216
3
+ metadata.gz: baa8c91485795d2ccd9ffbc45823cef841e33dc497fbf9a4be19b1cc1b7b6e24
4
+ data.tar.gz: 2d3e8af55460dd8b89fccf4cda928a51432196082b1841686984d11a0b590b18
5
5
  SHA512:
6
- metadata.gz: 1325bb5914a7cf4b0debae58bd96d6621a0205a96f1029fcaa7373c8a52d5735540fed0a950475e8b799651c6a24ed461225daa18b2c7c237e3ee8b2713e53f0
7
- data.tar.gz: abd644d6bc94123414b64bf71db7c055e6f38c59694795a3d3dfef11ab89b422d71f82f7c19c802d7e78b448dfb4984bc7ca5ad549de42e811750a901f9b9a72
6
+ metadata.gz: 6d33150cdf0de6ba676a7e572974b6440b6e81db85c3293779cfbd16dd05e6d16b9d108872c0f60499e364238050f090a790fb0d5d25b1bfb42628f51a5edb8a
7
+ data.tar.gz: 536d0c1b30855031ef354176ba39a63e91e8166262824e9bf473459709cb45c177e133a288e1eeb325a8cecc533a5e013b0de4dd1cf9b88a179d94ab47b31d37
data/.rubocop.yml CHANGED
@@ -6,6 +6,8 @@ Metrics/ClassLength:
6
6
  Max: 1500
7
7
  Metrics/BlockLength:
8
8
  Max: 50
9
+ Metrics/AbcSize:
10
+ Max: 18
9
11
  Layout/SpaceAroundEqualsInParameterDefault:
10
12
  EnforcedStyle: space
11
13
  Style/SymbolArray:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # SleepIQ Changelog
2
2
 
3
+ ## V0.2.0
4
+ * Removed dalli(memcached logic)
5
+ * Updated rubocop.yml
6
+
3
7
  ## v0.1.1
4
8
  * Adding foundation methods however these are untested
5
9
  * Adding method for getting and setting favorite sleep number
@@ -1,11 +1,9 @@
1
- require 'dalli'
2
1
  require 'faraday'
3
2
  require 'faraday_middleware'
4
3
 
5
4
  module SleepIQ
6
5
  class Client
7
6
  attr_accessor :key, :sessid, :awsalb, :bedid
8
- attr_reader :cache
9
7
 
10
8
  include SleepIQ::Family
11
9
  include SleepIQ::Bed
@@ -13,21 +11,13 @@ module SleepIQ
13
11
  include SleepIQ::Pump
14
12
  include SleepIQ::Sleeper
15
13
 
16
- def initialize(**opts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
17
- @cache = Dalli::Client.new('localhost:11211', namespace: 'sleep_iq')
14
+ def initialize(**opts)
18
15
  @username = opts[:username].nil? ? ENV['sleepiq_username'] : opts[:username]
19
16
  @password = opts[:password].nil? ? ENV['sleepiq_password'] : opts[:password]
20
- @login_cache_time = opts[:logic_cache_time].nil? ? 60 : opts[:login_cache_time]
21
-
22
- login if @cache.get('api_key').nil? || @cache.get('session_id') || @cache.get('awsalb')
23
-
24
- @sessid = @cache.get('session_id')
25
- @key = @cache.get('api_key')
26
- @awsalb = @cache.get('awsalb')
27
17
 
18
+ login
28
19
  @conn = Faraday.new(
29
20
  url: 'https://api.sleepiq.sleepnumber.com',
30
- ssl: { verify: false, ca_file: '/Users/miverso2/Downloads/optum_ca1_full_chain.pem' },
31
21
  headers: default_headers,
32
22
  params: { _k: @key },
33
23
  request: { timeout: 10, open_timeout: 3, write_timeout: 10 }
@@ -36,7 +26,7 @@ module SleepIQ
36
26
  conn.adapter :net_http
37
27
  end
38
28
 
39
- @bedid = default_bed
29
+ @bedid = family_status['beds'][0]['bedId']
40
30
  end
41
31
 
42
32
  def login(username = @username, password = @password) # rubocop:disable Metrics/AbcSize
@@ -60,10 +50,10 @@ module SleepIQ
60
50
  raise "status code was #{result.status}" unless result.status == 200
61
51
 
62
52
  result.headers['set-cookie'].split(' ').each do |k, _v|
63
- @cache.set('session_id', k.split('=')[1].delete_suffix(';'), @login_cache_time) if k.include? 'JSESSIONID'
64
- @cache.set('awsalb', k.split('=')[1].delete_suffix(';'), @login_cache_time) if k.include? 'AWSALB'
53
+ @sessid = k.split('=')[1].delete_suffix(';')
54
+ @awsalb = k.split('=')[1].delete_suffix(';')
65
55
  end
66
- @cache.set('api_key', result.body['key'], @login_cache_time)
56
+ @key = result.body['key']
67
57
  end
68
58
 
69
59
  def default_headers
@@ -75,10 +65,5 @@ module SleepIQ
75
65
  'Connection': 'keep-alive',
76
66
  'Cookie': "AWSALB=#{@awsalb}; JSESSIONID=#{@sessid}" }
77
67
  end
78
-
79
- def default_bed
80
- @cache.set('bedid', family_status['beds'][0]['bedId'], @login_cache_time) if @cache.get('bedid').nil?
81
- @cache.get('bedid')
82
- end
83
68
  end
84
69
  end
@@ -1,3 +1,3 @@
1
1
  module SleepIQ
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.2.0'.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.1.1
4
+ version: 0.2.0
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-04 00:00:00.000000000 Z
11
+ date: 2020-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler