class ChartMogul::Customer
Public Class Methods
all(options = {})
click to toggle source
# File lib/chartmogul/customer.rb, line 44 def self.all(options = {}) Customers.all(options) end
find_by_external_id(external_id)
click to toggle source
# File lib/chartmogul/customer.rb, line 52 def self.find_by_external_id(external_id) all(external_id: external_id).first end
search(email, options = {})
click to toggle source
# File lib/chartmogul/customer.rb, line 48 def self.search(email, options = {}) Customers.search(email, options) end
Public Instance Methods
add_custom_attributes!(*custom_attrs)
click to toggle source
# File lib/chartmogul/customer.rb, line 89 def add_custom_attributes!(*custom_attrs) self.custom_attributes = custom_without_assign!(:post, "/v1/customers/#{uuid}/attributes/custom", custom: custom_attrs)[:custom] end
custom_attributes()
click to toggle source
# File lib/chartmogul/customer.rb, line 73 def custom_attributes @attributes[:custom] end
invoices(options = {})
click to toggle source
# File lib/chartmogul/customer.rb, line 60 def invoices(options = {}) @invoices ||= ChartMogul::CustomerInvoices.all(uuid, options) end
invoices=(invoices_array)
click to toggle source
# File lib/chartmogul/customer.rb, line 64 def invoices=(invoices_array) @invoices = ChartMogul::CustomerInvoices.new(customer_uuid: uuid, invoices: invoices_array) end
merge_into!(other_customer)
click to toggle source
# File lib/chartmogul/customer.rb, line 107 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)
click to toggle source
# File lib/chartmogul/customer.rb, line 101 def remove_custom_attributes!(*custom_attrs) self.custom_attributes = custom_without_assign!(:delete, "/v1/customers/#{uuid}/attributes/custom", custom: custom_attrs)[:custom] end
subscriptions(options = {})
click to toggle source
# File lib/chartmogul/customer.rb, line 56 def subscriptions(options = {}) @subscriptions ||= ChartMogul::Subscription.all(uuid, options) end
update_custom_attributes!(custom_attrs = {})
click to toggle source
# File lib/chartmogul/customer.rb, line 95 def update_custom_attributes!(custom_attrs = {}) self.custom_attributes = custom_without_assign!(:put, "/v1/customers/#{uuid}/attributes/custom", custom: custom_attrs)[:custom] end
Private Instance Methods
custom_attributes=(custom_attributes = {})
click to toggle source
# File lib/chartmogul/customer.rb, line 122 def custom_attributes=(custom_attributes = {}) @attributes[:custom] = ChartMogul::Utils::JSONParser.typecast_custom_attributes(custom_attributes) end
set_attributes(attributes_attributes)
click to toggle source
# File lib/chartmogul/customer.rb, line 126 def set_attributes(attributes_attributes) @attributes = attributes_attributes @attributes[:custom] = ChartMogul::Utils::JSONParser.typecast_custom_attributes(attributes_attributes[:custom]) end