Sha256: 4102d19f1e73a1fb90f9e61c1ba573553b523f01e5dd4dc9a12610c03000908b
Contents?: true
Size: 1.12 KB
Versions: 3
Compression:
Stored size: 1.12 KB
Contents
module Spree module Api module V2 module Platform class UserSerializer < BaseSerializer set_type :user attributes :email, :first_name, :last_name, :created_at, :updated_at, :public_metadata, :private_metadata 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 has_many :vendors 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
3 entries across 3 versions & 2 rubygems