finapps 2.0.10 → 2.0.11
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 +4 -4
- data/lib/finapps/rest/base_client.rb +4 -0
- data/lib/finapps/rest/configuration.rb +4 -0
- data/lib/finapps/rest/connection.rb +1 -3
- data/lib/finapps/version.rb +1 -1
- data/spec/core_extensions/hash/compact_spec.rb +21 -0
- data/spec/core_extensions/object/is_integer_spec.rb +17 -0
- data/spec/rest/base_client_spec.rb +10 -0
- data/spec/rest/configuration_spec.rb +11 -0
- metadata +15 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9685b0a3f9fad48a9bd328149950e69d9ceece8
|
4
|
+
data.tar.gz: 499cd1b6b4e58d8cc0c80d3bbee9ea7b47b187e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 221ed36e938139757128972a2a1b249249bd9fc06aa2c1d75717af2d80a58a68db4dfb81377ba90e260c83f6b21cdfc72d37483a0a9df1739a2d689996caebf7
|
7
|
+
data.tar.gz: f6c5e89211c89c172c42f5aebb35e7fdd1b5350b894e49c72ba3b3b3d83771c14ea7c59ce2c153969f48dcc90817e1cdf788d92083b36205d1cd2a90888cd1c9
|
@@ -17,6 +17,10 @@ module FinApps
|
|
17
17
|
raise FinApps::InvalidArgumentsError.new "Invalid argument. {timeout: #{timeout}}" unless timeout.integer?
|
18
18
|
end
|
19
19
|
|
20
|
+
def valid_user_credentials?
|
21
|
+
FinApps::REST::Credentials.new(user_identifier, user_token).valid?
|
22
|
+
end
|
23
|
+
|
20
24
|
private
|
21
25
|
|
22
26
|
def valid_host?
|
@@ -18,9 +18,7 @@ module FinApps
|
|
18
18
|
conn.request :retry
|
19
19
|
conn.request :multipart
|
20
20
|
conn.request :url_encoded
|
21
|
-
|
22
|
-
conn.request :basic_auth, config.user_identifier, config.user_token
|
23
|
-
end
|
21
|
+
conn.request :basic_auth, config.user_identifier, config.user_token if config.valid_user_credentials?
|
24
22
|
|
25
23
|
conn.use FinApps::Middleware::RaiseError
|
26
24
|
conn.response :rashify
|
data/lib/finapps/version.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
RSpec.describe HashExtensions do
|
3
|
+
context 'when refining hash' do
|
4
|
+
using HashExtensions
|
5
|
+
|
6
|
+
subject { {a: true, b: false, c: nil} }
|
7
|
+
|
8
|
+
describe '#compact' do
|
9
|
+
it 'returns a hash with non nil values' do
|
10
|
+
expect(subject.compact).to eq(a: true, b: false)
|
11
|
+
expect(subject).to eq(a: true, b: false, c: nil)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
describe '#compact!' do
|
15
|
+
it 'replaces current hash with non nil values' do
|
16
|
+
expect(subject.compact!).to eq(a: true, b: false)
|
17
|
+
expect(subject).to eq(a: true, b: false)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
RSpec.describe ObjectExtensions do
|
3
|
+
context 'when refining Object' do
|
4
|
+
using ObjectExtensions
|
5
|
+
|
6
|
+
describe '#integer?' do
|
7
|
+
context 'for integers' do
|
8
|
+
subject { 1 + rand(10) }
|
9
|
+
it { expect(subject.integer?).to eq(true) }
|
10
|
+
end
|
11
|
+
context 'for non integers' do
|
12
|
+
subject { rand }
|
13
|
+
it { expect(subject.integer?).to eq(false) }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -16,6 +16,16 @@ RSpec.describe FinApps::REST::BaseClient do
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
describe '#user_credentials?' do
|
20
|
+
context 'when user credentials were not set' do
|
21
|
+
it { expect(subject.user_credentials?).to eq(false) }
|
22
|
+
end
|
23
|
+
context 'when user credentials were set' do
|
24
|
+
subject { FinApps::REST::BaseClient.new(valid_tenant_options.merge(user_identifier: 1, user_token: 2)) }
|
25
|
+
it { expect(subject.user_credentials?).to eq(true) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
19
29
|
describe '#connection' do
|
20
30
|
it 'created a Faraday connection object' do
|
21
31
|
expect(subject.connection).to be_a(Faraday::Connection)
|
@@ -25,4 +25,15 @@ RSpec.describe FinApps::REST::Configuration do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
describe '#valid_user_credentials??' do
|
30
|
+
context 'when user credentials were not set' do
|
31
|
+
subject { FinApps::REST::Configuration.new(host: nil) }
|
32
|
+
it { expect(subject.valid_user_credentials?).to eq(false) }
|
33
|
+
end
|
34
|
+
context 'when user credentials were set' do
|
35
|
+
subject { FinApps::REST::Configuration.new(user_identifier: 1, user_token: 2) }
|
36
|
+
it { expect(subject.valid_user_credentials?).to eq(true) }
|
37
|
+
end
|
38
|
+
end
|
28
39
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: finapps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erich Quintero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -267,6 +267,8 @@ files:
|
|
267
267
|
- lib/finapps/utils/loggeable.rb
|
268
268
|
- lib/finapps/version.rb
|
269
269
|
- lib/tasks/releaser.rake
|
270
|
+
- spec/core_extensions/hash/compact_spec.rb
|
271
|
+
- spec/core_extensions/object/is_integer_spec.rb
|
270
272
|
- spec/middleware/accept_json_spec.rb
|
271
273
|
- spec/middleware/tenant_authentication_spec.rb
|
272
274
|
- spec/middleware/user_agent_spec.rb
|
@@ -308,19 +310,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
308
310
|
version: '0'
|
309
311
|
requirements: []
|
310
312
|
rubyforge_project:
|
311
|
-
rubygems_version: 2.
|
313
|
+
rubygems_version: 2.6.6
|
312
314
|
signing_key:
|
313
315
|
specification_version: 4
|
314
316
|
summary: FinApps REST API ruby client.
|
315
317
|
test_files:
|
316
|
-
- spec/
|
317
|
-
- spec/
|
318
|
+
- spec/spec_helper.rb
|
319
|
+
- spec/support/fake_api.rb
|
318
320
|
- spec/middleware/user_agent_spec.rb
|
319
|
-
- spec/
|
320
|
-
- spec/
|
321
|
-
- spec/rest/configuration_spec.rb
|
321
|
+
- spec/middleware/tenant_authentication_spec.rb
|
322
|
+
- spec/middleware/accept_json_spec.rb
|
322
323
|
- spec/rest/credentials_spec.rb
|
323
|
-
- spec/rest/orders_spec.rb
|
324
324
|
- spec/rest/resources_spec.rb
|
325
|
-
- spec/
|
326
|
-
- spec/
|
325
|
+
- spec/rest/client_spec.rb
|
326
|
+
- spec/rest/orders_spec.rb
|
327
|
+
- spec/rest/base_client_spec.rb
|
328
|
+
- spec/rest/configuration_spec.rb
|
329
|
+
- spec/core_extensions/object/is_integer_spec.rb
|
330
|
+
- spec/core_extensions/hash/compact_spec.rb
|