Skip to content

Instantly share code, notes, and snippets.

@tstachl
Created August 7, 2014 00:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tstachl/993d9f74e1cb0157d829 to your computer and use it in GitHub Desktop.
Save tstachl/993d9f74e1cb0157d829 to your computer and use it in GitHub Desktop.
Example on how you can upload customers to desk.com using the desk_api gem.
require 'desk_api'
require 'csv'
DeskApi.configure do |config|
config.username = 'you@example.com'
config.password = 'Top$ecret1'
config.endpoint = 'https://example.desk.com'
end
CSV.foreach('./customers.csv', headers: true) do |csv|
DeskApi.customers.create({
first_name: csv['first_name'],
last_name: csv['last_name'],
emails: [{ type: 'home', value: csv['email'] }],
phone_numbers: [{ type: 'home', value: csv['phone'] }],
custom_fields: {
id: csv['id']
}
})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment