Module: Assistly::Client::Customer
- Included in:
- Assistly::Client
- Defined in:
- lib/assistly/client/customer.rb
Overview
Defines methods related to customers
Instance Method Summary collapse
-
#create_customer(*args) ⇒ Object
Create a new customer.
-
#create_customer_email(id, email, *args) ⇒ Object
Create a new customer email.
-
#customer(id) ⇒ Object
Returns extended information on a single customer.
-
#customers(*args) ⇒ Object
Returns extended information of customers.
-
#update_customer(id, *args) ⇒ Object
Update a customer.
-
#update_customer_email(id, email_id, *args) ⇒ Object
Update a customer's email.
Instance Method Details
#create_customer(*args) ⇒ Object
Create a new customer
@option options [String] @example Return extended information for 12345 Assistly.create_customer(:name => "Chris Warren", :twitter => "cdwarren")
41 42 43 44 45 46 47 48 49 |
# File 'lib/assistly/client/customer.rb', line 41 def create_customer(*args) = args.last.is_a?(Hash) ? args.pop : {} response = post("customers",) if response['success'] return response['results']['customer'] else return response end end |
#create_customer_email(id, email, *args) ⇒ Object
Create a new customer email
@option options [String] @example Return extended information for 12345 Assistly.create_customer_email(12345, "[email protected]")
77 78 79 80 81 82 83 84 85 86 |
# File 'lib/assistly/client/customer.rb', line 77 def create_customer_email(id, email, *args) = args.last.is_a?(Hash) ? args.pop : {} .merge!({:email => email}) response = post("customers/#{id}/emails",) if response['success'] return response['results']['email'] else return response end end |
#customer(id) ⇒ Object
Returns extended information on a single customer
@option options [String] @example Return extended information for customer 12345 Assistly.customer(12345)
28 29 30 31 |
# File 'lib/assistly/client/customer.rb', line 28 def customer(id) response = get("customers/#{id}") response.customer end |
#customers(*args) ⇒ Object
Returns extended information of customers
@option options [Boolean, String, Integer] @example Return extended information for customers Assistly.customers Assistly.customers(:since_id => 12345, :count => 5)
14 15 16 17 18 |
# File 'lib/assistly/client/customer.rb', line 14 def customers(*args) = args.last.is_a?(Hash) ? args.pop : {} response = get("customers",) response end |
#update_customer(id, *args) ⇒ Object
Update a customer
@option options [String] @example Return extended information for 12345 Assistly.update_customer(12345, :name => "Christopher Warren")
59 60 61 62 63 64 65 66 67 |
# File 'lib/assistly/client/customer.rb', line 59 def update_customer(id, *args) = args.last.is_a?(Hash) ? args.pop : {} response = put("customers/#{id}",) if response['success'] return response['results']['customer'] else return response end end |
#update_customer_email(id, email_id, *args) ⇒ Object
Update a customer's email
@option options [String] @example Return extended information for 12345 Assistly.update_customer_email(12345, 12345, :email => "[email protected]") Assistly.update_customer_email(12345, 12345, :customer_contact_type => "work")
97 98 99 100 101 102 103 104 105 |
# File 'lib/assistly/client/customer.rb', line 97 def update_customer_email(id, email_id, *args) = args.last.is_a?(Hash) ? args.pop : {} response = put("customers/#{id}/emails/#{email_id}",) if response['success'] return response['results']['email'] else return response end end |