Skip to content

Commit

Permalink
Merge pull request #8 from colinc/master
Browse files Browse the repository at this point in the history
Adds customers/phones/create and customers/phones/update support
  • Loading branch information
Chris Warren committed Apr 19, 2012
2 parents 26b5715 + 9432c2e commit a6319a0
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.mkd
Expand Up @@ -107,6 +107,14 @@ Usage Examples
# Update a customer email # Update a customer email
Assistly.update_customer_email(12345, 54321, :email => "foo@example.com") Assistly.update_customer_email(12345, 54321, :email => "foo@example.com")
Assistly.update_customer_email(12345, 54321, :customer_contact_type => "work") Assistly.update_customer_email(12345, 54321, :customer_contact_type => "work")

# Add a customer phone number
Assistly.create_customer_phone(12345, "555-368-7147")
Assistly.create_customer_phone(12345, "555-368-7147", :customer_contact_type => "work")

# Update a customer phone number
Assistly.update_customer_phone(12345, 54321, :phone => "555-368-7147")
Assistly.update_customer_phone(12345, 54321, :customer_contact_type => "work")


###### ######
# Interactions # Interactions
Expand Down
38 changes: 38 additions & 0 deletions lib/assistly/client/customer.rb
Expand Up @@ -103,6 +103,44 @@ def update_customer_email(id, email_id, *args)
return response return response
end end
end end

# Create a new customer phone number
#
# @option options [String]
# @example Return extended information for 12345
# Assistly.create_customer_phone(12345, "555-368-7147")
# @format :json
# @authenticated true
# @see http://dev.desk.com/docs/api/customers/phones/create
def create_customer_phone(id, phone, *args)
options = args.last.is_a?(Hash) ? args.pop : {}
options.merge!({:phone => phone})
response = post("customers/#{id}/phones",options)
if response['success']
return response['results']['phone']
else
return response
end
end

# Update a customer's phone number
#
# @option options [String]
# @example Return extended information for 12345
# Assistly.update_customer_phone(12345, 12345, :phone => "555-368-7147")
# Assistly.update_customer_phone(12345, 12345, :customer_contact_type => "work")
# @format :json
# @authenticated true
# @see http://dev.desk.com/docs/api/customers/phones/update
def update_customer_phone(id, phone_id, *args)
options = args.last.is_a?(Hash) ? args.pop : {}
response = put("customers/#{id}/phones/#{phone_id}",options)
if response['success']
return response['results']['phone']
else
return response
end
end
end end
end end
end end

0 comments on commit a6319a0

Please sign in to comment.