Class: ChartMogul::Customer
Overview
rubocop:disable Metrics/ClassLength
Constant Summary
Constants inherited
from APIResource
APIResource::BACKOFF_FACTOR, APIResource::INTERVAL, APIResource::INTERVAL_RANDOMNESS, APIResource::MAX_INTERVAL, APIResource::RETRY_EXCEPTIONS, APIResource::RETRY_STATUSES, APIResource::THREAD_CONNECTION_KEY
Class Method Summary
collapse
Instance Method Summary
collapse
included, #update!
included
#destroy!, included
#custom!, #custom_without_assign!, included
#create!, included
Methods inherited from APIResource
connection, handle_other_error, handle_request_error, handling_errors, immutable_keys, set_immutable_keys, set_resource_name, set_resource_path, set_resource_root_key
Methods inherited from Object
#allowed_for_write?, #assign_all_attributes, #assign_writeable_attributes, attributes, define_private_writer, define_reader, define_writer, #initialize, #instance_attributes, new_from_json, readonly_attr, #serialize_for_write, #serialized_value_for_attr, writeable_attr, writeable_attributes
Class Method Details
.all(options = {}) ⇒ Object
48
49
50
|
# File 'lib/chartmogul/customer.rb', line 48
def self.all(options = {})
Customers.all(options)
end
|
.find_by_external_id(external_id) ⇒ Object
56
57
58
|
# File 'lib/chartmogul/customer.rb', line 56
def self.find_by_external_id(external_id)
all(external_id: external_id).first
end
|
.merge!(into_uuid:, from_uuid:) ⇒ Object
60
61
62
63
64
65
66
67
|
# File 'lib/chartmogul/customer.rb', line 60
def self.merge!(into_uuid:, from_uuid:)
options = {
from: { customer_uuid: from_uuid },
into: { customer_uuid: into_uuid }
}
custom!(:post, '/v1/customers/merges', options)
true
end
|
.search(email, options = {}) ⇒ Object
52
53
54
|
# File 'lib/chartmogul/customer.rb', line 52
def self.search(email, options = {})
Customers.search(email, options)
end
|
.unmerge!(customer_uuid:, data_source_uuid:, external_id:, move_to_new_customer: []) ⇒ Object
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/chartmogul/customer.rb', line 69
def self.unmerge!(customer_uuid:, data_source_uuid:, external_id:, move_to_new_customer: [])
options = {
customer_uuid: customer_uuid,
data_source_uuid: data_source_uuid,
external_id: external_id,
move_to_new_customer: move_to_new_customer
}
custom!(:post, '/v1/customers/unmerges', options)
true
end
|
Instance Method Details
#add_custom_attributes!(*custom_attrs) ⇒ Object
137
138
139
140
141
|
# File 'lib/chartmogul/customer.rb', line 137
def add_custom_attributes!(*custom_attrs)
self.custom_attributes = custom_without_assign!(:post,
"/v1/customers/#{uuid}/attributes/custom",
custom: custom_attrs)[:custom]
end
|
125
126
127
128
129
|
# File 'lib/chartmogul/customer.rb', line 125
def add_tags!(*tags)
self.tags = custom_without_assign!(:post,
"/v1/customers/#{uuid}/attributes/tags",
tags: tags)[:tags]
end
|
92
93
94
|
# File 'lib/chartmogul/customer.rb', line 92
def contacts(options = {})
Contacts.all(options.merge(customer_uuid: uuid))
end
|
96
97
98
|
# File 'lib/chartmogul/customer.rb', line 96
def create_contact(options = {})
Contact.create!(options.merge(customer_uuid: uuid))
end
|
#create_note(options = {}) ⇒ Object
104
105
106
|
# File 'lib/chartmogul/customer.rb', line 104
def create_note(options = {})
Note.create!(options.merge(customer_uuid: uuid))
end
|
#create_opportunity(options = {}) ⇒ Object
112
113
114
|
# File 'lib/chartmogul/customer.rb', line 112
def create_opportunity(options = {})
Opportunity.create!(options.merge(customer_uuid: uuid))
end
|
#custom_attributes ⇒ Object
121
122
123
|
# File 'lib/chartmogul/customer.rb', line 121
def custom_attributes
@attributes[:custom]
end
|
#invoices(options = {}) ⇒ Object
84
85
86
|
# File 'lib/chartmogul/customer.rb', line 84
def invoices(options = {})
@invoices ||= ChartMogul::CustomerInvoices.all(uuid, options)
end
|
#invoices=(invoices_array) ⇒ Object
88
89
90
|
# File 'lib/chartmogul/customer.rb', line 88
def invoices=(invoices_array)
@invoices = ChartMogul::CustomerInvoices.new(customer_uuid: uuid, invoices: invoices_array)
end
|
#merge_into!(other_customer) ⇒ Object
155
156
157
158
159
160
161
162
|
# File 'lib/chartmogul/customer.rb', line 155
def merge_into!(other_customer)
options = {
from: { customer_uuid: uuid },
into: { customer_uuid: other_customer.uuid }
}
custom!(:post, '/v1/customers/merges', options)
true
end
|
#notes(options = {}) ⇒ Object
100
101
102
|
# File 'lib/chartmogul/customer.rb', line 100
def notes(options = {})
Notes.all(options.merge(customer_uuid: uuid))
end
|
#opportunities(options = {}) ⇒ Object
108
109
110
|
# File 'lib/chartmogul/customer.rb', line 108
def opportunities(options = {})
Opportnities.all(options.merge(customer_uuid: uuid))
end
|
#remove_custom_attributes!(*custom_attrs) ⇒ Object
149
150
151
152
153
|
# File 'lib/chartmogul/customer.rb', line 149
def remove_custom_attributes!(*custom_attrs)
self.custom_attributes = custom_without_assign!(:delete,
"/v1/customers/#{uuid}/attributes/custom",
custom: custom_attrs)
end
|
131
132
133
134
135
|
# File 'lib/chartmogul/customer.rb', line 131
def remove_tags!(*tags)
self.tags = custom_without_assign!(:delete,
"/v1/customers/#{uuid}/attributes/tags",
tags: tags)[:tags]
end
|
#subscriptions(options = {}) ⇒ Object
80
81
82
|
# File 'lib/chartmogul/customer.rb', line 80
def subscriptions(options = {})
@subscriptions ||= ChartMogul::Subscription.all(uuid, options)
end
|
117
118
119
|
# File 'lib/chartmogul/customer.rb', line 117
def tags
@attributes[:tags]
end
|
#unmerge!(data_source_uuid:, external_id:, move_to_new_customer: []) ⇒ Object
164
165
166
167
168
169
170
171
|
# File 'lib/chartmogul/customer.rb', line 164
def unmerge!(data_source_uuid:, external_id:, move_to_new_customer: [])
self.class.unmerge!(
customer_uuid: uuid,
data_source_uuid: data_source_uuid,
external_id: external_id,
move_to_new_customer: move_to_new_customer
)
end
|
#update_custom_attributes!(custom_attrs = {}) ⇒ Object
143
144
145
146
147
|
# File 'lib/chartmogul/customer.rb', line 143
def update_custom_attributes!(custom_attrs = {})
self.custom_attributes = custom_without_assign!(:put,
"/v1/customers/#{uuid}/attributes/custom",
custom: custom_attrs)[:custom]
end
|