Skip to content

Instantly share code, notes, and snippets.

@austinthecoder
Created December 18, 2015 21:50
Show Gist options
  • Save austinthecoder/268fcaa988dcee7d01ca to your computer and use it in GitHub Desktop.
Save austinthecoder/268fcaa988dcee7d01ca to your computer and use it in GitHub Desktop.
def self.to_google_params(params)
given_name = params[:first_name] if params.key? :first_name
family_name = params[:last_name] if params.key? :last_name
department = params[:department] if params.key? :department
title = params[:title] if params.key? :title
result = {}
result[:primaryEmail] = params[:address] if params.key? :address
result[:password] = params[:password] if params.key? :password
result[:name] = {givenName: given_name, familyName: family_name} if given_name || family_name
result[:organizations] = [{department: department, title: title}] if department || title
result[:includeInGlobalAddressList] = !params[:privacy] if params.key? :privacy
result[:orgUnitPath] = params[:org_unit_path] if params.key? :org_unit_path
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment