class NextcallerClient::NextCallerClient

The NextCaller API client

Attributes

auth[RW]

Public Class Methods

new(username, password, sandbox=false) click to toggle source
# File lib/nextcaller_client/client.rb, line 7
def initialize(username, password, sandbox=false)
  auth = {username: username, password: password}
  @sandbox = sandbox
  @transport = Transport.new(auth, DEFAULT_USER_AGENT)
end

Public Instance Methods

get_by_email(email) { |response| ... } click to toggle source

Get profile by email arguments:

email      -- Email, required, str, length is 30
# File lib/nextcaller_client/client.rb, line 60
def get_by_email(email)
  url_params = {
      email: email,
      format: JSON_RESPONSE_FORMAT,
  }
  url = Utils.prepare_url('records/', @sandbox, url_params)
  response = @transport.make_http_request(url, 'GET')

  block_given? ? yield(response) : JSON.parse(response.body)
end
get_by_name_address(name_address_data) { |response| ... } click to toggle source

Get profile by name and address arguments:

data                -- dictionary with changed data, required
# File lib/nextcaller_client/client.rb, line 46
def get_by_name_address(name_address_data)
  url_params = {
      format: JSON_RESPONSE_FORMAT
  }.merge(name_address_data)
  url = Utils.prepare_url('records/', @sandbox, url_params)
  response = @transport.make_http_request(url, 'GET')

  block_given? ? yield(response) : JSON.parse(response.body)
end
get_by_phone(phone) { |response| ... } click to toggle source

Get profiles by phone arguments:

phone           -- 10 digits phone, str ot int, required
# File lib/nextcaller_client/client.rb, line 17
def get_by_phone(phone)
  url_params = {
    phone: phone,
    format: JSON_RESPONSE_FORMAT
  }
  url = Utils.prepare_url('records/', @sandbox, url_params)
  response = @transport.make_http_request(url, 'GET')

  block_given? ? yield(response) : JSON.parse(response.body)
end
get_by_profile_id(profile_id) { |response| ... } click to toggle source

Get profile by id arguments:

profile_id      -- Profile identifier, required, length is 30
# File lib/nextcaller_client/client.rb, line 32
def get_by_profile_id(profile_id)
  url_params = {
      format: JSON_RESPONSE_FORMAT
  }
  url = Utils.prepare_url('users/%s/' % profile_id, @sandbox, url_params)
  response = @transport.make_http_request(url, 'GET')

  block_given? ? yield(response) : JSON.parse(response.body)
end
get_fraud_level(phone) { |response| ... } click to toggle source

Get fraud level for phone arguments:

phone           -- 10 digits phone, str ot int, required
# File lib/nextcaller_client/client.rb, line 92
def get_fraud_level(phone)
  url_params = {
    phone: phone,
    format: JSON_RESPONSE_FORMAT
  }
  url = Utils.prepare_url('fraud/', @sandbox, url_params)
  response = @transport.make_http_request(url, 'GET')

  block_given? ? yield(response) : JSON.parse(response.body)
end
update_by_profile_id(profile_id, data) { |response| ... } click to toggle source

Update profile by id arguments:

profile_id      -- Profile identifier, required, length is 30
data            -- dictionary with changed data, required
# File lib/nextcaller_client/client.rb, line 77
def update_by_profile_id(profile_id, data)
  url_params = {
    format: JSON_RESPONSE_FORMAT
  }
  url = Utils.prepare_url('users/%s/' % profile_id, @sandbox, url_params)
  data = Utils.prepare_json_data(data)
  response = @transport.make_http_request(url, 'POST', data)

  block_given? ? yield(response) : response
end