Class: Workarea::GlobalE::CartUserDetails

Inherits:
Object
  • Object
show all
Defined in:
app/services/workarea/global_e/cart_user_details.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ CartUserDetails

Returns a new instance of CartUserDetails.



6
7
8
# File 'app/services/workarea/global_e/cart_user_details.rb', line 6

def initialize(user)
  @user = user
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



4
5
6
# File 'app/services/workarea/global_e/cart_user_details.rb', line 4

def user
  @user
end

Instance Method Details

#address_detailsArray<Workarea::GlobalE::AddressDetails>

All available addresses taken from the registered customer address book



29
30
31
# File 'app/services/workarea/global_e/cart_user_details.rb', line 29

def address_details
  @address_details ||= user.addresses.map { |address| AddressDetails.new user, address }
end

#as_json(*args) ⇒ Object



10
11
12
13
14
15
# File 'app/services/workarea/global_e/cart_user_details.rb', line 10

def as_json(*args)
  {
    UserId: user_id,
    AddressDetails: address_details
  }.compact
end

#user_idString

Internal User identifier on the Merchant’s site.

Returns:

  • (String)


21
22
23
# File 'app/services/workarea/global_e/cart_user_details.rb', line 21

def user_id
  user.id.to_s
end