nextcaller_client 0.0.2 → 0.0.3
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/.gitignore +3 -0
- data/Gemfile.lock +27 -0
- data/README.md +29 -12
- data/examples/client_get_by_phone.rb +71 -0
- data/examples/client_get_by_profile_id.rb +70 -0
- data/examples/client_get_fraud_level.rb +27 -0
- data/examples/client_update_by_profile_id.rb +37 -0
- data/examples/platform_get_by_phone.rb +57 -0
- data/examples/platform_get_by_profile_id.rb +55 -0
- data/examples/platform_get_fraud_level.rb +28 -0
- data/examples/platform_get_statistics.rb +48 -0
- data/examples/platform_get_user.rb +42 -0
- data/examples/platform_update_by_profile_id.rb +24 -0
- data/examples/platform_update_platform_user.rb +23 -0
- data/lib/nextcaller_client/client.rb +174 -37
- data/lib/nextcaller_client/constants.rb +2 -0
- data/lib/nextcaller_client/transport.rb +14 -12
- data/lib/nextcaller_client/utils.rb +20 -4
- data/lib/nextcaller_client/version.rb +1 -1
- data/test/constants.rb +206 -0
- data/test/test_base.rb +3 -4
- data/test/test_by_phone.rb +11 -52
- data/test/test_by_profile.rb +14 -55
- data/test/test_fraud_level.rb +24 -0
- data/test/test_platform_by_phone.rb +33 -0
- data/test/test_platform_by_profile_id.rb +50 -0
- data/test/test_platform_fraud_level.rb +31 -0
- data/test/test_platform_statistics.rb +13 -0
- data/test/test_platform_user.rb +35 -0
- metadata +28 -2
data/test/test_by_profile.rb
CHANGED
|
@@ -1,60 +1,7 @@
|
|
|
1
1
|
require_relative './test_base'
|
|
2
|
+
require_relative './constants'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
first_name: 'Clark',
|
|
5
|
-
last_name: 'Kent',
|
|
6
|
-
shipping_address1: {
|
|
7
|
-
line1: '225 Kryptonite Ave.',
|
|
8
|
-
line2: '',
|
|
9
|
-
city: 'Smallville',
|
|
10
|
-
state: 'KS',
|
|
11
|
-
zip_code: '66002'
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
PROFILE_JSON_RESULT_EXAMPLE = '
|
|
16
|
-
{
|
|
17
|
-
"id": "97d949a413f4ea8b85e9586e1f2d9a",
|
|
18
|
-
"first_name": "Jerry",
|
|
19
|
-
"last_name": "Seinfeld",
|
|
20
|
-
"name": "Jerry Seinfeld",
|
|
21
|
-
"language": "English",
|
|
22
|
-
"fraud_threat": "low",
|
|
23
|
-
"spoof": "false",
|
|
24
|
-
"phone": [
|
|
25
|
-
{
|
|
26
|
-
"number": "2125558383"
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"carrier": "Verizon Wireless",
|
|
30
|
-
"line_type": "LAN",
|
|
31
|
-
"address": [
|
|
32
|
-
{
|
|
33
|
-
"city": "New York",
|
|
34
|
-
"extended_zip": "",
|
|
35
|
-
"country": "USA",
|
|
36
|
-
"line2": "Apt 5a",
|
|
37
|
-
"line1": "129 West 81st Street",
|
|
38
|
-
"state": "NY",
|
|
39
|
-
"zip_code": "10024"
|
|
40
|
-
}
|
|
41
|
-
],
|
|
42
|
-
"email": "demo@nextcaller.com",
|
|
43
|
-
"age": "45-54",
|
|
44
|
-
"gender": "Male",
|
|
45
|
-
"household_income": "50k-75k",
|
|
46
|
-
"marital_status": "Single",
|
|
47
|
-
"presence_of_children": "No",
|
|
48
|
-
"home_owner_status": "Rent",
|
|
49
|
-
"market_value": "350k-500k",
|
|
50
|
-
"length_of_residence": "12 Years",
|
|
51
|
-
"high_net_worth": "No",
|
|
52
|
-
"occupation": "Entertainer",
|
|
53
|
-
"education": "Completed College",
|
|
54
|
-
"department": "not specified"
|
|
55
|
-
}'
|
|
56
|
-
|
|
57
|
-
class ProfileTestCase <BaseTestCase
|
|
4
|
+
class ProfileTestCase < BaseTestCase
|
|
58
5
|
|
|
59
6
|
def initialize(name)
|
|
60
7
|
@profile_id = '97d949a413f4ea8b85e9586e1f2d9a'
|
|
@@ -69,6 +16,18 @@ class ProfileTestCase <BaseTestCase
|
|
|
69
16
|
assert_equal(res['last_name'], 'Seinfeld')
|
|
70
17
|
end
|
|
71
18
|
|
|
19
|
+
def test_by_wrong_profile_id
|
|
20
|
+
@profile_id = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
|
21
|
+
stub_request(:get, prepare_url_for_test('users/')).to_return(:body => PROFILE_JSON_RESULT_EXAMPLE, :status => 200)
|
|
22
|
+
assert_raises(ArgumentError) { @client.get_by_profile_id(@profile_id) }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_profile_update_by_wrong_profile_id
|
|
26
|
+
@profile_id = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
|
27
|
+
stub_request(:post, prepare_url_for_test('users/')).to_return(:status => 204)
|
|
28
|
+
assert_raises(ArgumentError) { @client.get_by_profile_id(@profile_id) }
|
|
29
|
+
end
|
|
30
|
+
|
|
72
31
|
def test_profile_update_json_request
|
|
73
32
|
stub_request(:post, prepare_url_for_test('users/')).to_return(:status => 204)
|
|
74
33
|
res = @client.update_by_profile_id(@profile_id, PROFILE_JSON_REQUEST_EXAMPLE)
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require_relative './test_base'
|
|
2
|
+
require_relative './constants'
|
|
3
|
+
|
|
4
|
+
class FraudLevelTestCase < BaseTestCase
|
|
5
|
+
|
|
6
|
+
def initialize(name)
|
|
7
|
+
@phone = '2125558383'
|
|
8
|
+
super(name)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_fraud_level_json_request
|
|
12
|
+
stub_request(:get, prepare_url_for_test('fraud/')).to_return(:body => FRAUD_LEVEL_JSON_RESULT_EXAMPLE, :status => 200)
|
|
13
|
+
res = @client.get_fraud_level(@phone)
|
|
14
|
+
assert_equal(res['spoofed'], 'false')
|
|
15
|
+
assert_equal(res['fraud_risk'], 'low')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_fraud_level_by_wrong_phone
|
|
19
|
+
@phone = '123'
|
|
20
|
+
stub_request(:get, prepare_url_for_test('fraud/')).to_return(:body => FRAUD_LEVEL_JSON_RESULT_EXAMPLE, :status => 200)
|
|
21
|
+
assert_raises(ArgumentError) { @client.get_fraud_level(@phone) }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require_relative './test_base'
|
|
2
|
+
require_relative './constants'
|
|
3
|
+
|
|
4
|
+
class PlatformPhoneTestCase < BaseTestCase
|
|
5
|
+
|
|
6
|
+
def initialize(name)
|
|
7
|
+
@phone = '2125558383'
|
|
8
|
+
@platform_username = 'user12345'
|
|
9
|
+
super(name)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_by_wrong_phone
|
|
13
|
+
@phone = '212555838'
|
|
14
|
+
stub_request(:get, prepare_url_for_test('records')).to_return(:body => PHONE_JSON_RESULT_EXAMPLE, :status => 200)
|
|
15
|
+
assert_raises(ArgumentError) { @client_platform.get_by_phone(@phone, @platform_username) }
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_by_wrong_platform
|
|
19
|
+
@platform_username = 'user#12345'
|
|
20
|
+
stub_request(:get, prepare_url_for_test('records')).to_return(:body => PHONE_JSON_RESULT_EXAMPLE, :status => 200)
|
|
21
|
+
assert_raises(ArgumentError) { @client_platform.get_by_phone(@phone, @platform_username) }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_by_phone_json_request
|
|
25
|
+
stub_request(:get, prepare_url_for_test('records')).to_return(:body => PHONE_JSON_RESULT_EXAMPLE, :status => 200)
|
|
26
|
+
res = @client_platform.get_by_phone(@phone, @platform_username)
|
|
27
|
+
refute_nil(res['records'])
|
|
28
|
+
assert_equal(res['records'][0]['email'], 'demo@nextcaller.com')
|
|
29
|
+
assert_equal(res['records'][0]['first_name'], 'Jerry')
|
|
30
|
+
assert_equal(res['records'][0]['last_name'], 'Seinfeld')
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require_relative './test_base'
|
|
2
|
+
require_relative './constants'
|
|
3
|
+
|
|
4
|
+
class PlatformProfileTestCase < BaseTestCase
|
|
5
|
+
|
|
6
|
+
def initialize(name)
|
|
7
|
+
@profile_id = '97d949a413f4ea8b85e9586e1f2d9a'
|
|
8
|
+
@platform_username = 'user12345'
|
|
9
|
+
super(name)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_platform_profile_get_json_request
|
|
13
|
+
stub_request(:get, prepare_url_for_test('users/')).to_return(:body => PROFILE_JSON_RESULT_EXAMPLE, :status => 200)
|
|
14
|
+
res = @client_platform.get_by_profile_id(@profile_id, @platform_username)
|
|
15
|
+
assert_equal(res['email'], 'demo@nextcaller.com')
|
|
16
|
+
assert_equal(res['first_name'], 'Jerry')
|
|
17
|
+
assert_equal(res['last_name'], 'Seinfeld')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_platform_profile_by_wrong_profile_id
|
|
21
|
+
@profile_id = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
|
22
|
+
stub_request(:get, prepare_url_for_test('users/')).to_return(:body => PROFILE_JSON_RESULT_EXAMPLE, :status => 200)
|
|
23
|
+
assert_raises(ArgumentError) { @client_platform.get_by_profile_id(@profile_id, @platform_username) }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_platform_profile_by_wrong_platform
|
|
27
|
+
@platform_username = 'user#12345'
|
|
28
|
+
stub_request(:get, prepare_url_for_test('users/')).to_return(:body => PROFILE_JSON_RESULT_EXAMPLE, :status => 200)
|
|
29
|
+
assert_raises(ArgumentError) { @client_platform.get_by_profile_id(@profile_id, @platform_username) }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_platform_profile_update_json_request_by_wrong_profile_id
|
|
33
|
+
@profile_id = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
|
34
|
+
stub_request(:post, prepare_url_for_test('users/')).to_return(:status => 204)
|
|
35
|
+
assert_raises(ArgumentError) { @client_platform.update_by_profile_id(@profile_id, @platform_username) }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_platform_profile_update_json_request_by_wrong_wrong_platform
|
|
39
|
+
@platform_username = 'user#12345'
|
|
40
|
+
stub_request(:post, prepare_url_for_test('users/')).to_return(:status => 204)
|
|
41
|
+
assert_raises(ArgumentError) { @client_platform.update_by_profile_id(@profile_id, @platform_username) }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_platform_profile_update_json_request
|
|
45
|
+
stub_request(:post, prepare_url_for_test('users/')).to_return(:status => 204)
|
|
46
|
+
res = @client_platform.update_by_profile_id(@profile_id, @platform_username, PROFILE_JSON_REQUEST_EXAMPLE)
|
|
47
|
+
assert_equal(res.code, '204')
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require_relative './test_base'
|
|
2
|
+
require_relative './constants'
|
|
3
|
+
|
|
4
|
+
class PlatformFraudLevelTestCase < BaseTestCase
|
|
5
|
+
|
|
6
|
+
def initialize(name)
|
|
7
|
+
@phone = '2125558383'
|
|
8
|
+
@platform_username = 'user12345'
|
|
9
|
+
super(name)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_platform_fraud_level_json_request
|
|
13
|
+
stub_request(:get, prepare_url_for_test('fraud/')).to_return(:body => FRAUD_LEVEL_JSON_RESULT_EXAMPLE, :status => 200)
|
|
14
|
+
res = @client_platform.get_fraud_level(@phone, @platform_username)
|
|
15
|
+
assert_equal(res['spoofed'], 'false')
|
|
16
|
+
assert_equal(res['fraud_risk'], 'low')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_fraud_level_by_wrong_phone
|
|
20
|
+
@phone = '123'
|
|
21
|
+
stub_request(:get, prepare_url_for_test('fraud/')).to_return(:body => FRAUD_LEVEL_JSON_RESULT_EXAMPLE, :status => 200)
|
|
22
|
+
assert_raises(ArgumentError) { @client_platform.get_fraud_level(@phone, @platform_username) }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_fraud_level_by_wrong_platform
|
|
26
|
+
@platform_username = 'user#12345'
|
|
27
|
+
stub_request(:get, prepare_url_for_test('fraud/')).to_return(:body => FRAUD_LEVEL_JSON_RESULT_EXAMPLE, :status => 200)
|
|
28
|
+
assert_raises(ArgumentError) { @client_platform.get_fraud_level(@phone, @platform_username) }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require_relative './test_base'
|
|
2
|
+
require_relative './constants'
|
|
3
|
+
|
|
4
|
+
class PlatformStatisticsTestCase < BaseTestCase
|
|
5
|
+
|
|
6
|
+
def test_platform_statistics_json_response
|
|
7
|
+
stub_request(:get, prepare_url_for_test('platform_users/')).to_return(:body => PLATFORM_STATISTICS_JSON_RESULT, :status => 200)
|
|
8
|
+
res = @client_platform.get_platform_statistics
|
|
9
|
+
assert_equal(res['platform_users'][0]['username'], 'pl2_un1')
|
|
10
|
+
assert_equal(res['platform_users'][1]['username'], 'pl2_un2')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require_relative './test_base'
|
|
2
|
+
require_relative './constants'
|
|
3
|
+
|
|
4
|
+
class PlatformUserTestCase < BaseTestCase
|
|
5
|
+
|
|
6
|
+
def initialize(name)
|
|
7
|
+
@platform_username = 'user12345'
|
|
8
|
+
super(name)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_platform_user_by_wrong_platform
|
|
12
|
+
@platform_username = 'user#12345'
|
|
13
|
+
stub_request(:get, prepare_url_for_test('platform_users/%s' % @platform_username)).to_return(:body => PLATFORM_USER_JSON_RESULT, :status => 200)
|
|
14
|
+
assert_raises(ArgumentError) { @client_platform.get_platform_user(@platform_username) }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_platform_user_json_request
|
|
18
|
+
stub_request(:get, prepare_url_for_test('platform_users/%s' % @platform_username)).to_return(:body => PLATFORM_USER_JSON_RESULT, :status => 200)
|
|
19
|
+
res = @client_platform.get_platform_user(@platform_username)
|
|
20
|
+
assert_equal(res['number_of_operations'], 24)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_platform_update_user_by_wrong_platform
|
|
24
|
+
@platform_username = 'user#12345'
|
|
25
|
+
stub_request(:post, prepare_url_for_test('platform_users/%s' % @platform_username)).to_return(:status => 204)
|
|
26
|
+
assert_raises(ArgumentError) { @client_platform.update_platform_user(@platform_username) }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_platform_update_user_json_request
|
|
30
|
+
stub_request(:post, prepare_url_for_test('platform_users/%s' % @platform_username)).to_return(:status => 204)
|
|
31
|
+
res = @client_platform.update_platform_user(@platform_username, PLATFORM_USER_JSON_REQUEST_EXAMPLE)
|
|
32
|
+
assert_equal(res.code, '204')
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nextcaller_client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Zenovich Alexey
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-12-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -77,9 +77,21 @@ files:
|
|
|
77
77
|
- ".gitignore"
|
|
78
78
|
- ".travis.yml"
|
|
79
79
|
- Gemfile
|
|
80
|
+
- Gemfile.lock
|
|
80
81
|
- LICENSE.txt
|
|
81
82
|
- README.md
|
|
82
83
|
- Rakefile
|
|
84
|
+
- examples/client_get_by_phone.rb
|
|
85
|
+
- examples/client_get_by_profile_id.rb
|
|
86
|
+
- examples/client_get_fraud_level.rb
|
|
87
|
+
- examples/client_update_by_profile_id.rb
|
|
88
|
+
- examples/platform_get_by_phone.rb
|
|
89
|
+
- examples/platform_get_by_profile_id.rb
|
|
90
|
+
- examples/platform_get_fraud_level.rb
|
|
91
|
+
- examples/platform_get_statistics.rb
|
|
92
|
+
- examples/platform_get_user.rb
|
|
93
|
+
- examples/platform_update_by_profile_id.rb
|
|
94
|
+
- examples/platform_update_platform_user.rb
|
|
83
95
|
- lib/nextcaller_client.rb
|
|
84
96
|
- lib/nextcaller_client/client.rb
|
|
85
97
|
- lib/nextcaller_client/constants.rb
|
|
@@ -88,9 +100,16 @@ files:
|
|
|
88
100
|
- lib/nextcaller_client/utils.rb
|
|
89
101
|
- lib/nextcaller_client/version.rb
|
|
90
102
|
- nextcaller_client.gemspec
|
|
103
|
+
- test/constants.rb
|
|
91
104
|
- test/test_base.rb
|
|
92
105
|
- test/test_by_phone.rb
|
|
93
106
|
- test/test_by_profile.rb
|
|
107
|
+
- test/test_fraud_level.rb
|
|
108
|
+
- test/test_platform_by_phone.rb
|
|
109
|
+
- test/test_platform_by_profile_id.rb
|
|
110
|
+
- test/test_platform_fraud_level.rb
|
|
111
|
+
- test/test_platform_statistics.rb
|
|
112
|
+
- test/test_platform_user.rb
|
|
94
113
|
homepage: http://rubygems.org/gems/nextcaller-client
|
|
95
114
|
licenses:
|
|
96
115
|
- MIT
|
|
@@ -116,6 +135,13 @@ signing_key:
|
|
|
116
135
|
specification_version: 4
|
|
117
136
|
summary: A Ruby wrapper around the Nextcaller API.
|
|
118
137
|
test_files:
|
|
138
|
+
- test/constants.rb
|
|
119
139
|
- test/test_base.rb
|
|
120
140
|
- test/test_by_phone.rb
|
|
121
141
|
- test/test_by_profile.rb
|
|
142
|
+
- test/test_fraud_level.rb
|
|
143
|
+
- test/test_platform_by_phone.rb
|
|
144
|
+
- test/test_platform_by_profile_id.rb
|
|
145
|
+
- test/test_platform_fraud_level.rb
|
|
146
|
+
- test/test_platform_statistics.rb
|
|
147
|
+
- test/test_platform_user.rb
|