lockme 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lockme/request.rb +5 -11
- data/lib/lockme/reservation.rb +11 -3
- data/lib/lockme/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ef8f125b89e9768fc655846a789cebeb6b528c1
|
4
|
+
data.tar.gz: 6c9886a66d6cf22dcc53de92767893d5a09f349b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7742c5b0218e8e2c0fbaf93e4f7f2ff7bee1f397a9cff591b8f4fe1eac15ca396148033bfea200cdeddd175aa5d87ab388537377c28e2501c7f1338b4b353844
|
7
|
+
data.tar.gz: 9bbd62b782b4c7ea7af643079e5d3e7e0a9a147144880f6a4de072b76d41383fdbc7dbd4f3a36849bd15ed1b04124c8cde6b5f6ed92cd9a7059abf8b9f9f9649
|
data/lib/lockme/request.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Lockme
|
2
2
|
module SignedRequest
|
3
3
|
def self.perform(method, path, data = nil)
|
4
|
-
headers = signature(method, path, data)
|
4
|
+
headers = signature(method.upcase, path.gsub(/^\//, ''), data)
|
5
5
|
params = {
|
6
6
|
body: data,
|
7
7
|
headers: headers,
|
@@ -17,23 +17,17 @@ module Lockme
|
|
17
17
|
raise Lockme::Error.new('Invalid response from the server')
|
18
18
|
end
|
19
19
|
|
20
|
-
def self.signature(
|
21
|
-
|
22
|
-
|
23
|
-
path.gsub(/^\//, ''),
|
24
|
-
data,
|
20
|
+
def self.signature(*args)
|
21
|
+
sha1 = Digest::SHA1.hexdigest([
|
22
|
+
*args,
|
25
23
|
Lockme.api_secret
|
26
24
|
].compact.join(''))
|
27
25
|
|
28
26
|
{
|
29
27
|
'Partner-Key' => Lockme.api_key,
|
30
|
-
'Signature' =>
|
28
|
+
'Signature' => sha1
|
31
29
|
}
|
32
30
|
end
|
33
|
-
|
34
|
-
class << self
|
35
|
-
private :signature
|
36
|
-
end
|
37
31
|
end
|
38
32
|
|
39
33
|
module Request
|
data/lib/lockme/reservation.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Lockme
|
2
2
|
class Reservation < Lockme::Base
|
3
3
|
def initialize(args = {})
|
4
|
-
|
4
|
+
parse_lockme_json(args)
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.find(lockme_id)
|
@@ -31,13 +31,21 @@ module Lockme
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def create
|
34
|
-
Lockme::SignedRequest.perform("put", "/reservation", self.to_json)
|
34
|
+
@data.reservationid = Lockme::SignedRequest.perform("put", "/reservation", self.to_json)
|
35
|
+
return self
|
35
36
|
end
|
36
37
|
private :create
|
37
38
|
|
38
39
|
def update
|
39
|
-
Lockme::SignedRequest.perform("post", "/reservation/#{@data.reservationid}", self.to_json)
|
40
|
+
resp = Lockme::SignedRequest.perform("post", "/reservation/#{@data.reservationid}", self.to_json)
|
41
|
+
parse_lockme_json(resp)
|
42
|
+
return self
|
40
43
|
end
|
41
44
|
private :update
|
45
|
+
|
46
|
+
def parse_lockme_json(data)
|
47
|
+
@data = OpenStruct.new(data)
|
48
|
+
end
|
49
|
+
private :parse_lockme_json
|
42
50
|
end
|
43
51
|
end
|
data/lib/lockme/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lockme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Szyndel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|