class NextcallerClient::Client
The NextCaller API client
Attributes
auth[RW]
Public Class Methods
new(api_key, api_secret)
click to toggle source
# File lib/test_nextcaller_client/client.rb, line 7 def initialize(api_key, api_secret) @auth = {username: api_key, password: api_secret} end
Public Instance Methods
get_by_phone(phone, response_format=JSON_RESPONSE_FORMAT, debug=false) { |response| ... }
click to toggle source
Get profiles by phone arguments:
phone -- 10 digits phone, str ot int, required response_format -- response format [json|xml] (default json) debug -- boolean (default false)
# File lib/test_nextcaller_client/client.rb, line 18 def get_by_phone(phone, response_format=JSON_RESPONSE_FORMAT, debug=false) method = 'GET' NextcallerClient.validate_format(response_format) NextcallerClient.validate_phone(phone) url_params = { phone: phone, format: response_format } url = NextcallerClient.prepare_url('records', url_params) response = NextcallerClient.make_http_request(@auth, url, method, debug) if block_given? yield response else NextcallerClient.default_handle_response(response, response_format) end end
get_by_profile_id(profile_id, response_format=JSON_RESPONSE_FORMAT, debug=false) { |response| ... }
click to toggle source
Get profile by id arguments:
profile_id -- Profile identifier, required response_format -- response format [json|xml] (default json) debug -- boolean (default false)
# File lib/test_nextcaller_client/client.rb, line 44 def get_by_profile_id(profile_id, response_format=JSON_RESPONSE_FORMAT, debug=false) method = 'GET' NextcallerClient.validate_format(response_format) url_params = { format: response_format } url = NextcallerClient.prepare_url('users/%s/' % profile_id, url_params) response = NextcallerClient.make_http_request(@auth, url, method, debug) if block_given? yield response else NextcallerClient.default_handle_response(response, response_format) end end
update_by_profile_id(profile_id, data, debug=false) { |response| ... }
click to toggle source
Update profile by id arguments:
profile_id -- Profile identifier, required data -- dictionary with changed data, required debug -- boolean (default false)
# File lib/test_nextcaller_client/client.rb, line 68 def update_by_profile_id(profile_id, data, debug=false) method = 'POST' url_params = { format: JSON_RESPONSE_FORMAT } url = NextcallerClient.prepare_url('users/%s/' % profile_id, url_params) data = NextcallerClient.prepare_json_data(data) response = NextcallerClient.make_http_request(@auth, url, method, debug, data) if block_given? yield response else response end end