Sha256: 69f6f7b0cd0f5add66db975bf94ead0480aad882a34d1b596b2e31ffce1d2e02
Contents?: true
Size: 1.03 KB
Versions: 6
Compression:
Stored size: 1.03 KB
Contents
module Spree module Api module V2 module Platform class UserSerializer < BaseSerializer set_type :user attributes :email, :created_at, :updated_at attribute :average_order_value do |user, params| price_stats(user.report_values_for(:average_order_value, params[:store])) end attribute :lifetime_value do |user, params| price_stats(user.report_values_for(:lifetime_value, params[:store])) end attribute :store_credits do |user, params| price_stats(user.available_store_credits(params[:store])) end has_one :bill_address, record_type: :address, serializer: :address has_one :ship_address, record_type: :address, serializer: :address def self.price_stats(stats) stats.map { |value| { currency: value.currency.to_s, amount: value.money.to_s } } end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems