lib/fake_braintree/customer.rb in fake_braintree-0.0.6 vs lib/fake_braintree/customer.rb in fake_braintree-0.1.0
- old
+ new
@@ -1,20 +1,22 @@
module FakeBraintree
class Customer
include Helpers
def initialize(customer_hash, options)
- @customer_hash = customer_hash.merge("merchant_id" => options[:merchant_id],
- "id" => options[:id])
+ @customer_hash = {
+ "id" => options[:id],
+ "merchant_id" => options[:merchant_id]
+ }.merge(customer_hash)
end
def create
if invalid?
failure_response
else
hash = customer_hash
- FakeBraintree.customers[hash["id"]] = hash
+ FakeBraintree.registry.customers[hash["id"]] = hash
gzipped_response(201, hash.to_xml(:root => 'customer'))
end
end
def update
@@ -25,11 +27,11 @@
failure_response(404)
end
end
def delete
- FakeBraintree.customers[existing_customer_id] = nil
+ FakeBraintree.registry.customers[existing_customer_id] = nil
gzipped_response(200, '')
end
def customer_hash
hash = @customer_hash.dup
@@ -61,10 +63,10 @@
hash["credit_card"]["expiration_year"] = expiration_date.split('/')[1]
end
end
def existing_customer_hash
- existing_customer_id && FakeBraintree.customers[existing_customer_id]
+ existing_customer_id && FakeBraintree.registry.customers[existing_customer_id]
end
def update_existing_customer!
existing_customer_hash.merge!(customer_hash)
end