wialon_api 0.0.4 → 0.0.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3696f2c16f7126835bd10c13a5f533b72b07a00
|
4
|
+
data.tar.gz: 84af7147d2315e1d17c3b4ce349c7383aa90d5b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f11002df1f7a104c1427c03ee96367e3951b89a82a1595f7ed99ecc8f04bd016cc296de8644c39b769475598d9d608d3b954281e0f8c491d1ee8a0064a44fc81
|
7
|
+
data.tar.gz: f71918769c4d9e04f5453133bad5d2c7f8bfda94a1c16b125c9f9e03b49f775f470bffa08d88e33ebb314f79a19b689877cac6169cd65569d98d87b636b995a3
|
@@ -3,7 +3,11 @@ module WialonApi
|
|
3
3
|
def authorize(user, password)
|
4
4
|
response = WialonApi::Api.call('core/login', user: user, password: password)
|
5
5
|
result = WialonApi::Result.process(response)
|
6
|
-
WialonApi
|
6
|
+
if WialonApi.wialon_edition == :pro
|
7
|
+
WialonApi::Client.new(result.ssid)
|
8
|
+
else
|
9
|
+
WialonApi::Client.new(result.eid)
|
10
|
+
end
|
7
11
|
end
|
8
12
|
end
|
9
13
|
end
|
@@ -4,6 +4,7 @@ module WialonApi
|
|
4
4
|
module Configuration
|
5
5
|
OPTION_NAMES = [
|
6
6
|
:wialon_host,
|
7
|
+
:wialon_edition,
|
7
8
|
:http_verb,
|
8
9
|
:max_retries,
|
9
10
|
:faraday_options,
|
@@ -21,6 +22,7 @@ module WialonApi
|
|
21
22
|
alias_method :log_responses?, :log_responses
|
22
23
|
|
23
24
|
DEFAULT_WIALON_HOST = 'https://hst-api.wialon.com/wialon/ajax.html'
|
25
|
+
DEFAULT_WIALON_EDITION = :hosting
|
24
26
|
DEFAULT_HTTP_VERB = :post
|
25
27
|
DEFAULT_MAX_RETRIES = 1
|
26
28
|
DEFAULT_ADAPTER = Faraday.default_adapter
|
@@ -37,6 +39,7 @@ module WialonApi
|
|
37
39
|
|
38
40
|
def reset
|
39
41
|
@wialon_host = DEFAULT_WIALON_HOST
|
42
|
+
@wialon_edition = DEFAULT_WIALON_EDITION
|
40
43
|
@http_verb = DEFAULT_HTTP_VERB
|
41
44
|
@max_retries = DEFAULT_MAX_RETRIES
|
42
45
|
@faraday_options = {}
|
data/lib/wialon_api/version.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe WialonApi::Authorization do
|
4
4
|
describe '.authorize' do
|
5
|
-
let(:success) { Hashie::Mash.new(
|
5
|
+
let(:success) { Hashie::Mash.new(eid: 'sid') }
|
6
6
|
let(:error) { Hashie::Mash.new(error: '8') }
|
7
7
|
let(:credentials) { ['user', 'password'] }
|
8
8
|
|
@@ -12,6 +12,16 @@ describe WialonApi::Authorization do
|
|
12
12
|
WialonApi.authorize(*credentials)
|
13
13
|
end
|
14
14
|
|
15
|
+
it "uses ssid with wialon pro edition" do
|
16
|
+
success = Hashie::Mash.new(ssid: 'sid')
|
17
|
+
allow(WialonApi::Api).to receive(:call).and_return(success)
|
18
|
+
WialonApi.configure do |config|
|
19
|
+
config.wialon_edition = :pro
|
20
|
+
end
|
21
|
+
expect(WialonApi::Client).to receive(:new).with('sid')
|
22
|
+
WialonApi.authorize(*credentials)
|
23
|
+
end
|
24
|
+
|
15
25
|
it 'raises an error if password or login do not match' do
|
16
26
|
allow(WialonApi::Api).to receive(:call).and_return(error)
|
17
27
|
expect { WialonApi.authorize(*credentials) }.to raise_error(WialonApi::Error)
|
@@ -21,6 +21,7 @@ describe WialonApi::Configuration do
|
|
21
21
|
it 'resets all the values to their default values' do
|
22
22
|
TestConfiguration.reset
|
23
23
|
expect(TestConfiguration.wialon_host).to eq('https://hst-api.wialon.com/wialon/ajax.html')
|
24
|
+
expect(TestConfiguration.wialon_edition).to eq(:hosting)
|
24
25
|
expect(TestConfiguration.http_verb).to eq(:post)
|
25
26
|
expect(TestConfiguration.max_retries).to eq(1)
|
26
27
|
expect(TestConfiguration.faraday_options).to eq({})
|
data/spec/wialon_api_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wialon_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arsen Shamkhalov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|