Class: ShellSmartPayApi::Loc

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

Overview

Object containing address details/elements

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(country = nil, ccode = nil, street = SKIP, pc = SKIP, city = SKIP, region = SKIP) ⇒ Loc

Returns a new instance of Loc.



64
65
66
67
68
69
70
71
72
# File 'lib/shell_smart_pay_api/models/loc.rb', line 64

def initialize(country = nil, ccode = nil, street = SKIP, pc = SKIP,
               city = SKIP, region = SKIP)
  @street = street unless street == SKIP
  @pc = pc unless pc == SKIP
  @city = city unless city == SKIP
  @region = region unless region == SKIP
  @country = country
  @ccode = ccode
end

Instance Attribute Details

#ccodeString

The two-letter ISO 3166 country code of the country the station is located within

Returns:

  • (String)


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

def ccode
  @ccode
end

#cityString

The city the station is located within

Returns:

  • (String)


22
23
24
# File 'lib/shell_smart_pay_api/models/loc.rb', line 22

def city
  @city
end

#countryString

The name of the country (in English) the station is located within

Returns:

  • (String)


30
31
32
# File 'lib/shell_smart_pay_api/models/loc.rb', line 30

def country
  @country
end

#pcString

The station’s postcode

Returns:

  • (String)


18
19
20
# File 'lib/shell_smart_pay_api/models/loc.rb', line 18

def pc
  @pc
end

#regionString

The region the station is located within

Returns:

  • (String)


26
27
28
# File 'lib/shell_smart_pay_api/models/loc.rb', line 26

def region
  @region
end

#streetString

The station’s full street address, including building number

Returns:

  • (String)


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

def street
  @street
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/shell_smart_pay_api/models/loc.rb', line 75

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  country = hash.key?('country') ? hash['country'] : nil
  ccode = hash.key?('ccode') ? hash['ccode'] : nil
  street = hash.key?('street') ? hash['street'] : SKIP
  pc = hash.key?('pc') ? hash['pc'] : SKIP
  city = hash.key?('city') ? hash['city'] : SKIP
  region = hash.key?('region') ? hash['region'] : SKIP

  # Create object from extracted values.

  Loc.new(country,
          ccode,
          street,
          pc,
          city,
          region)
end

.namesObject

A mapping from model property names to API property names.



38
39
40
41
42
43
44
45
46
47
# File 'lib/shell_smart_pay_api/models/loc.rb', line 38

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['street'] = 'street'
  @_hash['pc'] = 'pc'
  @_hash['city'] = 'city'
  @_hash['region'] = 'region'
  @_hash['country'] = 'country'
  @_hash['ccode'] = 'ccode'
  @_hash
end

.nullablesObject

An array for nullable fields



60
61
62
# File 'lib/shell_smart_pay_api/models/loc.rb', line 60

def self.nullables
  []
end

.optionalsObject

An array for optional fields



50
51
52
53
54
55
56
57
# File 'lib/shell_smart_pay_api/models/loc.rb', line 50

def self.optionals
  %w[
    street
    pc
    city
    region
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



103
104
105
106
107
# File 'lib/shell_smart_pay_api/models/loc.rb', line 103

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} street: #{@street.inspect}, pc: #{@pc.inspect}, city: #{@city.inspect},"\
  " region: #{@region.inspect}, country: #{@country.inspect}, ccode: #{@ccode.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



96
97
98
99
100
# File 'lib/shell_smart_pay_api/models/loc.rb', line 96

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} street: #{@street}, pc: #{@pc}, city: #{@city}, region: #{@region},"\
  " country: #{@country}, ccode: #{@ccode}>"
end