Class: UplandMobileCommonsRest::Profiles

Inherits:
Base
  • Object
show all
Defined in:
lib/upland_mobile_commons_rest/profiles.rb

Instance Method Summary collapse

Methods inherited from Base

#url_escape

Instance Method Details

#base_pathObject



5
6
7
# File 'lib/upland_mobile_commons_rest/profiles.rb', line 5

def base_path
  'profile'
end

#get(phone_number) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/upland_mobile_commons_rest/profiles.rb', line 9

def get(phone_number)
  resp = client.get_request("#{base_path}?phone_number=#{CGI.escape(phone_number)}")
  resp.body['response']['profile']
# API returns error id '5' (invalid phone number) when profile with phone number is not found
rescue UplandMobileCommonsRest::InvalidPhoneNumber
  nil
end

#update(params) ⇒ Object



17
18
19
# File 'lib/upland_mobile_commons_rest/profiles.rb', line 17

def update(params)
  client.post_request('profile_update', params)
end