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
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require 'nextcaller_client'
|
|
2
|
+
|
|
3
|
+
api_username = 'XXXXX'
|
|
4
|
+
api_password = 'XXXXX'
|
|
5
|
+
sandbox = false
|
|
6
|
+
account_id = 'user12345'
|
|
7
|
+
email = 'email@exmaple.com'
|
|
8
|
+
|
|
9
|
+
client = NextcallerClient::NextCallerPlatformClient.new(api_username, api_password, sandbox)
|
|
10
|
+
|
|
11
|
+
begin
|
|
12
|
+
response_content = client.get_by_email(email, account_id)
|
|
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
|
+
# }
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
require 'nextcaller_client'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
api_username = 'XXXXX'
|
|
4
|
+
api_password = 'XXXXX'
|
|
5
5
|
sandbox = false
|
|
6
|
-
|
|
6
|
+
account_id = 'user12345'
|
|
7
7
|
phone_number = '2125558383'
|
|
8
8
|
|
|
9
|
-
client = NextcallerClient::NextCallerPlatformClient.new(
|
|
9
|
+
client = NextcallerClient::NextCallerPlatformClient.new(api_username, api_password, sandbox)
|
|
10
10
|
|
|
11
11
|
begin
|
|
12
|
-
response_content = client.get_by_phone(phone_number,
|
|
12
|
+
response_content = client.get_by_phone(phone_number, account_id)
|
|
13
13
|
puts response_content.class # Response is a hash
|
|
14
14
|
puts "First name: " + response_content['records'][0]['first_name'] # Retrieve first name for example
|
|
15
15
|
puts response_content
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
require 'nextcaller_client'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
api_username = 'XXXXX'
|
|
4
|
+
api_password = 'XXXXX'
|
|
5
5
|
sandbox = false
|
|
6
|
-
|
|
6
|
+
account_id = 'user12345'
|
|
7
7
|
profile_id = '97d949a413f4ea8b85e9586e1f2d9a'
|
|
8
8
|
|
|
9
|
-
client = NextcallerClient::NextCallerPlatformClient.new(
|
|
9
|
+
client = NextcallerClient::NextCallerPlatformClient.new(api_username, api_password, sandbox)
|
|
10
10
|
|
|
11
11
|
begin
|
|
12
|
-
response_content = client.get_by_profile_id(profile_id,
|
|
12
|
+
response_content = client.get_by_profile_id(profile_id, account_id)
|
|
13
13
|
puts response_content.class # Response is a hash
|
|
14
14
|
puts "First name: " + response_content['first_name'] # Retrieve first name for example
|
|
15
15
|
puts response_content
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
require 'nextcaller_client'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
api_username = 'XXXXX'
|
|
4
|
+
api_password = 'XXXXX'
|
|
5
5
|
sandbox = false
|
|
6
|
-
|
|
6
|
+
account_id = 'user12345'
|
|
7
7
|
phone_number = '2125558383'
|
|
8
8
|
|
|
9
|
-
client = NextcallerClient::NextCallerPlatformClient.new(
|
|
9
|
+
client = NextcallerClient::NextCallerPlatformClient.new(api_username, api_password, sandbox)
|
|
10
10
|
|
|
11
11
|
begin
|
|
12
|
-
response_content = client.get_fraud_level(phone_number,
|
|
12
|
+
response_content = client.get_fraud_level(phone_number, account_id)
|
|
13
13
|
puts response_content.class # Response is a hash
|
|
14
14
|
puts "Fraud risk: " + response_content['fraud_risk'] # Retrieve fraud risk for example
|
|
15
15
|
puts response_content
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
require 'nextcaller_client'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
api_username = 'XXXXX'
|
|
4
|
+
api_password = 'XXXXX'
|
|
5
5
|
sandbox = false
|
|
6
6
|
|
|
7
|
-
client = NextcallerClient::NextCallerPlatformClient.new(
|
|
7
|
+
client = NextcallerClient::NextCallerPlatformClient.new(api_username, api_password, sandbox)
|
|
8
8
|
|
|
9
9
|
begin
|
|
10
10
|
response_content = client.get_platform_statistics
|
|
11
11
|
puts response_content.class # Response is a hash
|
|
12
|
-
puts "Platform name: " + response_content['
|
|
12
|
+
puts "Platform name: " + response_content['data'][0]['id'] # Retrieve platform name for example
|
|
13
13
|
puts response_content
|
|
14
14
|
rescue ArgumentError => error
|
|
15
15
|
puts error.message
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
require 'nextcaller_client'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
api_username = 'XXXXX'
|
|
4
|
+
api_password = 'XXXXX'
|
|
5
5
|
sandbox = false
|
|
6
|
-
|
|
6
|
+
account_id = 'user12345'
|
|
7
7
|
|
|
8
|
-
client = NextcallerClient::NextCallerPlatformClient.new(
|
|
8
|
+
client = NextcallerClient::NextCallerPlatformClient.new(api_username, api_password, sandbox)
|
|
9
9
|
|
|
10
10
|
begin
|
|
11
|
-
response_content = client.
|
|
11
|
+
response_content = client.get_platform_account(account_id)
|
|
12
12
|
puts response_content.class # Response is a hash
|
|
13
13
|
puts "First name: " + response_content['first_name'] # Retrieve first name for example
|
|
14
14
|
puts response_content
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
require 'nextcaller_client'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
api_username = 'XXXXX'
|
|
4
|
+
api_password = 'XXXXX'
|
|
5
5
|
sandbox = false
|
|
6
6
|
profile_id = '97d949a413f4ea8b85e9586e1f2d9a'
|
|
7
|
-
|
|
7
|
+
account_id = 'user12345'
|
|
8
8
|
|
|
9
|
-
client = NextcallerClient::NextCallerPlatformClient.new(
|
|
9
|
+
client = NextcallerClient::NextCallerPlatformClient.new(api_username, api_password, sandbox)
|
|
10
10
|
|
|
11
11
|
begin
|
|
12
12
|
data = { email: 'test@test.com' }
|
|
13
|
-
response = client.update_by_profile_id(profile_id,
|
|
13
|
+
response = client.update_by_profile_id(profile_id, account_id, data)
|
|
14
14
|
puts response.class # Response is a object of Net::HTTPNoContent
|
|
15
15
|
puts 'Success'
|
|
16
16
|
rescue ArgumentError => error
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
require 'nextcaller_client'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
api_username = 'XXXXX'
|
|
4
|
+
api_password = 'XXXXX'
|
|
5
5
|
sandbox = false
|
|
6
|
-
|
|
6
|
+
account_id = 'user12345'
|
|
7
7
|
|
|
8
|
-
client = NextcallerClient::NextCallerPlatformClient.new(
|
|
8
|
+
client = NextcallerClient::NextCallerPlatformClient.new(api_username, api_password, sandbox)
|
|
9
9
|
|
|
10
10
|
begin
|
|
11
11
|
data = { email: 'test@test.com' }
|
|
12
|
-
response = client.update_platform_user(
|
|
12
|
+
response = client.update_platform_user(account_id, data)
|
|
13
13
|
puts response.class # Response is a object of Net::HTTPNoContent
|
|
14
14
|
puts 'Success'
|
|
15
15
|
rescue ArgumentError => error
|
|
@@ -13,16 +13,14 @@ module NextcallerClient
|
|
|
13
13
|
# Get profiles by phone
|
|
14
14
|
# arguments:
|
|
15
15
|
# phone -- 10 digits phone, str ot int, required
|
|
16
|
-
# debug -- boolean (default false)
|
|
17
16
|
#
|
|
18
|
-
def get_by_phone(phone
|
|
19
|
-
Utils.validate_phone(phone)
|
|
17
|
+
def get_by_phone(phone)
|
|
20
18
|
url_params = {
|
|
21
19
|
phone: phone,
|
|
22
20
|
format: JSON_RESPONSE_FORMAT
|
|
23
21
|
}
|
|
24
22
|
url = Utils.prepare_url('records/', @sandbox, url_params)
|
|
25
|
-
response = @transport.make_http_request(url, 'GET'
|
|
23
|
+
response = @transport.make_http_request(url, 'GET')
|
|
26
24
|
|
|
27
25
|
block_given? ? yield(response) : JSON.parse(response.body)
|
|
28
26
|
end
|
|
@@ -30,33 +28,59 @@ module NextcallerClient
|
|
|
30
28
|
# Get profile by id
|
|
31
29
|
# arguments:
|
|
32
30
|
# profile_id -- Profile identifier, required, length is 30
|
|
33
|
-
# debug -- boolean (default false)
|
|
34
31
|
#
|
|
35
|
-
def get_by_profile_id(profile_id
|
|
36
|
-
Utils.validate_profile_id(profile_id)
|
|
32
|
+
def get_by_profile_id(profile_id)
|
|
37
33
|
url_params = {
|
|
38
|
-
|
|
34
|
+
format: JSON_RESPONSE_FORMAT
|
|
39
35
|
}
|
|
40
36
|
url = Utils.prepare_url('users/%s/' % profile_id, @sandbox, url_params)
|
|
41
|
-
response = @transport.make_http_request(url, 'GET'
|
|
37
|
+
response = @transport.make_http_request(url, 'GET')
|
|
38
|
+
|
|
39
|
+
block_given? ? yield(response) : JSON.parse(response.body)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Get profile by name and address
|
|
43
|
+
# arguments:
|
|
44
|
+
# data -- dictionary with changed data, required
|
|
45
|
+
#
|
|
46
|
+
def get_by_name_address(name_address_data)
|
|
47
|
+
url_params = {
|
|
48
|
+
format: JSON_RESPONSE_FORMAT
|
|
49
|
+
}.merge(name_address_data)
|
|
50
|
+
url = Utils.prepare_url('records/', @sandbox, url_params)
|
|
51
|
+
response = @transport.make_http_request(url, 'GET')
|
|
52
|
+
|
|
53
|
+
block_given? ? yield(response) : JSON.parse(response.body)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Get profile by email
|
|
57
|
+
# arguments:
|
|
58
|
+
# email -- Email, required, str, length is 30
|
|
59
|
+
#
|
|
60
|
+
def get_by_email(email)
|
|
61
|
+
url_params = {
|
|
62
|
+
email: email,
|
|
63
|
+
format: JSON_RESPONSE_FORMAT,
|
|
64
|
+
}
|
|
65
|
+
url = Utils.prepare_url('records/', @sandbox, url_params)
|
|
66
|
+
response = @transport.make_http_request(url, 'GET')
|
|
42
67
|
|
|
43
68
|
block_given? ? yield(response) : JSON.parse(response.body)
|
|
44
69
|
end
|
|
45
70
|
|
|
71
|
+
|
|
46
72
|
# Update profile by id
|
|
47
73
|
# arguments:
|
|
48
74
|
# profile_id -- Profile identifier, required, length is 30
|
|
49
75
|
# data -- dictionary with changed data, required
|
|
50
|
-
# debug -- boolean (default false)
|
|
51
76
|
#
|
|
52
|
-
def update_by_profile_id(profile_id, data
|
|
53
|
-
Utils.validate_profile_id(profile_id)
|
|
77
|
+
def update_by_profile_id(profile_id, data)
|
|
54
78
|
url_params = {
|
|
55
79
|
format: JSON_RESPONSE_FORMAT
|
|
56
80
|
}
|
|
57
81
|
url = Utils.prepare_url('users/%s/' % profile_id, @sandbox, url_params)
|
|
58
82
|
data = Utils.prepare_json_data(data)
|
|
59
|
-
response = @transport.make_http_request(url, 'POST',
|
|
83
|
+
response = @transport.make_http_request(url, 'POST', data)
|
|
60
84
|
|
|
61
85
|
block_given? ? yield(response) : response
|
|
62
86
|
end
|
|
@@ -64,16 +88,14 @@ module NextcallerClient
|
|
|
64
88
|
# Get fraud level for phone
|
|
65
89
|
# arguments:
|
|
66
90
|
# phone -- 10 digits phone, str ot int, required
|
|
67
|
-
# debug -- boolean (default false)
|
|
68
91
|
#
|
|
69
|
-
def get_fraud_level(phone
|
|
70
|
-
Utils.validate_phone(phone)
|
|
92
|
+
def get_fraud_level(phone)
|
|
71
93
|
url_params = {
|
|
72
94
|
phone: phone,
|
|
73
95
|
format: JSON_RESPONSE_FORMAT
|
|
74
96
|
}
|
|
75
97
|
url = Utils.prepare_url('fraud/', @sandbox, url_params)
|
|
76
|
-
response = @transport.make_http_request(url, 'GET'
|
|
98
|
+
response = @transport.make_http_request(url, 'GET')
|
|
77
99
|
|
|
78
100
|
block_given? ? yield(response) : JSON.parse(response.body)
|
|
79
101
|
end
|
|
@@ -87,19 +109,15 @@ module NextcallerClient
|
|
|
87
109
|
# Get profiles by phone
|
|
88
110
|
# arguments:
|
|
89
111
|
# phone -- 10 digits phone, str ot int, required
|
|
90
|
-
#
|
|
91
|
-
# debug -- boolean (default false)
|
|
112
|
+
# account_id -- platform username, str.
|
|
92
113
|
#
|
|
93
|
-
def get_by_phone(phone,
|
|
94
|
-
Utils.validate_phone(phone)
|
|
95
|
-
Utils.validate_platform_username(platform_username)
|
|
114
|
+
def get_by_phone(phone, account_id=DEFAULT_PLATFORM_ACCOUNT_ID)
|
|
96
115
|
url_params = {
|
|
97
116
|
phone: phone,
|
|
98
|
-
platform_username: platform_username,
|
|
99
117
|
format: JSON_RESPONSE_FORMAT
|
|
100
118
|
}
|
|
101
119
|
url = Utils.prepare_url('records/', @sandbox, url_params)
|
|
102
|
-
response = @transport.make_http_request(url, 'GET',
|
|
120
|
+
response = @transport.make_http_request(url, 'GET', account_id)
|
|
103
121
|
|
|
104
122
|
block_given? ? yield(response) : JSON.parse(response.body)
|
|
105
123
|
end
|
|
@@ -107,18 +125,44 @@ module NextcallerClient
|
|
|
107
125
|
# Get profiles by phone
|
|
108
126
|
# arguments:
|
|
109
127
|
# profile_id -- Profile identifier, required, length is 30
|
|
110
|
-
#
|
|
111
|
-
# debug -- boolean (default false)
|
|
128
|
+
# account_id -- platform username, str.
|
|
112
129
|
#
|
|
113
|
-
def get_by_profile_id(profile_id,
|
|
114
|
-
Utils.validate_profile_id(profile_id)
|
|
115
|
-
Utils.validate_platform_username(platform_username)
|
|
130
|
+
def get_by_profile_id(profile_id, account_id=DEFAULT_PLATFORM_ACCOUNT_ID)
|
|
116
131
|
url_params = {
|
|
117
|
-
|
|
118
|
-
format: JSON_RESPONSE_FORMAT
|
|
132
|
+
format: JSON_RESPONSE_FORMAT
|
|
119
133
|
}
|
|
120
134
|
url = Utils.prepare_url('users/%s/' % profile_id, @sandbox, url_params)
|
|
121
|
-
response = @transport.make_http_request(url, 'GET',
|
|
135
|
+
response = @transport.make_http_request(url, 'GET', account_id)
|
|
136
|
+
|
|
137
|
+
block_given? ? yield(response) : JSON.parse(response.body)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Get profile by name and address
|
|
141
|
+
# arguments:
|
|
142
|
+
# data -- dictionary with changed data, required
|
|
143
|
+
# account_id -- platform username, str.
|
|
144
|
+
#
|
|
145
|
+
def get_by_name_address(name_address_data, account_id)
|
|
146
|
+
url_params = {
|
|
147
|
+
format: JSON_RESPONSE_FORMAT
|
|
148
|
+
}.merge(name_address_data)
|
|
149
|
+
url = Utils.prepare_url('records/', @sandbox, url_params)
|
|
150
|
+
response = @transport.make_http_request(url, 'GET', account_id)
|
|
151
|
+
|
|
152
|
+
block_given? ? yield(response) : JSON.parse(response.body)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# Get profile by email
|
|
156
|
+
# arguments:
|
|
157
|
+
# email -- Email, required, str, length is 30
|
|
158
|
+
#
|
|
159
|
+
def get_by_email(email, account_id=DEFAULT_PLATFORM_ACCOUNT_ID)
|
|
160
|
+
url_params = {
|
|
161
|
+
format: JSON_RESPONSE_FORMAT,
|
|
162
|
+
email: email
|
|
163
|
+
}
|
|
164
|
+
url = Utils.prepare_url('records/', @sandbox, url_params)
|
|
165
|
+
response = @transport.make_http_request(url, 'GET', account_id)
|
|
122
166
|
|
|
123
167
|
block_given? ? yield(response) : JSON.parse(response.body)
|
|
124
168
|
end
|
|
@@ -127,91 +171,97 @@ module NextcallerClient
|
|
|
127
171
|
# arguments:
|
|
128
172
|
# profile_id -- Profile identifier, required, length is 30
|
|
129
173
|
# data -- dictionary with changed data, required
|
|
130
|
-
#
|
|
131
|
-
# debug -- boolean (default false)
|
|
174
|
+
# account_id -- platform username, str.
|
|
132
175
|
#
|
|
133
|
-
def update_by_profile_id(profile_id,
|
|
134
|
-
Utils.validate_profile_id(profile_id)
|
|
135
|
-
Utils.validate_platform_username(platform_username)
|
|
176
|
+
def update_by_profile_id(profile_id, account_id=DEFAULT_PLATFORM_ACCOUNT_ID, data)
|
|
136
177
|
url_params = {
|
|
137
|
-
platform_username: platform_username,
|
|
138
178
|
format: JSON_RESPONSE_FORMAT
|
|
139
179
|
}
|
|
140
180
|
url = Utils.prepare_url('users/%s/' % profile_id, @sandbox, url_params)
|
|
141
181
|
data = Utils.prepare_json_data(data)
|
|
142
|
-
response = @transport.make_http_request(url, 'POST',
|
|
182
|
+
response = @transport.make_http_request(url, 'POST', data, account_id)
|
|
143
183
|
|
|
144
184
|
block_given? ? yield(response) : response
|
|
145
185
|
end
|
|
146
186
|
|
|
147
|
-
# Get
|
|
187
|
+
# Get platform statistics
|
|
148
188
|
# arguments:
|
|
149
|
-
#
|
|
150
|
-
# data -- dictionary with changed data, required
|
|
151
|
-
# platform_username -- platform username, str.
|
|
152
|
-
# debug -- boolean (default false)
|
|
189
|
+
# page -- integer (default 1)
|
|
153
190
|
#
|
|
154
|
-
def
|
|
155
|
-
Utils.validate_phone(phone)
|
|
156
|
-
Utils.validate_platform_username(platform_username)
|
|
191
|
+
def get_platform_statistics(page=1)
|
|
157
192
|
url_params = {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
format: JSON_RESPONSE_FORMAT
|
|
193
|
+
page: page,
|
|
194
|
+
format: JSON_RESPONSE_FORMAT,
|
|
161
195
|
}
|
|
162
|
-
url = Utils.prepare_url('
|
|
163
|
-
response = @transport.make_http_request(url, 'GET'
|
|
164
|
-
|
|
196
|
+
url = Utils.prepare_url('accounts/', @sandbox, url_params)
|
|
197
|
+
response = @transport.make_http_request(url, 'GET')
|
|
198
|
+
puts response.body
|
|
165
199
|
block_given? ? yield(response) : JSON.parse(response.body)
|
|
166
200
|
end
|
|
167
201
|
|
|
168
|
-
# Get platform
|
|
202
|
+
# Get platform user
|
|
169
203
|
# arguments:
|
|
170
|
-
#
|
|
204
|
+
# account_id -- platform username, str.
|
|
171
205
|
#
|
|
172
|
-
def
|
|
206
|
+
def get_platform_account(account_id=DEFAULT_PLATFORM_ACCOUNT_ID)
|
|
173
207
|
url_params = {
|
|
174
|
-
|
|
208
|
+
format: JSON_RESPONSE_FORMAT
|
|
175
209
|
}
|
|
176
|
-
url = Utils.prepare_url('
|
|
177
|
-
response = @transport.make_http_request(url, 'GET'
|
|
210
|
+
url = Utils.prepare_url('accounts/%s/' % account_id, @sandbox, url_params)
|
|
211
|
+
response = @transport.make_http_request(url, 'GET')
|
|
178
212
|
|
|
179
213
|
block_given? ? yield(response) : JSON.parse(response.body)
|
|
180
214
|
end
|
|
181
215
|
|
|
182
|
-
#
|
|
216
|
+
# Create platform account
|
|
183
217
|
# arguments:
|
|
184
|
-
#
|
|
185
|
-
# debug -- boolean (default false)
|
|
218
|
+
# data -- dictionary with changed data, required
|
|
186
219
|
#
|
|
187
|
-
def
|
|
188
|
-
Utils.validate_platform_username(platform_username)
|
|
220
|
+
def create_platform_account(data)
|
|
189
221
|
url_params = {
|
|
190
|
-
|
|
222
|
+
format: JSON_RESPONSE_FORMAT
|
|
191
223
|
}
|
|
192
|
-
url = Utils.prepare_url('
|
|
193
|
-
|
|
224
|
+
url = Utils.prepare_url('accounts/', @sandbox, url_params)
|
|
225
|
+
data = Utils.prepare_json_data(data)
|
|
226
|
+
response = @transport.make_http_request(url, 'POST', data)
|
|
194
227
|
|
|
195
|
-
block_given? ? yield(response) :
|
|
228
|
+
block_given? ? yield(response) : response
|
|
196
229
|
end
|
|
197
230
|
|
|
198
231
|
# Update platform user data
|
|
199
232
|
# arguments:
|
|
200
|
-
#
|
|
233
|
+
# account_id -- platform username, str.
|
|
201
234
|
# data -- dictionary with changed data, required
|
|
202
|
-
# debug -- boolean (default false)
|
|
203
235
|
#
|
|
204
|
-
def
|
|
205
|
-
Utils.validate_platform_username(platform_username)
|
|
236
|
+
def update_platform_account(account_data, account_id)
|
|
206
237
|
url_params = {
|
|
207
|
-
|
|
238
|
+
format: JSON_RESPONSE_FORMAT
|
|
208
239
|
}
|
|
209
|
-
url = Utils.prepare_url('
|
|
210
|
-
data = Utils.prepare_json_data(
|
|
211
|
-
response = @transport.make_http_request(url, 'POST',
|
|
240
|
+
url = Utils.prepare_url('accounts/%s/' % account_id, @sandbox, url_params)
|
|
241
|
+
data = Utils.prepare_json_data(account_data)
|
|
242
|
+
response = @transport.make_http_request(url, 'POST', data)
|
|
212
243
|
|
|
213
244
|
block_given? ? yield(response) : response
|
|
214
|
-
end
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
# Get profiles by phone
|
|
249
|
+
# arguments:
|
|
250
|
+
# phone -- 10 digits phone, str ot int, required
|
|
251
|
+
# data -- dictionary with changed data, required
|
|
252
|
+
# account_id -- platform username, str.
|
|
253
|
+
#
|
|
254
|
+
def get_fraud_level(phone, account_id=DEFAULT_PLATFORM_ACCOUNT_ID)
|
|
255
|
+
url_params = {
|
|
256
|
+
phone: phone,
|
|
257
|
+
format: JSON_RESPONSE_FORMAT
|
|
258
|
+
}
|
|
259
|
+
url = Utils.prepare_url('fraud/', @sandbox, url_params)
|
|
260
|
+
response = @transport.make_http_request(url, 'GET', account_id)
|
|
261
|
+
|
|
262
|
+
block_given? ? yield(response) : JSON.parse(response.body)
|
|
263
|
+
end
|
|
264
|
+
|
|
215
265
|
|
|
216
266
|
end
|
|
217
267
|
|