Sha256: 41119ec928d139bc13b11eae591e710182e39acb2aec998770067f0b3ee5944c

Contents?: true

Size: 956 Bytes

Versions: 6

Compression:

Stored size: 956 Bytes

Contents

module Workarea
  module Forter
    class Account
      attr_reader :order, :options

      def initialize(order, options = {})
        @order = order
        @options = options
      end

      # @return Hash
      def to_h
        return guest_account unless order.user_id.present?

        user_account
      end

      private

        def user_account
          user = Workarea::User.find(order.user_id)
            {
              firstName: user.first_name,
              lastName: user.last_name,
              email: user.email,
              accountId: user.id.to_s,
              created: user.created_at.to_i,
              lastLoginIP: user.ip_address
            }
        end

        def guest_account
          payment = Workarea::Payment.find(order.id)
          {
            firstName: payment.address.first_name,
            lastName: payment.address.last_name,
            email: order.email
          }
        end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
workarea-forter-1.3.2 app/services/workarea/forter/account.rb
workarea-forter-1.3.1 app/services/workarea/forter/account.rb
workarea-forter-1.3.0 app/services/workarea/forter/account.rb
workarea-forter-1.2.4 app/services/workarea/forter/account.rb
workarea-forter-1.2.3 app/services/workarea/forter/account.rb
workarea-forter-1.2.2 app/services/workarea/forter/account.rb