Class: SpreeCmCommissioner::Integrations::BookMeBusV1::Resources::Location

Inherits:
Base
  • Object
show all
Defined in:
app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

from_json_api, from_json_api_item, from_json_api_single

Constructor Details

#initialize(attributes = {}) ⇒ Location

Returns a new instance of Location.



17
18
19
20
21
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb', line 17

def initialize(attributes = {})
  super(attributes)

  @photo = attributes['photo'] if attributes['photo'].is_a?(Hash)
end

Instance Attribute Details

#abbreviationObject

Returns the value of attribute abbreviation.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb', line 3

def abbreviation
  @abbreviation
end

#city_tel_codeObject

Returns the value of attribute city_tel_code.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb', line 3

def city_tel_code
  @city_tel_code
end

#country_codeObject

Returns the value of attribute country_code.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb', line 3

def country_code
  @country_code
end

#country_nameObject

Returns the value of attribute country_name.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb', line 3

def country_name
  @country_name
end

#hits_destinationObject

Returns the value of attribute hits_destination.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb', line 3

def hits_destination
  @hits_destination
end

#hits_originObject

Returns the value of attribute hits_origin.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb', line 3

def hits_origin
  @hits_origin
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb', line 3

def id
  @id
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb', line 3

def name
  @name
end

#name_khmerObject

Returns the value of attribute name_khmer.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb', line 3

def name_khmer
  @name_khmer
end

#name_lowerObject

Returns the value of attribute name_lower.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb', line 3

def name_lower
  @name_lower
end

#photoObject

Returns the value of attribute photo.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb', line 3

def photo
  @photo
end

#slugObject

Returns the value of attribute slug.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb', line 3

def slug
  @slug
end

#typeObject

Returns the value of attribute type.



3
4
5
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb', line 3

def type
  @type
end

Instance Method Details

#display_nameObject



31
32
33
34
35
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb', line 31

def display_name
  return name if name_khmer.blank?

  "#{name} (#{name_khmer})"
end

#photo_standardObject



27
28
29
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb', line 27

def photo_standard
  @photo&.dig('standard')
end

#photo_thumbObject



23
24
25
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb', line 23

def photo_thumb
  @photo&.dig('thumb')
end

#to_hObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/location.rb', line 37

def to_h
  {
    id: id,
    type: type,
    name: name,
    name_lower: name_lower,
    abbreviation: abbreviation,
    city_tel_code: city_tel_code,
    photo: photo,
    name_khmer: name_khmer,
    country_code: country_code,
    country_name: country_name,
    hits_origin: hits_origin,
    hits_destination: hits_destination,
    slug: slug
  }.compact
end