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

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")

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true



41
42
43
44
45
46
47
48
49
# File 'lib/assistly/client/customer.rb', line 41

def create_customer(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  response = post("customers",options)
  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]")

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true



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)
  options = args.last.is_a?(Hash) ? args.pop : {}
  options.merge!({:email => email})
  response = post("customers/#{id}/emails",options)
  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)

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true



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)

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true



14
15
16
17
18
# File 'lib/assistly/client/customer.rb', line 14

def customers(*args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  response = get("customers",options)
  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")

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true



59
60
61
62
63
64
65
66
67
# File 'lib/assistly/client/customer.rb', line 59

def update_customer(id, *args)
  options = args.last.is_a?(Hash) ? args.pop : {}
  response = put("customers/#{id}",options)
  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")

See Also:

Supported formats:

  • :json

Requires Authentication:

  • true



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)
  options = args.last.is_a?(Hash) ? args.pop : {}
  response = put("customers/#{id}/emails/#{email_id}",options)
  if response['success']
    return response['results']['email']
  else
    return response
  end
end