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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2349e07434c48f600ec72ea85cc10741e58b153
4
- data.tar.gz: dd6243f52aad95b9ceff988150db838eb5d29a4b
3
+ metadata.gz: 3dad21050c4c7b20a11909629c5ac046c510e01f
4
+ data.tar.gz: e3d576fc8338e4e4ead88b24ba6b048c186d5f24
5
5
  SHA512:
6
- metadata.gz: f0598de770e0c0eaceb0a4e9a574ec9f51c7310d23295567d0ff137a1129915c3ed6ea5825fc8e2068871e3579ce028fb92d82880d9be0cf157b927af10e4216
7
- data.tar.gz: a8055a87666c80c0a6a4ede9419cf367996484082a6b3927c845308070cff80df250724b91735114bca02a73143aedbc1e8e8bc0c03e4042138e456b1b1dda05
6
+ metadata.gz: ee989ed5e9e42a07fabf5d6b4337d864e93a54d16efd3a0da4d833707907c7cdaafda820a606d894e449ffad1fa7344ae600144318b15dd46602b883cb995036
7
+ data.tar.gz: 85cb16a130a0d5084d43e4cc5c42e63df321bd2003d3f336f5626a4cbf63442bd98b67b1b5a328ae5e6241923ef22ca6577caa8f60bd26cb3da865ec36e8ff5f
data/.gitignore CHANGED
@@ -1 +1,4 @@
1
1
  /pkg
2
+
3
+ # RubyMine project files
4
+ .idea
data/Gemfile.lock ADDED
@@ -0,0 +1,27 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ nextcaller_client (0.0.2)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ addressable (2.3.6)
10
+ crack (0.4.2)
11
+ safe_yaml (~> 1.0.0)
12
+ minitest (5.4.3)
13
+ rake (10.4.2)
14
+ safe_yaml (1.0.4)
15
+ webmock (1.20.4)
16
+ addressable (>= 2.3.6)
17
+ crack (>= 0.3.2)
18
+
19
+ PLATFORMS
20
+ ruby
21
+
22
+ DEPENDENCIES
23
+ bundler (>= 1.5)
24
+ minitest (> 5.0.1)
25
+ nextcaller_client!
26
+ rake (>= 10.0)
27
+ webmock (>= 1.16)
data/README.md CHANGED
@@ -25,23 +25,23 @@ Or install it yourself as:
25
25
  **Example**
26
26
 
27
27
  require 'nextcaller_client'
28
- api_key = "XXXXX"
29
- api_secret = "YYYYY"
28
+ username = "XXXXX"
29
+ password = "YYYYY"
30
30
  phone_number = "121212..."
31
- client = NextcallerClient::Client.new(api_key, api_secret)
31
+ client = NextcallerClient::NextCallerClient.new(username, password)
32
32
  resp = client.get_by_phone(phone_number)
33
33
  print resp
34
34
 
35
35
  **Initializing client**
36
36
 
37
37
  require 'nextcaller_client'
38
- api_key = "XXXXX"
39
- api_secret = "YYYYY"
40
- client = NextcallerClient::Client.new(api_key, api_secret)
38
+ username = "XXXXX"
39
+ password = "YYYYY"
40
+ client = NextcallerClient::NextCallerClient.new(username, password)
41
41
 
42
42
  **Get profile by phone**
43
43
 
44
- resp = client.get_by_phone(phone, response_format, debug)
44
+ resp = client.get_by_phone(phone, debug)
45
45
 
46
46
  # arguments:
47
47
  # phone -- 10 digits phone, str or int, required
@@ -49,7 +49,7 @@ Or install it yourself as:
49
49
 
50
50
  **Get profile by id**
51
51
 
52
- resp = client.get_by_profile_id(profile_id, response_format, debug)
52
+ resp = client.get_by_profile_id(profile_id, debug)
53
53
 
54
54
  # arguments:
55
55
  # profile_id -- Profile identifier, required
@@ -66,13 +66,30 @@ Or install it yourself as:
66
66
 
67
67
  # Returns 204 response in the case of the succesfull request.
68
68
 
69
+ **Get fraud level**
69
70
 
70
- ##Exceptions
71
+ resp = client.get_fraud_level(phone, debug)
71
72
 
72
- **NextcallerClient::HttpException**
73
+ # arguments:
74
+ # phone -- 10 digits phone, str or int, required
75
+ # debug -- boolean (default false)
76
+
77
+
78
+ ##Errors handling
79
+
80
+ In case of wrong phone number a ArgumentError exception will be thrown:
81
+
82
+ ArgumentError('Invalid phone number: 1221. .........)
83
+
84
+ In case of wrong profile id a ArgumentError exception will be thrown:
85
+
86
+ ArgumentError('Invalid profile id: assw2. .........)
87
+
88
+ In case of wrong platform name a ArgumentError exception will be thrown:
89
+
90
+ ArgumentError('Invalid platform name: sd#s. .........)
73
91
 
74
- Thrown in the case of 4xx or 5xx response from server.
75
- 'content' attribute contains parsed response body.
92
+ [NextcallerClient::HttpException](https://github.com/Nextcaller/nextcaller-ruby-api/blob/master/lib/nextcaller_client/exceptions.rb) exeception is raised in the case of 4xx or 5xx response from server. 'content' attribute contains parsed response body.
76
93
 
77
94
 
78
95
  ##Notes
@@ -0,0 +1,71 @@
1
+ require 'nextcaller_client'
2
+
3
+ username = 'E72D42B98D2232703EE3'
4
+ password = '826f22ade660d6612523b212b997094c70dba8e1'
5
+
6
+ sandbox = false
7
+ phone_number = '2125558383'
8
+
9
+ client = NextcallerClient::NextCallerClient.new(username, password, sandbox)
10
+
11
+ begin
12
+ response_content = client.get_by_phone(phone_number)
13
+ puts response_content.class # Response is a hash
14
+ puts "First name: " + response_content['records'][0]['first_name'] # Retrieve first name for example
15
+ puts response_content
16
+ rescue ArgumentError => error
17
+ puts error.message
18
+ rescue NextcallerClient::HttpException => error
19
+ puts error.message
20
+ puts error.content
21
+ end
22
+ # Output:
23
+ # Hash
24
+ # First name: Jerry
25
+ # {
26
+ # "records":[
27
+ # {
28
+ # "id": "97d949a413f4ea8b85e9586e1f2d9a",
29
+ # "first_name": "Jerry",
30
+ # "middle_name": "",
31
+ # "last_name": "Seinfeld",
32
+ # "name": "Jerry Seinfeld",
33
+ # "language": "English",
34
+ # "phone":[
35
+ # {
36
+ # "number": "2125558383",
37
+ # "resource_uri": "/v2/records/2125558383/"
38
+ # }
39
+ # ],
40
+ # "carrier": "Verizon Wireless",
41
+ # "address":[
42
+ # {
43
+ # "city": "New York",
44
+ # "extended_zip": "",
45
+ # "country": "USA",
46
+ # "line1": "129 West 81st Street",
47
+ # "line2": "Apt 5a", "state": "NY",
48
+ # "zip_code": "10024"
49
+ # }
50
+ # ],
51
+ # "relatives": [],
52
+ # "email": "demo@nextcaller.com",
53
+ # "linked_emails": ["demo@nextcaller.com"],
54
+ # "social_links": [],
55
+ # "age": "",
56
+ # "education": "",
57
+ # "gender": "Male",
58
+ # "high_net_worth": "",
59
+ # "home_owner_status": "",
60
+ # "household_income": "",
61
+ # "length_of_residence": "",
62
+ # "line_type": "",
63
+ # "marital_status": "",
64
+ # "market_value": "",
65
+ # "occupation": "",
66
+ # "presence_of_children": "",
67
+ # "department": "not specified",
68
+ # "resource_uri": "/v2/users/97d949a413f4ea8b85e9586e1f2d9a/"
69
+ # }
70
+ # ]
71
+ # }
@@ -0,0 +1,70 @@
1
+ require 'nextcaller_client'
2
+
3
+ username = 'XXXXX'
4
+ password = 'XXXXX'
5
+ sandbox = false
6
+ profile_id = '97d949a413f4ea8b85e9586e1f2d9a'
7
+
8
+ client = NextcallerClient::NextCallerClient.new(username, password, sandbox)
9
+
10
+ begin
11
+ response_content = client.get_by_profile_id(profile_id)
12
+ puts response_content.class # Response is a hash
13
+ puts "First name: " + response_content['first_name'] # Retrieve first name for example
14
+ puts response_content
15
+ rescue ArgumentError => error
16
+ puts error.message
17
+ rescue NextcallerClient::HttpException => error
18
+ puts error.message
19
+ puts error.content
20
+ end
21
+ # Output:
22
+ # Hash
23
+ # First name: Jerry
24
+ # Response example:
25
+ # {
26
+ # {
27
+ # "id": "97d949a413f4ea8b85e9586e1f2d9a",
28
+ # "first_name": "Jerry",
29
+ # "middle_name": "",
30
+ # "last_name": "Seinfeld",
31
+ # "name": "Jerry Seinfeld",
32
+ # "language": "English",
33
+ # "phone":[
34
+ # {
35
+ # "number": "2125558383",
36
+ # "resource_uri": "/v2/records/2125558383/"
37
+ # }
38
+ # ],
39
+ # "carrier": "Verizon Wireless",
40
+ # "address":[
41
+ # {
42
+ # "city": "New York",
43
+ # "extended_zip": "",
44
+ # "country": "USA",
45
+ # "line1": "129 West 81st Street",
46
+ # "line2": "Apt 5a", "state": "NY",
47
+ # "zip_code": "10024"
48
+ # }
49
+ # ],
50
+ # "relatives": [],
51
+ # "email": "demo@nextcaller.com",
52
+ # "linked_emails": ["demo@nextcaller.com"],
53
+ # "social_links": [],
54
+ # "age": "",
55
+ # "education": "",
56
+ # "gender": "Male",
57
+ # "high_net_worth": "",
58
+ # "home_owner_status": "",
59
+ # "household_income": "",
60
+ # "length_of_residence": "",
61
+ # "line_type": "",
62
+ # "marital_status": "",
63
+ # "market_value": "",
64
+ # "occupation": "",
65
+ # "presence_of_children": "",
66
+ # "department": "not specified",
67
+ # "resource_uri": "/v2/users/97d949a413f4ea8b85e9586e1f2d9a/"
68
+ # }
69
+ # }
70
+ # First name: Jerry
@@ -0,0 +1,27 @@
1
+ require 'nextcaller_client'
2
+
3
+ username = 'XXXXX'
4
+ password = 'XXXXX'
5
+ sandbox = false
6
+ phone_number = '2125558383'
7
+
8
+ client = NextcallerClient::NextCallerClient.new(username, password, sandbox)
9
+
10
+ begin
11
+ response_content = client.get_fraud_level(phone_number)
12
+ puts response_content.class # Response is a hash
13
+ puts "Fraud risk: " + response_content['fraud_risk'] # Retrieve fraud risk for example
14
+ puts response_content
15
+ rescue ArgumentError => error
16
+ puts error.message
17
+ rescue NextcallerClient::HttpException => error
18
+ puts error.message
19
+ puts error.content
20
+ end
21
+ # Output:
22
+ # Hash
23
+ # Fraud risk: medium
24
+ # {
25
+ # "fraud_risk"=>"medium",
26
+ # "spoofed"=>"unknown"
27
+ # }
@@ -0,0 +1,37 @@
1
+ require 'nextcaller_client'
2
+
3
+ username = 'XXXXX'
4
+ password = 'XXXXX'
5
+ sandbox = false
6
+ profile_id = '97d949a413f4ea8b85e9586e1f2d9a'
7
+
8
+ client = NextcallerClient::NextCallerClient.new(username, password, sandbox)
9
+
10
+ begin
11
+ data = {
12
+ first_name: "Clark",
13
+ last_name:"Kent",
14
+ email:"clarkkent@supermail.com",
15
+ phone1:"1234567890",
16
+ phone2:"2345678901",
17
+ phone3:"3456789012",
18
+ shipping_address1:{
19
+ line1:"223 Kryptonite Ave.",
20
+ line2:"",
21
+ city:"Smallville",
22
+ state:"KS",
23
+ zip_code:"66002"
24
+ }
25
+ }
26
+ response = client.update_by_profile_id(profile_id, data)
27
+ puts response.class # Response is a object of Net::HTTPNoContent
28
+ puts 'Success'
29
+ rescue ArgumentError => error
30
+ puts error.message
31
+ rescue NextcallerClient::HttpException => error
32
+ puts error.message
33
+ puts error.content
34
+ end
35
+ # Output:
36
+ # Net::HTTPNoContent
37
+ # Success
@@ -0,0 +1,57 @@
1
+ require 'nextcaller_client'
2
+
3
+ username = 'XXXXX'
4
+ password = 'XXXXX'
5
+ sandbox = false
6
+ platform_username = 'user12345'
7
+ phone_number = '2125558383'
8
+
9
+ client = NextcallerClient::NextCallerPlatformClient.new(username, password, sandbox)
10
+
11
+ begin
12
+ response_content = client.get_by_phone(phone_number, platform_username)
13
+ puts response_content.class # Response is a hash
14
+ puts "First name: " + response_content['records'][0]['first_name'] # Retrieve first name for example
15
+ puts response_content
16
+ rescue ArgumentError => error
17
+ puts error.message
18
+ rescue NextcallerClient::HttpException => error
19
+ puts error.message
20
+ puts error.content
21
+ end
22
+ # Output:
23
+ # Hash
24
+ # First name: Jerry
25
+ # {
26
+ # "records"=>[
27
+ # {
28
+ # "id"=>"97d949a413f4ea8b85e9586e1f2d9a",
29
+ # "first_name"=>"Jerry",
30
+ # "middle_name"=>"",
31
+ # "last_name"=>"Seinfeld",
32
+ # "name"=>"Jerry Seinfeld",
33
+ # "language"=>"English",
34
+ # "phone"=>[
35
+ # {
36
+ # "number"=>"2125558383",
37
+ # "resource_uri"=>"/v2/records/2125558383/"
38
+ # }
39
+ # ],
40
+ # "carrier"=>"Verizon Wireless",
41
+ # "address"=>[
42
+ # {
43
+ # "city"=>"New York",
44
+ # "extended_zip"=>"",
45
+ # "country"=>"USA",
46
+ # "line1"=>"129 West 81st Street",
47
+ # "line2"=>"Apt 5a",
48
+ # "state"=>"NY",
49
+ # "zip_code"=>"10024"
50
+ # }
51
+ # ],
52
+ # "line_type"=>"",
53
+ # "department"=>"not specified",
54
+ # "resource_uri"=>"/v2/users/97d949a413f4ea8b85e9586e1f2d9a/"
55
+ # }
56
+ # ]
57
+ # }
@@ -0,0 +1,55 @@
1
+ require 'nextcaller_client'
2
+
3
+ username = 'XXXXX'
4
+ password = 'XXXXX'
5
+ sandbox = false
6
+ platform_username = 'user12345'
7
+ profile_id = '97d949a413f4ea8b85e9586e1f2d9a'
8
+
9
+ client = NextcallerClient::NextCallerPlatformClient.new(username, password, sandbox)
10
+
11
+ begin
12
+ response_content = client.get_by_profile_id(profile_id, platform_username)
13
+ puts response_content.class # Response is a hash
14
+ puts "First name: " + response_content['first_name'] # Retrieve first name for example
15
+ puts response_content
16
+ rescue ArgumentError => error
17
+ puts error.message
18
+ rescue NextcallerClient::HttpException => error
19
+ puts error.message
20
+ puts error.content
21
+ end
22
+ # Output:
23
+ # Hash
24
+ # First name: Jerry
25
+ # {
26
+ # {
27
+ # "id"=>"97d949a413f4ea8b85e9586e1f2d9a",
28
+ # "first_name"=>"Jerry",
29
+ # "middle_name"=>"",
30
+ # "last_name"=>"Seinfeld",
31
+ # "name"=>"Jerry Seinfeld",
32
+ # "language"=>"English",
33
+ # "phone"=>[
34
+ # {
35
+ # "number"=>"2125558383",
36
+ # "resource_uri"=>"/v2/records/2125558383/"
37
+ # }
38
+ # ],
39
+ # "carrier"=>"Verizon Wireless",
40
+ # "address"=>[
41
+ # {
42
+ # "city"=>"New York",
43
+ # "extended_zip"=>"",
44
+ # "country"=>"USA",
45
+ # "line1"=>"129 West 81st Street",
46
+ # "line2"=>"Apt 5a",
47
+ # "state"=>"NY",
48
+ # "zip_code"=>"10024"
49
+ # }
50
+ # ],
51
+ # "line_type"=>"",
52
+ # "department"=>"not specified",
53
+ # "resource_uri"=>"/v2/users/97d949a413f4ea8b85e9586e1f2d9a/"
54
+ # }
55
+ # }
@@ -0,0 +1,28 @@
1
+ require 'nextcaller_client'
2
+
3
+ username = 'XXXXX'
4
+ password = 'XXXXX'
5
+ sandbox = false
6
+ platform_username = 'user12345'
7
+ phone_number = '2125558383'
8
+
9
+ client = NextcallerClient::NextCallerPlatformClient.new(username, password, sandbox)
10
+
11
+ begin
12
+ response_content = client.get_fraud_level(phone_number, platform_username)
13
+ puts response_content.class # Response is a hash
14
+ puts "Fraud risk: " + response_content['fraud_risk'] # Retrieve fraud risk for example
15
+ puts response_content
16
+ rescue ArgumentError => error
17
+ puts error.message
18
+ rescue NextcallerClient::HttpException => error
19
+ puts error.message
20
+ puts error.content
21
+ end
22
+ # Output:
23
+ # Hash
24
+ # Fraud risk: medium
25
+ # {
26
+ # "fraud_risk"=>"medium",
27
+ # "spoofed"=>"unknown"
28
+ # }
@@ -0,0 +1,48 @@
1
+ require 'nextcaller_client'
2
+
3
+ username = 'XXXXX'
4
+ password = 'XXXXX'
5
+ sandbox = false
6
+
7
+ client = NextcallerClient::NextCallerPlatformClient.new(username, password, sandbox)
8
+
9
+ begin
10
+ response_content = client.get_platform_statistics
11
+ puts response_content.class # Response is a hash
12
+ puts "Platform name: " + response_content['object_list'][0]['username'] # Retrieve platform name for example
13
+ puts response_content
14
+ rescue ArgumentError => error
15
+ puts error.message
16
+ rescue NextcallerClient::HttpException => error
17
+ puts error.message
18
+ puts error.content
19
+ end
20
+ # Output:
21
+ # Hash
22
+ # Platform name: user1
23
+ # {
24
+ # "object_list"=>[
25
+ # {
26
+ # "username"=>"user1",
27
+ # "first_name"=>"",
28
+ # "last_name"=>"",
29
+ # "company_name"=>"",
30
+ # "email"=>"",
31
+ # "number_of_operations"=>1777,
32
+ # "total_calls"=>
33
+ # {
34
+ # "2014-12"=>56,
35
+ # "2014-10"=>9,
36
+ # "2014-11"=>3
37
+ # },
38
+ # "successful_calls"=>
39
+ # {
40
+ # "2014-12"=>56,
41
+ # "2014-10"=>9,
42
+ # "2014-11"=>3
43
+ # },
44
+ # "resource_uri"=>"/v2/platform_users/user1/"
45
+ # },
46
+ # ...
47
+ # ]
48
+ # }
@@ -0,0 +1,42 @@
1
+ require 'nextcaller_client'
2
+
3
+ username = 'XXXXX'
4
+ password = 'XXXXX'
5
+ sandbox = false
6
+ platform_username = 'user12345'
7
+
8
+ client = NextcallerClient::NextCallerPlatformClient.new(username, password, sandbox)
9
+
10
+ begin
11
+ response_content = client.get_platform_user(platform_username)
12
+ puts response_content.class # Response is a hash
13
+ puts "First name: " + response_content['first_name'] # Retrieve first name for example
14
+ puts response_content
15
+ rescue ArgumentError => error
16
+ puts error.message
17
+ rescue NextcallerClient::HttpException => error
18
+ puts error.message
19
+ puts error.content
20
+ end
21
+ # Output:
22
+ # Hash
23
+ # First name: platform_user1_fname
24
+ # {
25
+ # "username"=>"user12345",
26
+ # "first_name"=>"platform_user1_fname",
27
+ # "last_name"=>"platform_user1_lname",
28
+ # "company_name"=>"platform_company1_name",
29
+ # "email"=>"test@test.com",
30
+ # "number_of_operations"=>71,
31
+ # "total_calls"=>
32
+ # {
33
+ # "2014-12"=>14,
34
+ # "2014-11"=>57
35
+ # },
36
+ # "successful_calls"=>
37
+ # {
38
+ # "2014-12"=>14,
39
+ # "2014-11"=>57
40
+ # },
41
+ # "resource_uri"=>"/v2/platform_users/user12345/"
42
+ # }
@@ -0,0 +1,24 @@
1
+ require 'nextcaller_client'
2
+
3
+ username = 'XXXXX'
4
+ password = 'XXXXX'
5
+ sandbox = false
6
+ profile_id = '97d949a413f4ea8b85e9586e1f2d9a'
7
+ platform_username = 'user12345'
8
+
9
+ client = NextcallerClient::NextCallerPlatformClient.new(username, password, sandbox)
10
+
11
+ begin
12
+ data = { email: 'test@test.com' }
13
+ response = client.update_by_profile_id(profile_id, platform_username, data)
14
+ puts response.class # Response is a object of Net::HTTPNoContent
15
+ puts 'Success'
16
+ rescue ArgumentError => error
17
+ puts error.message
18
+ rescue NextcallerClient::HttpException => error
19
+ puts error.message
20
+ puts error.content
21
+ end
22
+ # Output:
23
+ # Net::HTTPNoContent
24
+ # Success
@@ -0,0 +1,23 @@
1
+ require 'nextcaller_client'
2
+
3
+ username = 'XXXXX'
4
+ password = 'XXXXX'
5
+ sandbox = false
6
+ platform_username = 'user12345'
7
+
8
+ client = NextcallerClient::NextCallerPlatformClient.new(username, password, sandbox)
9
+
10
+ begin
11
+ data = { email: 'test@test.com' }
12
+ response = client.update_platform_user(platform_username, data)
13
+ puts response.class # Response is a object of Net::HTTPNoContent
14
+ puts 'Success'
15
+ rescue ArgumentError => error
16
+ puts error.message
17
+ rescue NextcallerClient::HttpException => error
18
+ puts error.message
19
+ puts error.content
20
+ end
21
+ # Output:
22
+ # Net::HTTPNoContent
23
+ # Success