castle-rb 7.1.1 → 7.1.2

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
  SHA256:
3
- metadata.gz: 774cdc6663639d2a96b9a9a0010bc34bea827edd6b7a42d2f72bb87f94573026
4
- data.tar.gz: ab2d684474508d1e20fce26dabe1f7594cf255b8682e8b3b1d9b52289d5bab39
3
+ metadata.gz: e2d022daae00e63158ee2f9d886faa5dbf3f70b89c16775c14f9328b0096f446
4
+ data.tar.gz: 1820e1afb9bd65683f5dd1a183369ed231b616c8466ee5c2b3d3cdd59d704319
5
5
  SHA512:
6
- metadata.gz: 9810ca259c0e26cf3195c8ddc1ca1409256011a89584585dd806ddd6b98efac526de25371b33a7cd122a08f271b0d99c61fe68a8da53714483e85fdc065367db
7
- data.tar.gz: c89c84e1748f1c8bf06e480d5273bfa8c5003da08b01b74f40d588fc1b0567d3828ea4e0b277d3526fe9a179836e5d86606cd88723cd5e70ecb40b23b925e1f5
6
+ metadata.gz: '009de5db675b53f46bb90f0f2cfe57cb081598c5af02d3770125d79d27739b03e82e6170013b86d5e74321e26a9f053023f6914ae68c1a7770b3ee2496c0482b'
7
+ data.tar.gz: 2dee44618c8c3318ba1dacc2f4484187fc8e28d2413db81531c9e46451da61dfcbea6aa5916a6df2d0eceaf6e5f97bed4c81f08bb3f9e1607f4ac798c90561ea
@@ -27,9 +27,7 @@ module Castle
27
27
  url = "#{config.base_url.path}/#{command.path}"
28
28
  request_obj = Net::HTTP.const_get(command.method.to_s.capitalize).new(url, headers)
29
29
 
30
- unless command.method == :get
31
- request_obj.body = ::Castle::Utils::CleanInvalidChars.call(command.data).to_json
32
- end
30
+ request_obj.body = ::Castle::Utils::CleanInvalidChars.call(command.data || {}).to_json
33
31
 
34
32
  Castle::Logger.call("#{url}:", request_obj.body, config)
35
33
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Castle
4
- VERSION = '7.1.1'
4
+ VERSION = '7.1.2'
5
5
  end
@@ -73,5 +73,29 @@ describe Castle::Core::SendRequest do
73
73
  it { expect(build.to_hash).to have_key('sample-header') }
74
74
  it { expect(build.to_hash['sample-header']).to eql(['1']) }
75
75
  end
76
+
77
+ context 'when get' do
78
+ let(:time) { Time.now.utc.iso8601(3) }
79
+ let(:command) { Castle::Commands::GetDevice.build(device_token: '1') }
80
+ let(:expected_body) { {} }
81
+
82
+ before { allow(Castle::Utils::GetTimestamp).to receive(:call).and_return(time) }
83
+
84
+ it { expect(build.body).to be_eql(expected_body.to_json) }
85
+ it { expect(build.method).to eql('GET') }
86
+ it { expect(build.path).to eql("/v1/#{command.path}") }
87
+ end
88
+
89
+ context 'when put' do
90
+ let(:time) { Time.now.utc.iso8601(3) }
91
+ let(:command) { Castle::Commands::ApproveDevice.build(device_token: '1') }
92
+ let(:expected_body) { {} }
93
+
94
+ before { allow(Castle::Utils::GetTimestamp).to receive(:call).and_return(time) }
95
+
96
+ it { expect(build.body).to be_eql(expected_body.to_json) }
97
+ it { expect(build.method).to eql('PUT') }
98
+ it { expect(build.path).to eql("/v1/#{command.path}") }
99
+ end
76
100
  end
77
101
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: castle-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.1
4
+ version: 7.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johan Brissmyr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-15 00:00:00.000000000 Z
11
+ date: 2021-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appraisal
@@ -177,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  - !ruby/object:Gem::Version
178
178
  version: '0'
179
179
  requirements: []
180
- rubygems_version: 3.0.6
180
+ rubygems_version: 3.2.23
181
181
  signing_key:
182
182
  specification_version: 4
183
183
  summary: Castle