Class: ChartMogul::Customer
Class Method Summary
collapse
Instance Method Summary
collapse
#update!
included
#destroy!, included
#custom!, #custom_without_assign!, included
#create!, included
Methods inherited from APIResource
connection, handle_other_error, handle_request_error, handling_errors, set_resource_name, set_resource_path, set_resource_root_key
Class Method Details
.all(options = {}) ⇒ Object
41
42
43
|
# File 'lib/chartmogul/customer.rb', line 41
def self.all(options = {})
Customers.all(options)
end
|
.find_by_external_id(external_id) ⇒ Object
50
51
52
|
# File 'lib/chartmogul/customer.rb', line 50
def self.find_by_external_id(external_id)
all(external_id: external_id).first
end
|
.search(email, options = {}) ⇒ Object
46
47
48
|
# File 'lib/chartmogul/customer.rb', line 46
def self.search(email, options = {})
Customers.search(email, options)
end
|
Instance Method Details
#add_custom_attributes!(*custom_attrs) ⇒ Object
87
88
89
90
91
|
# File 'lib/chartmogul/customer.rb', line 87
def add_custom_attributes!(*custom_attrs)
self.custom_attributes = custom_without_assign!(:post,
"/v1/customers/#{uuid}/attributes/custom",
custom: custom_attrs)[:custom]
end
|
75
76
77
78
79
|
# File 'lib/chartmogul/customer.rb', line 75
def add_tags!(*tags)
self.tags = custom_without_assign!(:post,
"/v1/customers/#{uuid}/attributes/tags",
tags: tags)[:tags]
end
|
#custom_attributes ⇒ Object
71
72
73
|
# File 'lib/chartmogul/customer.rb', line 71
def custom_attributes
@attributes[:custom]
end
|
#invoices(options = {}) ⇒ Object
58
59
60
|
# File 'lib/chartmogul/customer.rb', line 58
def invoices(options = {})
@invoices ||= ChartMogul::CustomerInvoices.all(uuid, options)
end
|
#invoices=(invoices_array) ⇒ Object
62
63
64
|
# File 'lib/chartmogul/customer.rb', line 62
def invoices=(invoices_array)
@invoices = ChartMogul::CustomerInvoices.new(customer_uuid: uuid, invoices: invoices_array)
end
|
#merge_into!(other_customer) ⇒ Object
105
106
107
108
109
110
111
112
|
# File 'lib/chartmogul/customer.rb', line 105
def merge_into!(other_customer)
options = {
from: { customer_uuid: uuid },
into: { customer_uuid: other_customer.uuid }
}
custom!(:post, '/v1/customers/merges', options)
true
end
|
#remove_custom_attributes!(*custom_attrs) ⇒ Object
99
100
101
102
103
|
# File 'lib/chartmogul/customer.rb', line 99
def remove_custom_attributes!(*custom_attrs)
self.custom_attributes = custom_without_assign!(:delete,
"/v1/customers/#{uuid}/attributes/custom",
custom: custom_attrs)[:custom]
end
|
81
82
83
84
85
|
# File 'lib/chartmogul/customer.rb', line 81
def remove_tags!(*tags)
self.tags = custom_without_assign!(:delete,
"/v1/customers/#{uuid}/attributes/tags",
tags: tags)[:tags]
end
|
#subscriptions(options = {}) ⇒ Object
54
55
56
|
# File 'lib/chartmogul/customer.rb', line 54
def subscriptions(options = {})
@subscriptions ||= ChartMogul::Subscription.all(uuid, options)
end
|
67
68
69
|
# File 'lib/chartmogul/customer.rb', line 67
def tags
@attributes[:tags]
end
|
#update_custom_attributes!(custom_attrs = {}) ⇒ Object
93
94
95
96
97
|
# File 'lib/chartmogul/customer.rb', line 93
def update_custom_attributes!(custom_attrs = {})
self.custom_attributes = custom_without_assign!(:put,
"/v1/customers/#{uuid}/attributes/custom",
custom: custom_attrs)[:custom]
end
|