nextcaller_client 0.0.3 → 0.0.4
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/README.md +14 -14
- data/examples/client_get_by_address_name.rb +127 -0
- data/examples/client_get_by_email.rb +57 -0
- data/examples/client_get_by_phone.rb +4 -5
- data/examples/client_get_by_profile_id.rb +4 -3
- data/examples/client_get_fraud_level.rb +13 -7
- data/examples/client_update_by_profile_id.rb +3 -6
- data/examples/platform_get_by_address_name.rb +127 -0
- data/examples/platform_get_by_email.rb +57 -0
- data/examples/platform_get_by_phone.rb +5 -5
- data/examples/platform_get_by_profile_id.rb +5 -5
- data/examples/platform_get_fraud_level.rb +5 -5
- data/examples/platform_get_statistics.rb +4 -4
- data/examples/platform_get_user.rb +5 -5
- data/examples/platform_update_by_profile_id.rb +5 -5
- data/examples/platform_update_platform_user.rb +5 -5
- data/lib/nextcaller_client/client.rb +127 -77
- data/lib/nextcaller_client/constants.rb +9 -3
- data/lib/nextcaller_client/exceptions.rb +10 -0
- data/lib/nextcaller_client/transport.rb +6 -6
- data/lib/nextcaller_client/utils.rb +4 -24
- data/lib/nextcaller_client/version.rb +1 -1
- data/test/constants.rb +1 -1
- data/test/test_by_address_name.rb +27 -0
- data/test/test_by_phone.rb +0 -12
- data/test/test_by_profile.rb +0 -12
- data/test/test_fraud_level.rb +1 -7
- data/test/test_platform_by_address_name.rb +29 -0
- data/test/test_platform_by_phone.rb +2 -14
- data/test/test_platform_by_profile_id.rb +3 -27
- data/test/test_platform_fraud_level.rb +2 -14
- data/test/test_platform_statistics.rb +2 -2
- data/test/test_platform_user.rb +5 -17
- metadata +11 -3
|
@@ -6,9 +6,15 @@ module NextcallerClient
|
|
|
6
6
|
DEFAULT_PROFILE_ID_LENGTH = 30
|
|
7
7
|
DEFAULT_USER_AGENT = 'nextcaller/ruby/%s' % VERSION
|
|
8
8
|
|
|
9
|
+
DEFAULT_PLATFORM_ACCOUNT_HEADER = 'Nc-Account-Id'
|
|
10
|
+
DEFAULT_PLATFORM_ACCOUNT_ID = 'ME'
|
|
11
|
+
|
|
9
12
|
# urls
|
|
10
|
-
BASE_URL = 'api.nextcaller.com/v2/'
|
|
11
|
-
FULL_URL = 'https://api.nextcaller.com/v2/'
|
|
12
|
-
FULL_SANDBOX_URL = 'https://api.sandbox.nextcaller.com/v2/'
|
|
13
|
+
BASE_URL = 'api.nextcaller.com/v2.1/'
|
|
14
|
+
FULL_URL = 'https://api.nextcaller.com/v2.1/'
|
|
15
|
+
FULL_SANDBOX_URL = 'https://api.sandbox.nextcaller.com/v2.1/'
|
|
13
16
|
|
|
17
|
+
# address
|
|
18
|
+
ADDRESS_MANDATORY_FIELDS = %w(first_name last_name address)
|
|
19
|
+
ADDRESS_ALLOWED_FIELDS = ADDRESS_MANDATORY_FIELDS + %w(city state zip_code middle_name apt_suite extended_zip)
|
|
14
20
|
end
|
|
@@ -11,7 +11,7 @@ module NextcallerClient
|
|
|
11
11
|
@log.level = Logger::DEBUG
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def make_http_request(url, method='GET',
|
|
14
|
+
def make_http_request(url, method='GET', data={}, account_id=nil)
|
|
15
15
|
uri = URI.parse(url)
|
|
16
16
|
case method
|
|
17
17
|
when 'GET'
|
|
@@ -21,25 +21,25 @@ module NextcallerClient
|
|
|
21
21
|
request['Content-Type'] = 'application/json'
|
|
22
22
|
request.body = data
|
|
23
23
|
end
|
|
24
|
+
|
|
24
25
|
request.basic_auth(@auth[:username], @auth[:password])
|
|
25
26
|
request['Connection'] = 'Keep-Alive'
|
|
26
27
|
request['User-Agent'] = @user_agent if @user_agent
|
|
28
|
+
request[DEFAULT_PLATFORM_ACCOUNT_HEADER] = account_id if account_id
|
|
27
29
|
|
|
28
30
|
hostname = /\A\[(.*)\]\z/ =~ uri.host ? $1 : uri.host # ruby prior to 1.9.3 does not have 'hostname', which removes brackets from ipv6 addresses
|
|
29
31
|
https = Net::HTTP.new(hostname, uri.port)
|
|
30
32
|
https.read_timeout = DEFAULT_REQUEST_TIMEOUT
|
|
31
33
|
https.use_ssl = true
|
|
32
34
|
|
|
33
|
-
# https.set_debug_output($stderr) if debug #deep debug
|
|
34
|
-
@log.debug('Request url: %s' % url) if debug
|
|
35
|
-
@log.debug('Request body: %s' % data.to_s) if debug && method == 'POST'
|
|
36
|
-
|
|
37
35
|
begin
|
|
38
36
|
response = https.start { |http| http.request(request) }
|
|
39
37
|
case response
|
|
40
38
|
when Net::HTTPSuccess then response
|
|
41
39
|
else
|
|
42
|
-
if response.code.to_i.
|
|
40
|
+
if response.code.to_i.equal? 429
|
|
41
|
+
raise TooManyRequestsException.new(Utils.parse_error_response(response), Utils.parse_error_response_retry_after(response))
|
|
42
|
+
elsif response.code.to_i.between?(400, 499)
|
|
43
43
|
raise HttpException.new(Utils.parse_error_response(response)), '%s Client Error: %s' % [response.code, response.message]
|
|
44
44
|
elsif response.code.to_i.between?(500, 599)
|
|
45
45
|
raise HttpException.new(Utils.parse_error_response(response)), '%s Server Error: %s' % [response.code, response.message]
|
|
@@ -9,6 +9,10 @@ module NextcallerClient
|
|
|
9
9
|
data.to_json
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
def self.parse_error_response_retry_after(resp)
|
|
13
|
+
resp['Retry-After']
|
|
14
|
+
end
|
|
15
|
+
|
|
12
16
|
def self.parse_error_response(resp)
|
|
13
17
|
if resp['Content-Type'].include? 'application/json'
|
|
14
18
|
JSON.parse(resp.body)
|
|
@@ -17,30 +21,6 @@ module NextcallerClient
|
|
|
17
21
|
end
|
|
18
22
|
end
|
|
19
23
|
|
|
20
|
-
#Validate phone format
|
|
21
|
-
def self.validate_phone(value, length=DEFAULT_PHONE_LENGTH)
|
|
22
|
-
value = value.to_s
|
|
23
|
-
unless value =~ /^[0-9]{#{length}}$/
|
|
24
|
-
raise ArgumentError, 'Invalid phone number: %s. Phone should consists of #{length} digits.' % value
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
#Validate porfile id
|
|
29
|
-
def self.validate_profile_id(value, length=DEFAULT_PROFILE_ID_LENGTH)
|
|
30
|
-
value = value.to_s
|
|
31
|
-
unless value =~ /^[0-9a-zA-Z]{#{length}}$/
|
|
32
|
-
raise ArgumentError, 'Invalid profile id: %s. Profile id should consists of #{length} characters.' % value
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
#Validate platform_username
|
|
37
|
-
def self.validate_platform_username(value)
|
|
38
|
-
value = value.to_s
|
|
39
|
-
if value =~ /\W/
|
|
40
|
-
raise ArgumentError, 'Invalid platform name: %s. Platfrom name should contain only an alphanumeric character, including _.' % value
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
24
|
#Prepare url from path and params
|
|
45
25
|
def self.prepare_url(path, sandbox, url_params={})
|
|
46
26
|
url = '%s%s' % [sandbox ? FULL_SANDBOX_URL : FULL_URL, path]
|
data/test/constants.rb
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require_relative './test_base'
|
|
2
|
+
require_relative './constants'
|
|
3
|
+
|
|
4
|
+
class AddressNameTestCase < BaseTestCase
|
|
5
|
+
|
|
6
|
+
def initialize(name)
|
|
7
|
+
@address_data = {
|
|
8
|
+
'first_name' => 'Jerry',
|
|
9
|
+
'last_name' => 'Seinfeld',
|
|
10
|
+
'address' => '129 West 81st Street',
|
|
11
|
+
'city' => 'New York',
|
|
12
|
+
'state' => 'NY',
|
|
13
|
+
'zip_code' => '10024'
|
|
14
|
+
}
|
|
15
|
+
super(name)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_profile_get_name_address_json_request
|
|
19
|
+
stub_request(:get, prepare_url_for_test('records/')).to_return(:body => PHONE_JSON_RESULT_EXAMPLE, :status => 200)
|
|
20
|
+
res = @client.get_by_name_address(@address_data)
|
|
21
|
+
|
|
22
|
+
assert_equal(res['records'][0]['email'], 'demo@nextcaller.com')
|
|
23
|
+
assert_equal(res['records'][0]['first_name'], 'Jerry')
|
|
24
|
+
assert_equal(res['records'][0]['last_name'], 'Seinfeld')
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
data/test/test_by_phone.rb
CHANGED
|
@@ -8,18 +8,6 @@ class PhoneTestCase < BaseTestCase
|
|
|
8
8
|
super(name)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
def test_by_short_phone
|
|
12
|
-
@phone = '212555838'
|
|
13
|
-
stub_request(:get, prepare_url_for_test('records')).to_return(:body => PHONE_JSON_RESULT_EXAMPLE, :status => 200)
|
|
14
|
-
assert_raises(ArgumentError) { @client.get_by_phone(@phone) }
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def test_by_wrong_phone
|
|
18
|
-
@phone = 'XXXXXXXXXX'
|
|
19
|
-
stub_request(:get, prepare_url_for_test('records')).to_return(:body => PHONE_JSON_RESULT_EXAMPLE, :status => 200)
|
|
20
|
-
assert_raises(ArgumentError) { @client.get_by_phone(@phone) }
|
|
21
|
-
end
|
|
22
|
-
|
|
23
11
|
def test_by_phone_json_request
|
|
24
12
|
stub_request(:get, prepare_url_for_test('records')).to_return(:body => PHONE_JSON_RESULT_EXAMPLE, :status => 200)
|
|
25
13
|
res = @client.get_by_phone(@phone)
|
data/test/test_by_profile.rb
CHANGED
|
@@ -16,18 +16,6 @@ class ProfileTestCase < BaseTestCase
|
|
|
16
16
|
assert_equal(res['last_name'], 'Seinfeld')
|
|
17
17
|
end
|
|
18
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
|
-
|
|
31
19
|
def test_profile_update_json_request
|
|
32
20
|
stub_request(:post, prepare_url_for_test('users/')).to_return(:status => 204)
|
|
33
21
|
res = @client.update_by_profile_id(@profile_id, PROFILE_JSON_REQUEST_EXAMPLE)
|
data/test/test_fraud_level.rb
CHANGED
|
@@ -14,11 +14,5 @@ class FraudLevelTestCase < BaseTestCase
|
|
|
14
14
|
assert_equal(res['spoofed'], 'false')
|
|
15
15
|
assert_equal(res['fraud_risk'], 'low')
|
|
16
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
|
-
|
|
17
|
+
|
|
24
18
|
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require_relative './test_base'
|
|
2
|
+
require_relative './constants'
|
|
3
|
+
|
|
4
|
+
class PlatformProfileTestCase < BaseTestCase
|
|
5
|
+
|
|
6
|
+
def initialize(name)
|
|
7
|
+
@account_id = 'user12345'
|
|
8
|
+
super(name)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_platform_profile_get_name_address_json_request
|
|
12
|
+
stub_request(:get, prepare_url_for_test('records/')).to_return(:body => PHONE_JSON_RESULT_EXAMPLE, :status => 200)
|
|
13
|
+
name_address_data = {
|
|
14
|
+
'first_name' => 'Jerry',
|
|
15
|
+
'last_name' => 'Seinfeld',
|
|
16
|
+
'address' => '129 West 81st Street',
|
|
17
|
+
'city' => 'New York',
|
|
18
|
+
'state' => 'NY',
|
|
19
|
+
'zip_code' => '10024'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
res = @client_platform.get_by_name_address(name_address_data, @account_id)
|
|
23
|
+
|
|
24
|
+
assert_equal(res['records'][0]['email'], 'demo@nextcaller.com')
|
|
25
|
+
assert_equal(res['records'][0]['first_name'], 'Jerry')
|
|
26
|
+
assert_equal(res['records'][0]['last_name'], 'Seinfeld')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -5,25 +5,13 @@ class PlatformPhoneTestCase < BaseTestCase
|
|
|
5
5
|
|
|
6
6
|
def initialize(name)
|
|
7
7
|
@phone = '2125558383'
|
|
8
|
-
@
|
|
8
|
+
@account_id = 'user12345'
|
|
9
9
|
super(name)
|
|
10
10
|
end
|
|
11
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
12
|
def test_by_phone_json_request
|
|
25
13
|
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, @
|
|
14
|
+
res = @client_platform.get_by_phone(@phone, @account_id)
|
|
27
15
|
refute_nil(res['records'])
|
|
28
16
|
assert_equal(res['records'][0]['email'], 'demo@nextcaller.com')
|
|
29
17
|
assert_equal(res['records'][0]['first_name'], 'Jerry')
|
|
@@ -5,45 +5,21 @@ class PlatformProfileTestCase < BaseTestCase
|
|
|
5
5
|
|
|
6
6
|
def initialize(name)
|
|
7
7
|
@profile_id = '97d949a413f4ea8b85e9586e1f2d9a'
|
|
8
|
-
@
|
|
8
|
+
@account_id = 'user12345'
|
|
9
9
|
super(name)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def test_platform_profile_get_json_request
|
|
13
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, @
|
|
14
|
+
res = @client_platform.get_by_profile_id(@profile_id, @account_id)
|
|
15
15
|
assert_equal(res['email'], 'demo@nextcaller.com')
|
|
16
16
|
assert_equal(res['first_name'], 'Jerry')
|
|
17
17
|
assert_equal(res['last_name'], 'Seinfeld')
|
|
18
18
|
end
|
|
19
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
20
|
def test_platform_profile_update_json_request
|
|
45
21
|
stub_request(:post, prepare_url_for_test('users/')).to_return(:status => 204)
|
|
46
|
-
res = @client_platform.update_by_profile_id(@profile_id, @
|
|
22
|
+
res = @client_platform.update_by_profile_id(@profile_id, @account_id, PROFILE_JSON_REQUEST_EXAMPLE)
|
|
47
23
|
assert_equal(res.code, '204')
|
|
48
24
|
end
|
|
49
25
|
|
|
@@ -5,27 +5,15 @@ class PlatformFraudLevelTestCase < BaseTestCase
|
|
|
5
5
|
|
|
6
6
|
def initialize(name)
|
|
7
7
|
@phone = '2125558383'
|
|
8
|
-
@
|
|
8
|
+
@account_id = 'user12345'
|
|
9
9
|
super(name)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def test_platform_fraud_level_json_request
|
|
13
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, @
|
|
14
|
+
res = @client_platform.get_fraud_level(@phone, @account_id)
|
|
15
15
|
assert_equal(res['spoofed'], 'false')
|
|
16
16
|
assert_equal(res['fraud_risk'], 'low')
|
|
17
17
|
end
|
|
18
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
19
|
end
|
|
@@ -4,8 +4,8 @@ require_relative './constants'
|
|
|
4
4
|
class PlatformStatisticsTestCase < BaseTestCase
|
|
5
5
|
|
|
6
6
|
def test_platform_statistics_json_response
|
|
7
|
-
stub_request(:get, prepare_url_for_test('
|
|
8
|
-
res = @client_platform.get_platform_statistics
|
|
7
|
+
stub_request(:get, prepare_url_for_test('accounts/')).to_return(:body => PLATFORM_STATISTICS_JSON_RESULT, :status => 200)
|
|
8
|
+
res = @client_platform.get_platform_statistics(1)
|
|
9
9
|
assert_equal(res['platform_users'][0]['username'], 'pl2_un1')
|
|
10
10
|
assert_equal(res['platform_users'][1]['username'], 'pl2_un2')
|
|
11
11
|
end
|
data/test/test_platform_user.rb
CHANGED
|
@@ -4,31 +4,19 @@ require_relative './constants'
|
|
|
4
4
|
class PlatformUserTestCase < BaseTestCase
|
|
5
5
|
|
|
6
6
|
def initialize(name)
|
|
7
|
-
@
|
|
7
|
+
@account_id = 'user12345'
|
|
8
8
|
super(name)
|
|
9
9
|
end
|
|
10
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
11
|
def test_platform_user_json_request
|
|
18
|
-
stub_request(:get, prepare_url_for_test('
|
|
19
|
-
res = @client_platform.
|
|
12
|
+
stub_request(:get, prepare_url_for_test('accounts/%s' % @account_id)).to_return(:body => PLATFORM_USER_JSON_RESULT, :status => 200)
|
|
13
|
+
res = @client_platform.get_platform_account(@account_id)
|
|
20
14
|
assert_equal(res['number_of_operations'], 24)
|
|
21
15
|
end
|
|
22
16
|
|
|
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
17
|
def test_platform_update_user_json_request
|
|
30
|
-
stub_request(:post, prepare_url_for_test('
|
|
31
|
-
res = @client_platform.
|
|
18
|
+
stub_request(:post, prepare_url_for_test('accounts/%s' % @account_id)).to_return(:status => 204)
|
|
19
|
+
res = @client_platform.update_platform_account(PLATFORM_USER_JSON_REQUEST_EXAMPLE, @account_id)
|
|
32
20
|
assert_equal(res.code, '204')
|
|
33
21
|
end
|
|
34
22
|
|
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.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Zenovich Alexey
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2015-11-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -81,10 +81,14 @@ files:
|
|
|
81
81
|
- LICENSE.txt
|
|
82
82
|
- README.md
|
|
83
83
|
- Rakefile
|
|
84
|
+
- examples/client_get_by_address_name.rb
|
|
85
|
+
- examples/client_get_by_email.rb
|
|
84
86
|
- examples/client_get_by_phone.rb
|
|
85
87
|
- examples/client_get_by_profile_id.rb
|
|
86
88
|
- examples/client_get_fraud_level.rb
|
|
87
89
|
- examples/client_update_by_profile_id.rb
|
|
90
|
+
- examples/platform_get_by_address_name.rb
|
|
91
|
+
- examples/platform_get_by_email.rb
|
|
88
92
|
- examples/platform_get_by_phone.rb
|
|
89
93
|
- examples/platform_get_by_profile_id.rb
|
|
90
94
|
- examples/platform_get_fraud_level.rb
|
|
@@ -102,9 +106,11 @@ files:
|
|
|
102
106
|
- nextcaller_client.gemspec
|
|
103
107
|
- test/constants.rb
|
|
104
108
|
- test/test_base.rb
|
|
109
|
+
- test/test_by_address_name.rb
|
|
105
110
|
- test/test_by_phone.rb
|
|
106
111
|
- test/test_by_profile.rb
|
|
107
112
|
- test/test_fraud_level.rb
|
|
113
|
+
- test/test_platform_by_address_name.rb
|
|
108
114
|
- test/test_platform_by_phone.rb
|
|
109
115
|
- test/test_platform_by_profile_id.rb
|
|
110
116
|
- test/test_platform_fraud_level.rb
|
|
@@ -130,16 +136,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
130
136
|
version: '0'
|
|
131
137
|
requirements: []
|
|
132
138
|
rubyforge_project:
|
|
133
|
-
rubygems_version: 2.
|
|
139
|
+
rubygems_version: 2.4.6
|
|
134
140
|
signing_key:
|
|
135
141
|
specification_version: 4
|
|
136
142
|
summary: A Ruby wrapper around the Nextcaller API.
|
|
137
143
|
test_files:
|
|
138
144
|
- test/constants.rb
|
|
139
145
|
- test/test_base.rb
|
|
146
|
+
- test/test_by_address_name.rb
|
|
140
147
|
- test/test_by_phone.rb
|
|
141
148
|
- test/test_by_profile.rb
|
|
142
149
|
- test/test_fraud_level.rb
|
|
150
|
+
- test/test_platform_by_address_name.rb
|
|
143
151
|
- test/test_platform_by_phone.rb
|
|
144
152
|
- test/test_platform_by_profile_id.rb
|
|
145
153
|
- test/test_platform_fraud_level.rb
|