Module: Desk::Client::Customer
- Included in:
- Desk::Client
- Defined in:
- lib/desk/client/customer.rb
Instance Method Summary collapse
- #customer_add_address(customer, address, type = "home") ⇒ Object
- #customer_add_email(customer, email, type = "home") ⇒ Object
- #customer_add_key(key, customer, value, type) ⇒ Object
- #customer_add_phone_number(customer, phone_number, type = "home") ⇒ Object
- #customer_delete_address(customer, *args) ⇒ Object
- #customer_delete_email(customer, *args) ⇒ Object
- #customer_delete_key(key, customer, *args) ⇒ Object
- #customer_delete_phone_number(customer, *args) ⇒ Object
- #customer_endpoints ⇒ Object
Instance Method Details
#customer_add_address(customer, address, type = "home") ⇒ Object
22 23 24 |
# File 'lib/desk/client/customer.rb', line 22 def customer_add_address(customer, address, type = "home") customer_add_key("addresses", customer, address, type) end |
#customer_add_email(customer, email, type = "home") ⇒ Object
30 31 32 |
# File 'lib/desk/client/customer.rb', line 30 def customer_add_email(customer, email, type = "home") customer_add_key("emails", customer, email, type) end |
#customer_add_key(key, customer, value, type) ⇒ Object
9 10 11 12 |
# File 'lib/desk/client/customer.rb', line 9 def customer_add_key(key, customer, value, type) customer.send(key) << {:value => value, :type => type} customer = Desk.update_customer(customer.id, {key.to_sym => customer.send(key)}) end |
#customer_add_phone_number(customer, phone_number, type = "home") ⇒ Object
38 39 40 |
# File 'lib/desk/client/customer.rb', line 38 def customer_add_phone_number(customer, phone_number, type = "home") customer_add_key("phone_numbers", customer, phone_number, type) end |
#customer_delete_address(customer, *args) ⇒ Object
26 27 28 |
# File 'lib/desk/client/customer.rb', line 26 def customer_delete_address(customer, *args) customer_delete_key("addresses", customer, args) end |
#customer_delete_email(customer, *args) ⇒ Object
34 35 36 |
# File 'lib/desk/client/customer.rb', line 34 def customer_delete_email(customer, *args) customer_delete_key("emails", customer, args) end |
#customer_delete_key(key, customer, *args) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/desk/client/customer.rb', line 14 def customer_delete_key(key, customer, *args) a = args.last.is_a?(Array) ? args.pop : args customer.send(key).delete_if do |item| a.include?(item.type) || a.include?(item.value) end customer = Desk.update_customer(customer.id, {key.to_sym => customer.send(key)}) end |
#customer_delete_phone_number(customer, *args) ⇒ Object
42 43 44 |
# File 'lib/desk/client/customer.rb', line 42 def customer_delete_phone_number(customer, *args) customer_delete_key("phone_numbers", customer, args) end |
#customer_endpoints ⇒ Object
5 6 7 |
# File 'lib/desk/client/customer.rb', line 5 def customer_endpoints [ :list, :show, :create, :update, :search ] end |