Skip to content

Instantly share code, notes, and snippets.

@jerzyn
Created March 21, 2014 11:16
Show Gist options
  • Save jerzyn/9684056 to your computer and use it in GitHub Desktop.
Save jerzyn/9684056 to your computer and use it in GitHub Desktop.
Example Account Info
def api_call_account_read(domain, provider_key, account_id)
url = "https://#{domain}/admin/api/accounts/#{account_id}.xml?provider_key=#{provider_key}"
response = RestClient.get url
raise Exception.new("Wrong response code (#{response.code}) in request #{url}") if response.code!=200
document = Nokogiri::XML(response.to_str)
account = Hash.new
account["email"] = document.xpath("//users/user/email").text
account["name"] = document.xpath("//users/user/first_name").text + " " + document.xpath("//users/user/last_name").text
return account
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment