Sha256: b8f82d535e3255e5e271f26e69fd902b725327314c6785eeb20c9dad77412f6a

Contents?: true

Size: 730 Bytes

Versions: 2

Compression:

Stored size: 730 Bytes

Contents

module Workarea
  module GlobalE
    class CartUserDetails
      attr_reader :user

      def initialize(user)
        @user = user
      end

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

      # Internal User identifier on the Merchant’s site.
      #
      # @return [String]
      #
      def user_id
        user.id.to_s
      end

      # All available addresses taken from the registered customer address book
      #
      # @return [Array<Workarea::GlobalE::AddressDetails>]
      #
      def address_details
        @address_details ||= user.addresses.map { |address| AddressDetails.new user, address }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-global_e-1.3.0 app/services/workarea/global_e/cart_user_details.rb
workarea-global_e-1.2.1 app/services/workarea/global_e/cart_user_details.rb