Class: Api::V5::SearchOptionSerializer

Inherits:
BaseSerializer show all
Defined in:
app/serializers/api/v5/search_option_serializer.rb

Instance Method Summary collapse

Methods inherited from BaseSerializer

#full_attachment_url, #safe_translation_attr

Methods inherited from ApplicationSerializer

decorate_attributes, decorator, #object_cache_key

Instance Method Details

#per_pack(object) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/serializers/api/v5/search_option_serializer.rb', line 32

def per_pack(object)
  if object.name == 'Singapore'
    [
      { "label": I18n.t('under_price', locale: :sg, price: 60), "value": 60 },
      { "label": I18n.t('under_price', locale: :sg, price: 250), "value": 250 },
      { "label": I18n.t('under_price', locale: :sg, price: 500), "value": 500 },
    ]
  elsif I18n.locale == :en
    [
      { "label": I18n.t('under_price', price: '1,000฿'), "value": 1000 },
      { "label": I18n.t('under_price', price: '5,000฿'), "value": 5000 },
      { "label": I18n.t('under_price', price: '10,000฿'), "value": 10_000 },
    ]
  else
    [
      { "label": I18n.t('under_price', price: '1,000'), "value": 1000 },
      { "label": I18n.t('under_price', price: '5,000'), "value": 5000 },
      { "label": I18n.t('under_price', price: '10,000'), "value": 10_000 },
    ]
  end
end

#per_person(object) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/serializers/api/v5/search_option_serializer.rb', line 6

def per_person(object)
  if object.name == 'Singapore'
    [
      { "label": I18n.t('under_price', locale: :sg, price: 30), "value": 30 },
      { "label": I18n.t('under_price', locale: :sg, price: 70), "value": 70 },
      { "label": I18n.t('under_price', locale: :sg, price: 140), "value": 140 },
    ]
  elsif I18n.locale == :en
    [
      { "label": I18n.t('under_price', price: '500฿'), "value": 500 },
      { "label": I18n.t('under_price', price: '1,000฿'), "value": 1000 },
      { "label": I18n.t('under_price', price: '2,000฿'), "value": 2000 },
    ]
  else
    [
      { "label": I18n.t('under_price', price: '500'), "value": 500 },
      { "label": I18n.t('under_price', price: '1,000'), "value": 1000 },
      { "label": I18n.t('under_price', price: '2,000'), "value": 2000 },
    ]
  end
end