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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa37c02a432d1e93c389daf8c240f029b1773fec
4
- data.tar.gz: 7a77a01614ca111df43be45d3b5427b3648c81f5
3
+ metadata.gz: 1ef8f125b89e9768fc655846a789cebeb6b528c1
4
+ data.tar.gz: 6c9886a66d6cf22dcc53de92767893d5a09f349b
5
5
  SHA512:
6
- metadata.gz: 34b50102fa3a223bb655491e82c45c3176fc14a29620e77241d17726acd104b9127ed17d54d0d554c982818d31c59421097aac249fbc14ca667fd9164a3c7a84
7
- data.tar.gz: e705504893e95198d349208b4428c3855a4753e6b28abceba4f3bdf487c3a0f30ea0903be41fd73daa19ace1b0abda4649249ec8aa3911f91760a1f02bcd4ebd
6
+ metadata.gz: 7742c5b0218e8e2c0fbaf93e4f7f2ff7bee1f397a9cff591b8f4fe1eac15ca396148033bfea200cdeddd175aa5d87ab388537377c28e2501c7f1338b4b353844
7
+ data.tar.gz: 9bbd62b782b4c7ea7af643079e5d3e7e0a9a147144880f6a4de072b76d41383fdbc7dbd4f3a36849bd15ed1b04124c8cde6b5f6ed92cd9a7059abf8b9f9f9649
@@ -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(method, path, data)
21
- digest = Digest::SHA1.hexdigest([
22
- method.upcase,
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' => digest
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
@@ -1,7 +1,7 @@
1
1
  module Lockme
2
2
  class Reservation < Lockme::Base
3
3
  def initialize(args = {})
4
- @data = OpenStruct.new(args)
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
@@ -1,3 +1,3 @@
1
1
  module Lockme
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
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.3.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-04 00:00:00.000000000 Z
11
+ date: 2018-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler