Class: Spree::Api::V3::Admin::DashboardAnalyticsSerializer

Inherits:
Object
  • Object
show all
Defined in:
app/serializers/spree/api/v3/admin/dashboard_analytics_serializer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store:, currency:, time_range:, params: {}) ⇒ DashboardAnalyticsSerializer

Returns a new instance of DashboardAnalyticsSerializer.



8
9
10
11
12
13
# File 'app/serializers/spree/api/v3/admin/dashboard_analytics_serializer.rb', line 8

def initialize(store:, currency:, time_range:, params: {})
  @store = store
  @currency = currency
  @time_range = time_range
  @params = params
end

Instance Attribute Details

#currencyObject (readonly)

Returns the value of attribute currency.



6
7
8
# File 'app/serializers/spree/api/v3/admin/dashboard_analytics_serializer.rb', line 6

def currency
  @currency
end

#paramsObject (readonly)

Returns the value of attribute params.



6
7
8
# File 'app/serializers/spree/api/v3/admin/dashboard_analytics_serializer.rb', line 6

def params
  @params
end

#storeObject (readonly)

Returns the value of attribute store.



6
7
8
# File 'app/serializers/spree/api/v3/admin/dashboard_analytics_serializer.rb', line 6

def store
  @store
end

#time_rangeObject (readonly)

Returns the value of attribute time_range.



6
7
8
# File 'app/serializers/spree/api/v3/admin/dashboard_analytics_serializer.rb', line 6

def time_range
  @time_range
end

Instance Method Details

#to_hObject



15
16
17
18
19
20
21
22
23
24
# File 'app/serializers/spree/api/v3/admin/dashboard_analytics_serializer.rb', line 15

def to_h
  {
    currency: currency,
    date_from: time_range.first.iso8601,
    date_to: time_range.last.iso8601,
    summary: summary,
    chart_data: chart_data,
    top_products: top_products
  }
end