lib/braintree/customer.rb in braintree-1.2.1 vs lib/braintree/customer.rb in braintree-2.0.0
- old
+ new
@@ -1,13 +1,16 @@
module Braintree
+ # == More Information
+ #
+ # For more detailed documentation on Customers, see http://www.braintreepaymentsolutions.com/gateway/customer-api
class Customer
include BaseModule
attr_reader :addresses, :company, :created_at, :credit_cards, :email, :fax, :first_name, :id, :last_name,
:phone, :updated_at, :website, :custom_fields
- # Returns a PagedCollection of all customers stored in the vault. Due to race conditions, this method
+ # Returns a ResourceCollection of all customers stored in the vault. Due to race conditions, this method
# may not reliably return all customers stored in the vault.
#
# page = Braintree::Customer.all
# loop do
# page.each do |customer|
@@ -21,11 +24,11 @@
response = Http.get("/customers?page=#{page_number}")
attributes = response[:customers]
attributes[:items] = Util.extract_attribute_as_array(attributes, :customer).map do |customer_attributes|
new customer_attributes
end
- PagedCollection.new(attributes) { |page_number| Customer.all(:page => page_number) }
+ ResourceCollection.new(attributes) { |page_number| Customer.all(:page => page_number) }
end
# Creates a customer using the given +attributes+. If <tt>:id</tt> is not passed,
# the gateway will generate it.
#
@@ -93,19 +96,19 @@
def self.sale!(customer_id, transaction_attributes)
return_object_or_raise(:transaction){ sale(customer_id, transaction_attributes) }
end
- # Returns a PagedCollection of transactions for the customer with the given +customer_id+.
+ # Returns a ResourceCollection of transactions for the customer with the given +customer_id+.
def self.transactions(customer_id, options = {})
page_number = options[:page] || 1
response = Http.get "/customers/#{customer_id}/transactions?page=#{page_number}"
attributes = response[:credit_card_transactions]
attributes[:items] = Util.extract_attribute_as_array(attributes, :transaction).map do |transaction_attributes|
Transaction._new transaction_attributes
end
- PagedCollection.new(attributes) { |page_number| Customer.transactions(customer_id, :page => page_number) }
+ ResourceCollection.new(attributes) { |page_number| Customer.transactions(customer_id, :page => page_number) }
end
def self.update(customer_id, attributes)
Util.verify_keys(_update_signature, attributes)
_do_update(:put, "/customers/#{customer_id}", :customer => attributes)
@@ -158,10 +161,10 @@
def sale!(transaction_attributes)
return_object_or_raise(:transaction) { sale(transaction_attributes) }
end
- # Returns a PagedCollection of transactions for the customer.
+ # Returns a ResourceCollection of transactions for the customer.
def transactions(options = {})
Customer.transactions(id, options)
end
def update(attributes)