Class: SpreeCmCommissioner::Integrations::VireakBuntham::Resources::Location

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

Overview

Wraps a VET location returned by POST /destination/from.

Example payload:

{
  "id": "ce982b94fbb21ff7cd3825691ba56ba2",
  "name": "Phnom Penh (Japan Hospital Branch)",
  "address": "#29 St. 47, Songkat Sras Jork, Khan Donpenh",
  "lat": "11.580118",
  "long": "104.9201612"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

from_api_response

Constructor Details

#initialize(data) ⇒ Location

rubocop:disable Lint/MissingSuper



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

def initialize(data) # rubocop:disable Lint/MissingSuper
  @id = data['id']
  @name = data['name']
  @address = data['address']
  @lat = data['lat']
  @long = data['long']
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



13
14
15
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/location.rb', line 13

def address
  @address
end

#idObject

Returns the value of attribute id.



13
14
15
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/location.rb', line 13

def id
  @id
end

#latObject

Returns the value of attribute lat.



13
14
15
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/location.rb', line 13

def lat
  @lat
end

#longObject

Returns the value of attribute long.



13
14
15
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/location.rb', line 13

def long
  @long
end

#nameObject

Returns the value of attribute name.



13
14
15
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/location.rb', line 13

def name
  @name
end

Instance Method Details

#display_nameObject



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

def display_name
  [name, address].compact_blank.join(' - ')
end

#to_hObject



27
28
29
30
31
32
33
34
35
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/resources/location.rb', line 27

def to_h
  {
    id: id,
    name: name,
    address: address,
    lat: lat,
    long: long
  }
end