Class: ShellSmartPayApi::Datum

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/shell_smart_pay_api/models/datum.rb

Overview

Datum Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(id = SKIP, type = SKIP, name = SKIP, addr = SKIP, lat = SKIP, lon = SKIP, amen = SKIP, fuel = SKIP, loc = SKIP, mpp_station_id = SKIP, double_site_id = SKIP, opening_hours = SKIP, telephone = SKIP, authorisation_code = SKIP, mp_preauth = SKIP) ⇒ Datum

Returns a new instance of Datum.



169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/shell_smart_pay_api/models/datum.rb', line 169

def initialize(id = SKIP, type = SKIP, name = SKIP, addr = SKIP, lat = SKIP,
               lon = SKIP, amen = SKIP, fuel = SKIP, loc = SKIP,
               mpp_station_id = SKIP, double_site_id = SKIP,
               opening_hours = SKIP, telephone = SKIP,
               authorisation_code = SKIP, mp_preauth = SKIP)
  @id = id unless id == SKIP
  @type = type unless type == SKIP
  @name = name unless name == SKIP
  @addr = addr unless addr == SKIP
  @lat = lat unless lat == SKIP
  @lon = lon unless lon == SKIP
  @amen = amen unless amen == SKIP
  @fuel = fuel unless fuel == SKIP
  @loc = loc unless loc == SKIP
  @mpp_station_id = mpp_station_id unless mpp_station_id == SKIP
  @double_site_id = double_site_id unless double_site_id == SKIP
  @opening_hours = opening_hours unless opening_hours == SKIP
  @telephone = telephone unless telephone == SKIP
  @authorisation_code = authorisation_code unless authorisation_code == SKIP
  @mp_preauth = mp_preauth unless mp_preauth == SKIP
end

Instance Attribute Details

#addrString

The side address as a concatenation of address information

Returns:

  • (String)


35
36
37
# File 'lib/shell_smart_pay_api/models/datum.rb', line 35

def addr
  @addr
end

#amenArray[Integer]

An array of amenities available at the station (see above for complete list)

Returns:

  • (Array[Integer])


48
49
50
# File 'lib/shell_smart_pay_api/models/datum.rb', line 48

def amen
  @amen
end

#authorisation_codeString

Station’s authorisation code

Returns:

  • (String)


116
117
118
# File 'lib/shell_smart_pay_api/models/datum.rb', line 116

def authorisation_code
  @authorisation_code
end

#double_site_idString

The Mobile Payment Platform recognises a user being located at a Shell Station if their GPS is within 300m of a Shell station. Some locations will return multiple Shell Stations within a 300 meter radius. This is an issue for Mobile Payments as it needs to accurately identify the station the Customer is located at to ensure the correct pump is released In Germany such locations have been identified and each Station has been assigned a unique letter (e.g. A, B, C). These letters are clearly visible at the stations. If a Mobile Payments user is located at such a location, they will need to identify the Station by identifying and specifying the Station’s corresponding letter as part of the refuelling journey. The double_site_id is used to store the Stations unique letter/ID value. It’s only populated if/when 1 or more stations are within 300m from this station.

Returns:

  • (String)


103
104
105
# File 'lib/shell_smart_pay_api/models/datum.rb', line 103

def double_site_id
  @double_site_id
end

#fuelArray[Integer]

An array of fuels* available at the station.

Global Product Group names:
*  8 = CNG
*  10 = Premium Gasoline
*  11 = Premium Diesel
*  12 = Fuelsave Midgrade Gasoline
*  13 = Fuelsave Regular Diesel
*  14 = Midgrade Gasoline
*  15 = Low Octane gasoline
*  16 = Regular Diesel
*  17 = Autogas LPG
*  18 = Auto/RV Propane
*  20 = Hydrogen
*  21 = Kerosene
*  22 = Super Premium Gasoline
*  23 = Unleaded Super
*  24 = Truck Diesel
*  25 = Super98
*  26 = GTL
*  27 = Fuelsave 98
*  28 = LNG
*  29 = DieselFit
*  30 = Shell Recharge

*An external mapping table may need to be maintained if it is required to

display true fuel product names (as visible on the site)

Returns:

  • (Array[Integer])


77
78
79
# File 'lib/shell_smart_pay_api/models/datum.rb', line 77

def fuel
  @fuel
end

#idString

The station’s unique site identifier – this must be ignored

Returns:

  • (String)


14
15
16
# File 'lib/shell_smart_pay_api/models/datum.rb', line 14

def id
  @id
end

#latFloat

The site’s latitude

Returns:

  • (Float)


39
40
41
# File 'lib/shell_smart_pay_api/models/datum.rb', line 39

def lat
  @lat
end

#locLoc

Object containing address details/elements

Returns:



81
82
83
# File 'lib/shell_smart_pay_api/models/datum.rb', line 81

def loc
  @loc
end

#lonFloat

The site’s longitude

Returns:

  • (Float)


43
44
45
# File 'lib/shell_smart_pay_api/models/datum.rb', line 43

def lon
  @lon
end

#mp_preauthInteger

Station’s mobile payment preauthorisation value

Returns:

  • (Integer)


120
121
122
# File 'lib/shell_smart_pay_api/models/datum.rb', line 120

def mp_preauth
  @mp_preauth
end

#mpp_station_idString

This is the 5-digit Shell Station ID. Leading ‘0’ should be dropped and only last four digits, should be used. E.G. for ‘00123’, only ‘0123’should be used and for ‘04567’ only ‘4567’ should be used.

Returns:

  • (String)


87
88
89
# File 'lib/shell_smart_pay_api/models/datum.rb', line 87

def mpp_station_id
  @mpp_station_id
end

#nameString

The name of the site

Returns:

  • (String)


31
32
33
# File 'lib/shell_smart_pay_api/models/datum.rb', line 31

def name
  @name
end

#opening_hoursArray[OpeningHour]

An Array of the station’s opening hours. This may have opening and closing times in hours, minutes and the day of the week.

Returns:



108
109
110
# File 'lib/shell_smart_pay_api/models/datum.rb', line 108

def opening_hours
  @opening_hours
end

#telephoneString

Station’s contact telephone number

Returns:

  • (String)


112
113
114
# File 'lib/shell_smart_pay_api/models/datum.rb', line 112

def telephone
  @telephone
end

#typeInteger

All fuel stations are of at least one Type, indicating whether it is Shell-branded or not, and if the station can be used by trucks. Note that a station can have more than one Type (e.g. Shell retail sites (Type=0) can also be truck friendly (Type=2)). Type values are as follows:

  • 0 = Shell owned/branded stations that are not also Type=2 or Type=3

  • 1 = Partner stations accepting Shell Card

  • 2 = Shell owned/branded stations that are truck friendly but not Type=3

  • 3 = Shell owned/branded stations that are truck only

Returns:

  • (Integer)


27
28
29
# File 'lib/shell_smart_pay_api/models/datum.rb', line 27

def type
  @type
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/shell_smart_pay_api/models/datum.rb', line 192

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  id = hash.key?('id') ? hash['id'] : SKIP
  type = hash.key?('type') ? hash['type'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP
  addr = hash.key?('addr') ? hash['addr'] : SKIP
  lat = hash.key?('lat') ? hash['lat'] : SKIP
  lon = hash.key?('lon') ? hash['lon'] : SKIP
  amen = hash.key?('amen') ? hash['amen'] : SKIP
  fuel = hash.key?('fuel') ? hash['fuel'] : SKIP
  loc = Loc.from_hash(hash['loc']) if hash['loc']
  mpp_station_id =
    hash.key?('mpp_station_id') ? hash['mpp_station_id'] : SKIP
  double_site_id =
    hash.key?('double_site_id') ? hash['double_site_id'] : SKIP
  # Parameter is an array, so we need to iterate through it

  opening_hours = nil
  unless hash['opening_hours'].nil?
    opening_hours = []
    hash['opening_hours'].each do |structure|
      opening_hours << (OpeningHour.from_hash(structure) if structure)
    end
  end

  opening_hours = SKIP unless hash.key?('opening_hours')
  telephone = hash.key?('telephone') ? hash['telephone'] : SKIP
  authorisation_code =
    hash.key?('authorisation_code') ? hash['authorisation_code'] : SKIP
  mp_preauth = hash.key?('mp_preauth') ? hash['mp_preauth'] : SKIP

  # Create object from extracted values.

  Datum.new(id,
            type,
            name,
            addr,
            lat,
            lon,
            amen,
            fuel,
            loc,
            mpp_station_id,
            double_site_id,
            opening_hours,
            telephone,
            authorisation_code,
            mp_preauth)
end

.namesObject

A mapping from model property names to API property names.



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/shell_smart_pay_api/models/datum.rb', line 123

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['type'] = 'type'
  @_hash['name'] = 'name'
  @_hash['addr'] = 'addr'
  @_hash['lat'] = 'lat'
  @_hash['lon'] = 'lon'
  @_hash['amen'] = 'amen'
  @_hash['fuel'] = 'fuel'
  @_hash['loc'] = 'loc'
  @_hash['mpp_station_id'] = 'mpp_station_id'
  @_hash['double_site_id'] = 'double_site_id'
  @_hash['opening_hours'] = 'opening_hours'
  @_hash['telephone'] = 'telephone'
  @_hash['authorisation_code'] = 'authorisation_code'
  @_hash['mp_preauth'] = 'mp_preauth'
  @_hash
end

.nullablesObject

An array for nullable fields



165
166
167
# File 'lib/shell_smart_pay_api/models/datum.rb', line 165

def self.nullables
  []
end

.optionalsObject

An array for optional fields



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/shell_smart_pay_api/models/datum.rb', line 144

def self.optionals
  %w[
    id
    type
    name
    addr
    lat
    lon
    amen
    fuel
    loc
    mpp_station_id
    double_site_id
    opening_hours
    telephone
    authorisation_code
    mp_preauth
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



253
254
255
256
257
258
259
260
261
# File 'lib/shell_smart_pay_api/models/datum.rb', line 253

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, type: #{@type.inspect}, name: #{@name.inspect}, addr:"\
  " #{@addr.inspect}, lat: #{@lat.inspect}, lon: #{@lon.inspect}, amen: #{@amen.inspect},"\
  " fuel: #{@fuel.inspect}, loc: #{@loc.inspect}, mpp_station_id: #{@mpp_station_id.inspect},"\
  " double_site_id: #{@double_site_id.inspect}, opening_hours: #{@opening_hours.inspect},"\
  " telephone: #{@telephone.inspect}, authorisation_code: #{@authorisation_code.inspect},"\
  " mp_preauth: #{@mp_preauth.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



243
244
245
246
247
248
249
250
# File 'lib/shell_smart_pay_api/models/datum.rb', line 243

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, type: #{@type}, name: #{@name}, addr: #{@addr}, lat: #{@lat},"\
  " lon: #{@lon}, amen: #{@amen}, fuel: #{@fuel}, loc: #{@loc}, mpp_station_id:"\
  " #{@mpp_station_id}, double_site_id: #{@double_site_id}, opening_hours: #{@opening_hours},"\
  " telephone: #{@telephone}, authorisation_code: #{@authorisation_code}, mp_preauth:"\
  " #{@mp_preauth}>"
end