Class: FakeBraintree::Address
- Inherits:
-
Object
- Object
- FakeBraintree::Address
show all
- Includes:
- Helpers
- Defined in:
- lib/fake_braintree/address.rb
Instance Method Summary
collapse
Methods included from Helpers
#create_id, #gzip, #gzipped_response, #md5
Constructor Details
#initialize(address_hash_from_params, options) ⇒ Address
Returns a new instance of Address.
5
6
7
|
# File 'lib/fake_braintree/address.rb', line 5
def initialize(address_hash_from_params, options)
set_up_address(address_hash_from_params, options)
end
|
Instance Method Details
#create ⇒ Object
9
10
11
12
13
14
|
# File 'lib/fake_braintree/address.rb', line 9
def create
@address['id'] = generate_id
FakeBraintree.registry.addresses[id] = @address
customer['addresses'] << @address
response_for_updated_address
end
|
#customer ⇒ Object
16
17
18
|
# File 'lib/fake_braintree/address.rb', line 16
def customer
FakeBraintree.registry.customers[@address['customer_id']]
end
|
#generate_id ⇒ Object
31
32
33
|
# File 'lib/fake_braintree/address.rb', line 31
def generate_id
"#{@address['customer_id']}_#{customer['addresses'].size}"
end
|
#id ⇒ Object
35
36
37
|
# File 'lib/fake_braintree/address.rb', line 35
def id
@address['id']
end
|
#response_for_updated_address ⇒ Object
20
21
22
|
# File 'lib/fake_braintree/address.rb', line 20
def response_for_updated_address
gzipped_response(200, @address.to_xml(root: 'address'))
end
|
#set_up_address(address_hash_from_params, options) ⇒ Object
24
25
26
27
28
29
|
# File 'lib/fake_braintree/address.rb', line 24
def set_up_address(address_hash_from_params, options)
@address = {
"merchant_id" => options[:merchant_id],
"customer_id" => options[:customer_id],
}.merge(address_hash_from_params)
end
|