Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #8 from colinc/master

Adds customers/phones/create and customers/phones/update support
  • Loading branch information...
commit a6319a059016b222831caa2bbec846f77283ba7f 2 parents 26b5715 + 9432c2e
Chris Warren authored
Showing with 46 additions and 0 deletions.
  1. +8 −0 README.mkd
  2. +38 −0 lib/assistly/client/customer.rb
View
8 README.mkd
@@ -107,6 +107,14 @@ Usage Examples
# Update a customer email
Assistly.update_customer_email(12345, 54321, :email => "foo@example.com")
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
View
38 lib/assistly/client/customer.rb
@@ -103,6 +103,44 @@ def update_customer_email(id, email_id, *args)
return response
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
Please sign in to comment.
Something went wrong with that request. Please try again.