lockitron 1.0.2 → 1.1

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
  SHA1:
3
- metadata.gz: 5bd9f00009507b314b73d155ff2c2844b83afc87
4
- data.tar.gz: a2ac73f3d050e376010feaf586a617c87d917551
3
+ metadata.gz: b4c7a6e2c137b6f821d26d8a16bb7b6eee4b6be2
4
+ data.tar.gz: 4331c29fc8680da98373b083deb8135b46e4c700
5
5
  SHA512:
6
- metadata.gz: cd80bdb9d6959c6759a835f21d55a95a0f6f154f9a23f65833314ede328c8fc31411c656ae8484a31ea95881ece599877fcce4bb703f083090c8a399591ac0c4
7
- data.tar.gz: 21631fbe36ea6a493dfaf140a5717dc64c413d09fad4d7926f049677cf4907de4f08986e5bc0b09ee344afca09fadd416b8fc359e17af9c7502ab98d0e6bec10
6
+ metadata.gz: 455f7f83a66479a2568aa266271bfc651183d0099656e9dd54a86a311170c4038881b8ad89f0ddbad6830c47fefc4179f871a82811324191a1de006eb91a61c5
7
+ data.tar.gz: c85214afe9b8d745da08155179ab7360532e22a442cd169c1acce42f72cf36e412a2f1ed9bfb5281453a9e5e7e8959475fd41aa35a63c19ec79ba549e63d3d5b
data/README.md CHANGED
@@ -23,7 +23,7 @@ If you don't have an OAuth2 token already for the user of your app
23
23
 
24
24
  To use, you will want a User object
25
25
 
26
- `user = Lockitron::User('user oauth token')`
26
+ `user = Lockitron::User.new('user oauth token')`
27
27
 
28
28
  Get all the user's locks
29
29
 
data/Rakefile CHANGED
@@ -1 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ desc "Poke around in a console"
4
+ task :pry do
5
+ require 'pry'
6
+ require 'lockitron'
7
+ user = Lockitron::User.new(ENV['LOCKITRON_TOKEN'])
8
+ locks = user.locks
9
+ binding.pry
10
+ end
@@ -2,6 +2,7 @@ module Lockitron
2
2
  class Lock
3
3
  attr_reader :name
4
4
  attr_reader :uuid
5
+ attr_reader :latitude, :longitude, :keys, :status
5
6
 
6
7
  # Initializes a lock from a Lockitron JSON representation
7
8
  # @param [Hash] JSON
@@ -14,22 +15,25 @@ module Lockitron
14
15
 
15
16
  # A lock
16
17
  # @param [Hash] options
17
- # @options params [String] UUID (Required)
18
- # @options params [String] Name
18
+ # @option params [String] UUID (Required)
19
+ # @option params [String] Name
20
+ # @option params [Lockitron::User] User
19
21
  def initialize(params={})
20
22
  @uuid = params[:uuid]
21
23
  @name = params[:name]
24
+ @user = params[:user]
25
+ refresh if @user #if we have credentials, go ahead and sync with the API
22
26
  end
23
27
 
24
28
  # Takes a block of actions to perform as user
25
29
  # @param user [Lockitron::User]
26
30
  def as user
27
- @user = user
31
+ insert_key user
28
32
  yield self
29
- @user = nil
33
+ remove_key
30
34
  end
31
35
 
32
- # Sets up the user context
36
+ # Sets up the user context
33
37
  # @param user [Lockitron::User]
34
38
  def insert_key user
35
39
  @user = user
@@ -47,11 +51,22 @@ module Lockitron
47
51
  require_user
48
52
  begin
49
53
  @user.post "locks/#{@uuid}/lock"
54
+ @status = "lock"
50
55
  rescue ApiError
51
56
  false
52
57
  end
53
58
  end
54
59
 
60
+ # @return [boolean] door is locked
61
+ def locked?
62
+ return @status == "lock"
63
+ end
64
+
65
+ # @return [boolean] door is unlocked
66
+ def unlocked?
67
+ return @status == "unlock"
68
+ end
69
+
55
70
  # Unlocks this lock
56
71
  # @note Must be performed in user context
57
72
  # @return [Hash] API response
@@ -59,21 +74,34 @@ module Lockitron
59
74
  require_user
60
75
  begin
61
76
  @user.post "locks/#{@uuid}/unlock"
77
+ @status = "unlock"
62
78
  rescue ApiError
63
79
  false
64
80
  end
65
81
  end
66
82
 
83
+ # Syncs the lock's status
84
+ # @note Must be performed with user context
85
+ def refresh
86
+ require_user
87
+ lock = @user.get "locks/#{@uuid}"
88
+ @name = lock['lock']['name']
89
+ @status = lock['lock']['status']
90
+ @latitude = lock['lock']['latitude']
91
+ @longitude = lock['lock']['longitude']
92
+ @keys = lock['lock']['keys']
93
+ end
94
+
67
95
  # Invites a user to this lock.
68
96
  # @note Must be performed in user context
69
97
  #
70
98
  # @param [Hash] Options
71
- # @options params [String] :phone
72
- # @options params [String] :email
73
- # @options params [String] :role Defaults to guest
74
- # @options params [String] :fullname
75
- # @options params [Time] :start Optional key start time
76
- # @options params [Time] :expiration Optional key stop time
99
+ # @option params [String] :phone
100
+ # @option params [String] :email
101
+ # @option params [String] :role Defaults to guest
102
+ # @option params [String] :fullname
103
+ # @option params [Time] :start Optional key start time
104
+ # @option params [Time] :expiration Optional key stop time
77
105
  # @return [Hash] API response
78
106
  def invite(params={})
79
107
  require_user
@@ -16,6 +16,7 @@ module Lockitron
16
16
  resp = Faraday.get "#{API_ENDPOINT}/#{action}", {access_token: @token}
17
17
  process resp
18
18
  end
19
+
19
20
  def post action, params = {}
20
21
  params.merge!({access_token: @token})
21
22
  resp = Faraday.post "#{API_ENDPOINT}/#{action}", params
@@ -26,7 +27,7 @@ module Lockitron
26
27
  def process resp
27
28
  raise AuthorizationError if resp.status == 403
28
29
  raise ApiError, "Bad API Request: #{resp.status}" unless resp.status == 200
29
- data = JSON.parse resp.body
30
+ JSON.parse resp.body
30
31
  end
31
32
  end
32
33
  end
@@ -1,3 +1,3 @@
1
1
  module Lockitron
2
- VERSION = "1.0.2"
2
+ VERSION = "1.1"
3
3
  end
data/lockitron.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.version = Lockitron::VERSION
9
9
 
10
10
  s.authors = ["Kurt Nelson"]
11
- s.date = "2013-06-22"
11
+ s.date = "2013-12-29"
12
12
  s.description = "Communicate with a Lockitron"
13
13
  s.email = "kurtisnelson@gmail.com"
14
14
  s.extra_rdoc_files = [
@@ -25,11 +25,11 @@ Gem::Specification.new do |s|
25
25
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
26
26
  s.require_paths = ["lib"]
27
27
 
28
- s.add_dependency 'faraday', ">= 0.8.4"
28
+ s.add_dependency 'faraday'
29
29
  s.add_dependency 'oauth2'
30
- s.add_development_dependency 'rspec', ">= 2.8.0"
31
- s.add_development_dependency 'rdoc', ">= 3.12"
32
- s.add_development_dependency 'bundler', ">= 1.0.0"
30
+ s.add_development_dependency 'rspec'
31
+ s.add_development_dependency 'rdoc'
32
+ s.add_development_dependency 'bundler'
33
33
  s.add_development_dependency 'dotenv'
34
34
  s.add_development_dependency 'coveralls'
35
35
  s.add_development_dependency 'pry'
@@ -5,10 +5,10 @@ http_interactions:
5
5
  uri: https://api.lockitron.com/v1/locks/a397ef51-7b33-46dd-9a96-53eb1a7ea07f/add
6
6
  body:
7
7
  encoding: US-ASCII
8
- string: email=someone%40example.com&role=guest&start=1372028005&access_token=<OAUTH_TOKEN>
8
+ string: email=someone%40example.com&role=guest&start=1388345498&access_token=<OAUTH_TOKEN>
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.8.7
11
+ - Faraday v0.8.8
12
12
  Content-Type:
13
13
  - application/x-www-form-urlencoded
14
14
  Accept-Encoding:
@@ -20,44 +20,49 @@ http_interactions:
20
20
  code: 200
21
21
  message: OK
22
22
  headers:
23
- Date:
24
- - Sun, 23 Jun 2013 22:52:18 GMT
25
- Server:
26
- - Apache
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ Transfer-Encoding:
26
+ - chunked
27
+ Connection:
28
+ - keep-alive
29
+ Status:
30
+ - 200 OK
27
31
  X-Ua-Compatible:
28
32
  - IE=Edge,chrome=1
29
- Etag:
30
- - '"1b8915afe54cbed95ed2e53529d49aee"'
31
33
  Cache-Control:
32
34
  - max-age=0, private, must-revalidate
35
+ Set-Cookie:
36
+ - sessitron=BAh7BkkiD3Nlc3Npb25faWQGOgZFVEkiJTc3YzEyNGNhN2M4ZmEzYjg5MGY2M2RlOWJkMzVmYmMyBjsAVA%3D%3D--d76f6ebfa8c397267801cd9e083ac7d6166eeec0;
37
+ domain=.lockitron.com; path=/; secure; HttpOnly
33
38
  X-Request-Id:
34
- - 18e6903a65af48755c9e3711e1ee0e26
39
+ - 0c8d8a0477f3bf5b5faf35250d7a7e31
35
40
  X-Runtime:
36
- - '1.318250'
41
+ - '0.495693'
42
+ Date:
43
+ - Sun, 29 Dec 2013 19:30:41 GMT
37
44
  X-Rack-Cache:
38
45
  - invalidate, pass
39
- Status:
40
- - '200'
46
+ X-Powered-By:
47
+ - Phusion Passenger 4.0.25
48
+ Server:
49
+ - nginx + Phusion Passenger 4.0.25
41
50
  Strict-Transport-Security:
42
51
  - max-age=15768000
43
- Content-Length:
44
- - '383'
45
- Content-Type:
46
- - application/json; charset=utf-8
47
52
  body:
48
53
  encoding: UTF-8
49
54
  string: '{"id":"7f02c05a-b94d-4c5a-814e-3bb5a07603b9","start":null,"expire":null,"lock_id":"a397ef51-7b33-46dd-9a96-53eb1a7ea07f","role":"guest","valid":true,"visible":true,"user":{"id":"41d0322d-b03d-4eef-935b-904e05831496","email":"someone@example.com","phone":null,"human_phone":null,"first_name":null,"last_name":null,"full_name":null,"best_name":"someone@example.com","activated":false}}'
50
55
  http_version:
51
- recorded_at: Sun, 23 Jun 2013 22:53:27 GMT
56
+ recorded_at: Sun, 29 Dec 2013 19:31:39 GMT
52
57
  - request:
53
58
  method: post
54
59
  uri: https://api.lockitron.com/v1/locks/a397ef51-7b33-46dd-9a96-53eb1a7ea07f/add
55
60
  body:
56
61
  encoding: US-ASCII
57
- string: email=someone2%40example.com&start=1372031207&role=guest&access_token=<OAUTH_TOKEN>
62
+ string: email=someone2%40example.com&start=1388348699&role=guest&access_token=<OAUTH_TOKEN>
58
63
  headers:
59
64
  User-Agent:
60
- - Faraday v0.8.7
65
+ - Faraday v0.8.8
61
66
  Content-Type:
62
67
  - application/x-www-form-urlencoded
63
68
  Accept-Encoding:
@@ -69,33 +74,38 @@ http_interactions:
69
74
  code: 200
70
75
  message: OK
71
76
  headers:
72
- Date:
73
- - Sun, 23 Jun 2013 22:52:19 GMT
74
- Server:
75
- - Apache
77
+ Content-Type:
78
+ - application/json; charset=utf-8
79
+ Transfer-Encoding:
80
+ - chunked
81
+ Connection:
82
+ - keep-alive
83
+ Status:
84
+ - 200 OK
76
85
  X-Ua-Compatible:
77
86
  - IE=Edge,chrome=1
78
- Etag:
79
- - '"95b36bd88e1fb7dcb089e1535bee7815"'
80
87
  Cache-Control:
81
88
  - max-age=0, private, must-revalidate
89
+ Set-Cookie:
90
+ - sessitron=BAh7BkkiD3Nlc3Npb25faWQGOgZFVEkiJTI4NDJjYTlkNjMwMTFhNjgyYTIyYzg1MDQ1NmM1MjgxBjsAVA%3D%3D--8b33fe3268f893cebad820c2cc9c0896058013d0;
91
+ domain=.lockitron.com; path=/; secure; HttpOnly
82
92
  X-Request-Id:
83
- - 4f18fb69a1be7b921bc49b97e5756bfb
93
+ - e386e983a043542c32869becdf20b685
84
94
  X-Runtime:
85
- - '1.410540'
95
+ - '0.332159'
96
+ Date:
97
+ - Sun, 29 Dec 2013 19:30:16 GMT
86
98
  X-Rack-Cache:
87
99
  - invalidate, pass
88
- Status:
89
- - '200'
100
+ X-Powered-By:
101
+ - Phusion Passenger 4.0.25
102
+ Server:
103
+ - nginx + Phusion Passenger 4.0.25
90
104
  Strict-Transport-Security:
91
105
  - max-age=15768000
92
- Content-Length:
93
- - '395'
94
- Content-Type:
95
- - application/json; charset=utf-8
96
106
  body:
97
107
  encoding: UTF-8
98
- string: '{"id":"402d031d-21be-4442-9bbb-2ce07ccf84b0","start":-18864896400.0,"expire":null,"lock_id":"a397ef51-7b33-46dd-9a96-53eb1a7ea07f","role":"guest","valid":true,"visible":true,"user":{"id":"40d877eb-03f4-4d66-b631-80f3d54fd832","email":"someone2@example.com","phone":null,"human_phone":null,"first_name":null,"last_name":null,"full_name":null,"best_name":"someone2@example.com","activated":false}}'
108
+ string: '{"id":"402d031d-21be-4442-9bbb-2ce07ccf84b0","start":null,"expire":null,"lock_id":"a397ef51-7b33-46dd-9a96-53eb1a7ea07f","role":"guest","valid":true,"visible":true,"user":{"id":"40d877eb-03f4-4d66-b631-80f3d54fd832","email":"someone2@example.com","phone":null,"human_phone":null,"first_name":null,"last_name":null,"full_name":null,"best_name":"someone2@example.com","activated":false}}'
99
109
  http_version:
100
- recorded_at: Sun, 23 Jun 2013 22:53:29 GMT
101
- recorded_with: VCR 2.5.0
110
+ recorded_at: Sun, 29 Dec 2013 19:31:40 GMT
111
+ recorded_with: VCR 2.8.0
@@ -8,7 +8,7 @@ http_interactions:
8
8
  string: access_token=<OAUTH_TOKEN>
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.8.7
11
+ - Faraday v0.8.8
12
12
  Content-Type:
13
13
  - application/x-www-form-urlencoded
14
14
  Accept-Encoding:
@@ -20,36 +20,41 @@ http_interactions:
20
20
  code: 200
21
21
  message: OK
22
22
  headers:
23
- Date:
24
- - Sun, 23 Jun 2013 22:06:12 GMT
25
- Server:
26
- - Apache
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ Transfer-Encoding:
26
+ - chunked
27
+ Connection:
28
+ - keep-alive
29
+ Status:
30
+ - 200 OK
27
31
  X-Ua-Compatible:
28
32
  - IE=Edge,chrome=1
29
- Etag:
30
- - '"4835698658def1e57a3c33f917c6aa95"'
31
33
  Cache-Control:
32
34
  - max-age=0, private, must-revalidate
35
+ Set-Cookie:
36
+ - sessitron=BAh7BkkiD3Nlc3Npb25faWQGOgZFVEkiJTVhYzdmMzU4NTQ1ZTg2YTY1NTk5MGM3OTM1ZTFhMzQ5BjsAVA%3D%3D--abb92905ec4b80c26418d1fef76477fc2c567fd6;
37
+ domain=.lockitron.com; path=/; secure; HttpOnly
33
38
  X-Request-Id:
34
- - 8eeae9a228ebdcc428e46a9e111b3052
39
+ - b3bc2308b1a2805b64db186dcc14dd7c
35
40
  X-Runtime:
36
- - '0.321305'
41
+ - '0.066245'
42
+ Date:
43
+ - Sun, 29 Dec 2013 19:30:14 GMT
37
44
  X-Rack-Cache:
38
45
  - invalidate, pass
39
- Status:
40
- - '200'
46
+ X-Powered-By:
47
+ - Phusion Passenger 4.0.25
48
+ Server:
49
+ - nginx + Phusion Passenger 4.0.25
41
50
  Strict-Transport-Security:
42
51
  - max-age=15768000
43
- Content-Length:
44
- - '545'
45
- Content-Type:
46
- - application/json; charset=utf-8
47
52
  body:
48
53
  encoding: UTF-8
49
- string: '{"activity":{"id":"dcf06438-e36f-4765-834c-d35d882ffd11","lock_name":"Gem
50
- Test","lock_id":"a397ef51-7b33-46dd-9a96-53eb1a7ea07f","key_id":"cee75f80-c36d-41fc-9bb9-f250fafe2cbc","outcome":false,"human_outcome":"notice","type":4,"human_type":"lock-updated-locked","performed_at":1372025173.13896,"user":{"id":"6c121f58-0cc9-11e2-984d-4040401f6100","email":"kurtisnelson@gmail.com","phone":"+14075120689","human_phone":"(407)
54
+ string: '{"activity":{"id":"7e56603d-5759-477b-a251-294891cd7c17","lock_name":"Gem
55
+ Test","lock_id":"a397ef51-7b33-46dd-9a96-53eb1a7ea07f","key_id":"cee75f80-c36d-41fc-9bb9-f250fafe2cbc","outcome":false,"human_outcome":"notice","type":4,"human_type":"lock-updated-locked","performed_at":1388345414.55979,"user":{"id":"6c121f58-0cc9-11e2-984d-4040401f6100","email":"kurtisnelson@gmail.com","phone":"+14075120689","human_phone":"(407)
51
56
  512-0689","first_name":"Kurt","last_name":"Nelson","full_name":"Kurt Nelson","best_name":"Kurt
52
57
  Nelson","activated":true}}}'
53
58
  http_version:
54
- recorded_at: Sun, 23 Jun 2013 22:07:21 GMT
55
- recorded_with: VCR 2.5.0
59
+ recorded_at: Sun, 29 Dec 2013 19:31:38 GMT
60
+ recorded_with: VCR 2.8.0
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.lockitron.com/v1/locks/a397ef51-7b33-46dd-9a96-53eb1a7ea07f?access_token=<OAUTH_TOKEN>
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.8.8
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - '*/*'
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Content-Type:
22
+ - application/json; charset=utf-8
23
+ Transfer-Encoding:
24
+ - chunked
25
+ Connection:
26
+ - keep-alive
27
+ Status:
28
+ - 200 OK
29
+ X-Ua-Compatible:
30
+ - IE=Edge,chrome=1
31
+ Cache-Control:
32
+ - max-age=0, private, must-revalidate
33
+ X-Request-Id:
34
+ - bb7042dca734164b49969cad07cc49c9
35
+ X-Runtime:
36
+ - '0.038802'
37
+ Date:
38
+ - Sun, 29 Dec 2013 19:30:09 GMT
39
+ X-Rack-Cache:
40
+ - miss
41
+ X-Powered-By:
42
+ - Phusion Passenger 4.0.25
43
+ Server:
44
+ - nginx + Phusion Passenger 4.0.25
45
+ Strict-Transport-Security:
46
+ - max-age=15768000
47
+ body:
48
+ encoding: UTF-8
49
+ string: '{"lock":{"id":"a397ef51-7b33-46dd-9a96-53eb1a7ea07f","status":"unlock","name":"Gem
50
+ Test","latitude":null,"longitude":null,"keys":[{"id":"402d031d-21be-4442-9bbb-2ce07ccf84b0","start":-18864896400.0,"expire":null,"lock_id":"a397ef51-7b33-46dd-9a96-53eb1a7ea07f","role":"guest","valid":true,"visible":true,"user":{"id":"40d877eb-03f4-4d66-b631-80f3d54fd832","email":"someone2@example.com","phone":null,"human_phone":null,"first_name":null,"last_name":null,"full_name":null,"best_name":"someone2@example.com","activated":false}},{"id":"7f02c05a-b94d-4c5a-814e-3bb5a07603b9","start":null,"expire":null,"lock_id":"a397ef51-7b33-46dd-9a96-53eb1a7ea07f","role":"guest","valid":true,"visible":true,"user":{"id":"41d0322d-b03d-4eef-935b-904e05831496","email":"someone@example.com","phone":null,"human_phone":null,"first_name":null,"last_name":null,"full_name":null,"best_name":"someone@example.com","activated":false}},{"id":"cee75f80-c36d-41fc-9bb9-f250fafe2cbc","start":null,"expire":null,"lock_id":"a397ef51-7b33-46dd-9a96-53eb1a7ea07f","role":"owner","valid":true,"visible":true,"user":{"id":"6c121f58-0cc9-11e2-984d-4040401f6100","email":"kurtisnelson@gmail.com","phone":"+14075120689","human_phone":"(407)
51
+ 512-0689","first_name":"Kurt","last_name":"Nelson","full_name":"Kurt Nelson","best_name":"Kurt
52
+ Nelson","activated":true}}]}}'
53
+ http_version:
54
+ recorded_at: Sun, 29 Dec 2013 19:31:34 GMT
55
+ recorded_with: VCR 2.8.0
@@ -8,7 +8,7 @@ http_interactions:
8
8
  string: access_token=<OAUTH_TOKEN>
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.8.7
11
+ - Faraday v0.8.8
12
12
  Content-Type:
13
13
  - application/x-www-form-urlencoded
14
14
  Accept-Encoding:
@@ -20,36 +20,41 @@ http_interactions:
20
20
  code: 200
21
21
  message: OK
22
22
  headers:
23
- Date:
24
- - Sun, 23 Jun 2013 22:06:12 GMT
25
- Server:
26
- - Apache
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ Transfer-Encoding:
26
+ - chunked
27
+ Connection:
28
+ - keep-alive
29
+ Status:
30
+ - 200 OK
27
31
  X-Ua-Compatible:
28
32
  - IE=Edge,chrome=1
29
- Etag:
30
- - '"5b658e78866d68be74b91664f528aa32"'
31
33
  Cache-Control:
32
34
  - max-age=0, private, must-revalidate
35
+ Set-Cookie:
36
+ - sessitron=BAh7BkkiD3Nlc3Npb25faWQGOgZFVEkiJTQwZWQzNTA5MzRkZTE3MGM3ZTRjZWEwNDY2ZDQ0ZWZjBjsAVA%3D%3D--d7d271630340afa4a4a79521599036b3f07afcda;
37
+ domain=.lockitron.com; path=/; secure; HttpOnly
33
38
  X-Request-Id:
34
- - 2a8a7beab9950f53c5102d1ee79e151c
39
+ - 625b73980bc68c8315196b1264f9daff
35
40
  X-Runtime:
36
- - '0.349355'
41
+ - '0.062143'
42
+ Date:
43
+ - Sun, 29 Dec 2013 19:30:35 GMT
37
44
  X-Rack-Cache:
38
45
  - invalidate, pass
39
- Status:
40
- - '200'
46
+ X-Powered-By:
47
+ - Phusion Passenger 4.0.25
48
+ Server:
49
+ - nginx + Phusion Passenger 4.0.25
41
50
  Strict-Transport-Security:
42
51
  - max-age=15768000
43
- Content-Length:
44
- - '547'
45
- Content-Type:
46
- - application/json; charset=utf-8
47
52
  body:
48
53
  encoding: UTF-8
49
- string: '{"activity":{"id":"75f3b8f5-b594-4326-ab6c-34ccddc5346d","lock_name":"Gem
50
- Test","lock_id":"a397ef51-7b33-46dd-9a96-53eb1a7ea07f","key_id":"cee75f80-c36d-41fc-9bb9-f250fafe2cbc","outcome":false,"human_outcome":"notice","type":4,"human_type":"lock-updated-unlocked","performed_at":1372025172.30165,"user":{"id":"6c121f58-0cc9-11e2-984d-4040401f6100","email":"kurtisnelson@gmail.com","phone":"+14075120689","human_phone":"(407)
54
+ string: '{"activity":{"id":"df3fa96e-9831-4a93-8401-7fb537c8a30a","lock_name":"Gem
55
+ Test","lock_id":"a397ef51-7b33-46dd-9a96-53eb1a7ea07f","key_id":"cee75f80-c36d-41fc-9bb9-f250fafe2cbc","outcome":false,"human_outcome":"notice","type":4,"human_type":"lock-updated-unlocked","performed_at":1388345435.58767,"user":{"id":"6c121f58-0cc9-11e2-984d-4040401f6100","email":"kurtisnelson@gmail.com","phone":"+14075120689","human_phone":"(407)
51
56
  512-0689","first_name":"Kurt","last_name":"Nelson","full_name":"Kurt Nelson","best_name":"Kurt
52
57
  Nelson","activated":true}}}'
53
58
  http_version:
54
- recorded_at: Sun, 23 Jun 2013 22:07:20 GMT
55
- recorded_with: VCR 2.5.0
59
+ recorded_at: Sun, 29 Dec 2013 19:31:33 GMT
60
+ recorded_with: VCR 2.8.0
@@ -8,7 +8,7 @@ http_interactions:
8
8
  string: ''
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.8.7
11
+ - Faraday v0.8.8
12
12
  Accept-Encoding:
13
13
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
14
  Accept:
@@ -18,39 +18,50 @@ http_interactions:
18
18
  code: 200
19
19
  message: OK
20
20
  headers:
21
- Date:
22
- - Sun, 23 Jun 2013 21:33:19 GMT
23
- Server:
24
- - Apache
21
+ Content-Type:
22
+ - application/json; charset=utf-8
23
+ Transfer-Encoding:
24
+ - chunked
25
+ Connection:
26
+ - keep-alive
27
+ Status:
28
+ - 200 OK
25
29
  X-Ua-Compatible:
26
30
  - IE=Edge,chrome=1
27
- Etag:
28
- - '"fc85b665bd3fef203cf530086be83441"'
29
31
  Cache-Control:
30
32
  - max-age=0, private, must-revalidate
31
33
  X-Request-Id:
32
- - 04720dd8e07b20712f97372a1a18ca15
34
+ - 6b6562e6f86146e91983fe3fab230a10
33
35
  X-Runtime:
34
- - '0.048871'
36
+ - '0.187618'
37
+ Date:
38
+ - Sun, 29 Dec 2013 19:30:16 GMT
35
39
  X-Rack-Cache:
36
40
  - miss
37
- Status:
38
- - '200'
41
+ X-Powered-By:
42
+ - Phusion Passenger 4.0.25
43
+ Server:
44
+ - nginx + Phusion Passenger 4.0.25
39
45
  Strict-Transport-Security:
40
46
  - max-age=15768000
41
- Content-Length:
42
- - '1091'
43
- Content-Type:
44
- - application/json; charset=utf-8
45
47
  body:
46
48
  encoding: UTF-8
47
- string: '[{"lock":{"id":"62191ffe-160e-4227-8e94-7537b83a9ba0","status":null,"name":"Gem
48
- Test 2","latitude":null,"longitude":null,"keys":[{"id":"b59e31f1-dd34-4044-9e3c-5bb150a0ab70","start":null,"expire":null,"lock_id":"62191ffe-160e-4227-8e94-7537b83a9ba0","role":"owner","valid":true,"visible":true,"user":{"id":"6c121f58-0cc9-11e2-984d-4040401f6100","email":"kurtisnelson@gmail.com","phone":"+14075120689","human_phone":"(407)
49
+ string: '[{"lock":{"id":"62191ffe-160e-4227-8e94-7537b83a9ba0","status":"lock","name":"Glass
50
+ Fun","latitude":null,"longitude":null,"keys":[{"id":"b59e31f1-dd34-4044-9e3c-5bb150a0ab70","start":null,"expire":null,"lock_id":"62191ffe-160e-4227-8e94-7537b83a9ba0","role":"owner","valid":true,"visible":true,"user":{"id":"6c121f58-0cc9-11e2-984d-4040401f6100","email":"kurtisnelson@gmail.com","phone":"+14075120689","human_phone":"(407)
51
+ 512-0689","first_name":"Kurt","last_name":"Nelson","full_name":"Kurt Nelson","best_name":"Kurt
52
+ Nelson","activated":true}}]}},{"lock":{"id":"a397ef51-7b33-46dd-9a96-53eb1a7ea07f","status":"lock","name":"Gem
53
+ Test","latitude":null,"longitude":null,"keys":[{"id":"402d031d-21be-4442-9bbb-2ce07ccf84b0","start":null,"expire":null,"lock_id":"a397ef51-7b33-46dd-9a96-53eb1a7ea07f","role":"guest","valid":true,"visible":true,"user":{"id":"40d877eb-03f4-4d66-b631-80f3d54fd832","email":"someone2@example.com","phone":null,"human_phone":null,"first_name":null,"last_name":null,"full_name":null,"best_name":"someone2@example.com","activated":false}},{"id":"7f02c05a-b94d-4c5a-814e-3bb5a07603b9","start":null,"expire":null,"lock_id":"a397ef51-7b33-46dd-9a96-53eb1a7ea07f","role":"guest","valid":true,"visible":true,"user":{"id":"41d0322d-b03d-4eef-935b-904e05831496","email":"someone@example.com","phone":null,"human_phone":null,"first_name":null,"last_name":null,"full_name":null,"best_name":"someone@example.com","activated":false}},{"id":"cee75f80-c36d-41fc-9bb9-f250fafe2cbc","start":null,"expire":null,"lock_id":"a397ef51-7b33-46dd-9a96-53eb1a7ea07f","role":"owner","valid":true,"visible":true,"user":{"id":"6c121f58-0cc9-11e2-984d-4040401f6100","email":"kurtisnelson@gmail.com","phone":"+14075120689","human_phone":"(407)
49
54
  512-0689","first_name":"Kurt","last_name":"Nelson","full_name":"Kurt Nelson","best_name":"Kurt
50
- Nelson","activated":true}}]}},{"lock":{"id":"a397ef51-7b33-46dd-9a96-53eb1a7ea07f","status":null,"name":"Gem
51
- Test","latitude":null,"longitude":null,"keys":[{"id":"cee75f80-c36d-41fc-9bb9-f250fafe2cbc","start":null,"expire":null,"lock_id":"a397ef51-7b33-46dd-9a96-53eb1a7ea07f","role":"owner","valid":true,"visible":true,"user":{"id":"6c121f58-0cc9-11e2-984d-4040401f6100","email":"kurtisnelson@gmail.com","phone":"+14075120689","human_phone":"(407)
55
+ Nelson","activated":true}}]}},{"lock":{"id":"0433dabf-dd78-4599-a9cb-5cb8258f5df0","status":"unlock","name":"611
56
+ @ Windsor","latitude":null,"longitude":null,"keys":[{"id":"b1d68c1f-8815-4ec0-9357-fdcb98425f4b","start":null,"expire":1388552160.0,"lock_id":"0433dabf-dd78-4599-a9cb-5cb8258f5df0","role":"guest","valid":true,"visible":true,"user":{"id":"9a14a65b-28e2-4b64-9c84-26af2fc06c39","email":"michael.tomczak.cs@gmail.com","phone":"+18656608899","human_phone":"(865)
57
+ 660-8899","first_name":"Michael","last_name":"Tomczak","full_name":"Michael
58
+ Tomczak","best_name":"Michael Tomczak","activated":false}},{"id":"1c4980dc-88d9-4c48-b697-9d639e3b9a74","start":null,"expire":null,"lock_id":"0433dabf-dd78-4599-a9cb-5cb8258f5df0","role":"admin","valid":true,"visible":true,"user":{"id":"32c1f943-4622-46ef-ae8d-8689255d0702","email":"andrewskriss@gmail.com","phone":"6783159307","human_phone":"(678)
59
+ 315-9307","first_name":"Andrew","last_name":"Kriss","full_name":"Andrew Kriss","best_name":"Andrew
60
+ Kriss","activated":true}},{"id":"4fc2b433-57c3-479a-9707-7d35694212fc","start":null,"expire":null,"lock_id":"0433dabf-dd78-4599-a9cb-5cb8258f5df0","role":"admin","valid":true,"visible":true,"user":{"id":"3dc981f0-35f6-43f7-a48d-6d202448f53f","email":"aaron.hoodin@gmail.com","phone":"6785918040","human_phone":"(678)
61
+ 591-8040","first_name":"Aaron","last_name":"Hoodin","full_name":"Aaron Hoodin","best_name":"Aaron
62
+ Hoodin","activated":true}},{"id":"d937d400-183d-4de9-8fe9-1864cc3ca3cc","start":null,"expire":null,"lock_id":"0433dabf-dd78-4599-a9cb-5cb8258f5df0","role":"owner","valid":true,"visible":true,"user":{"id":"6c121f58-0cc9-11e2-984d-4040401f6100","email":"kurtisnelson@gmail.com","phone":"+14075120689","human_phone":"(407)
52
63
  512-0689","first_name":"Kurt","last_name":"Nelson","full_name":"Kurt Nelson","best_name":"Kurt
53
64
  Nelson","activated":true}}]}}]'
54
65
  http_version:
55
- recorded_at: Sun, 23 Jun 2013 21:34:40 GMT
56
- recorded_with: VCR 2.5.0
66
+ recorded_at: Sun, 29 Dec 2013 19:31:40 GMT
67
+ recorded_with: VCR 2.8.0
@@ -1,7 +1,7 @@
1
1
  require_relative '../spec_helper'
2
2
 
3
3
  describe Lockitron::Lock do
4
- let(:lock) { Lockitron::Lock.new(uuid: VIRTUAL_LOCK_UUID, name: VIRTUAL_LOCK_NAME)}
4
+ let(:lock) { Lockitron::Lock.new(uuid: VIRTUAL_LOCK_UUID)}
5
5
  context "valid user" do
6
6
  let(:valid_user) { Lockitron::User.new OAUTH_TOKEN }
7
7
  describe '#as' do
@@ -13,6 +13,22 @@ describe Lockitron::Lock do
13
13
  end
14
14
  end
15
15
 
16
+ it "refreshes" do
17
+ lock.as valid_user do |l|
18
+ VCR.use_cassette 'refresh' do
19
+ l.refresh
20
+ end
21
+ l.name.should eq VIRTUAL_LOCK_NAME
22
+ end
23
+ end
24
+
25
+ it "refreshes automatically if possible" do
26
+ VCR.use_cassette 'refresh' do
27
+ lock = Lockitron::Lock.new(uuid: VIRTUAL_LOCK_UUID, user: valid_user)
28
+ lock.name.should eq VIRTUAL_LOCK_NAME
29
+ end
30
+ end
31
+
16
32
  it "locks" do
17
33
  lock.as valid_user do |l|
18
34
  VCR.use_cassette 'lock' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lockitron
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: '1.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kurt Nelson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-22 00:00:00.000000000 Z
11
+ date: 2013-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.8.4
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.8.4
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: oauth2
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,42 +44,42 @@ dependencies:
44
44
  requirements:
45
45
  - - '>='
46
46
  - !ruby/object:Gem::Version
47
- version: 2.8.0
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
- version: 2.8.0
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rdoc
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '>='
60
60
  - !ruby/object:Gem::Version
61
- version: '3.12'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
- version: '3.12'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - '>='
74
74
  - !ruby/object:Gem::Version
75
- version: 1.0.0
75
+ version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '>='
81
81
  - !ruby/object:Gem::Version
82
- version: 1.0.0
82
+ version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: dotenv
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -176,6 +176,7 @@ files:
176
176
  - spec/fixtures/vcr_cassettes/invite.yml
177
177
  - spec/fixtures/vcr_cassettes/lock.yml
178
178
  - spec/fixtures/vcr_cassettes/oauth.yml
179
+ - spec/fixtures/vcr_cassettes/refresh.yml
179
180
  - spec/fixtures/vcr_cassettes/unlock.yml
180
181
  - spec/fixtures/vcr_cassettes/user.yml
181
182
  - spec/request/auth_spec.rb
@@ -202,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
203
  version: '0'
203
204
  requirements: []
204
205
  rubyforge_project:
205
- rubygems_version: 2.0.3
206
+ rubygems_version: 2.1.11
206
207
  signing_key:
207
208
  specification_version: 4
208
209
  summary: Access the Lockitron API
@@ -210,10 +211,10 @@ test_files:
210
211
  - spec/fixtures/vcr_cassettes/invite.yml
211
212
  - spec/fixtures/vcr_cassettes/lock.yml
212
213
  - spec/fixtures/vcr_cassettes/oauth.yml
214
+ - spec/fixtures/vcr_cassettes/refresh.yml
213
215
  - spec/fixtures/vcr_cassettes/unlock.yml
214
216
  - spec/fixtures/vcr_cassettes/user.yml
215
217
  - spec/request/auth_spec.rb
216
218
  - spec/request/lock_spec.rb
217
219
  - spec/request/user_spec.rb
218
220
  - spec/spec_helper.rb
219
- has_rdoc: