Class: GoogleMapsPlatform::GeolocationRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/google_maps_platform/models/geolocation_request.rb

Overview

The request body must be formatted as JSON. The following fields are supported, and all fields are optional.

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(home_mobile_country_code: SKIP, home_mobile_network_code: SKIP, radio_type: SKIP, carrier: SKIP, consider_ip: SKIP, cell_towers: SKIP, wifi_access_points: SKIP, additional_properties: nil) ⇒ GeolocationRequest

Returns a new instance of GeolocationRequest.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/google_maps_platform/models/geolocation_request.rb', line 78

def initialize(home_mobile_country_code: SKIP,
               home_mobile_network_code: SKIP, radio_type: SKIP,
               carrier: SKIP, consider_ip: SKIP, cell_towers: SKIP,
               wifi_access_points: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @home_mobile_country_code = home_mobile_country_code unless home_mobile_country_code == SKIP
  @home_mobile_network_code = home_mobile_network_code unless home_mobile_network_code == SKIP
  @radio_type = radio_type unless radio_type == SKIP
  @carrier = carrier unless carrier == SKIP
  @consider_ip = consider_ip unless consider_ip == SKIP
  @cell_towers = cell_towers unless cell_towers == SKIP
  @wifi_access_points = wifi_access_points unless wifi_access_points == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#carrierString

The carrier name.

Returns:

  • (String)


30
31
32
# File 'lib/google_maps_platform/models/geolocation_request.rb', line 30

def carrier
  @carrier
end

#cell_towersArray[CellTower]

The request body’s cellTowers array contains zero or more cell tower objects.

Returns:



41
42
43
# File 'lib/google_maps_platform/models/geolocation_request.rb', line 41

def cell_towers
  @cell_towers
end

#consider_ipString

Specifies whether to fall back to IP geolocation if wifi and cell tower signals are not available. Defaults to true. Set considerIp to false to disable fall back.

Returns:

  • (String)


36
37
38
# File 'lib/google_maps_platform/models/geolocation_request.rb', line 36

def consider_ip
  @consider_ip
end

#home_mobile_country_codeInteger

The cell tower’s Mobile Country Code (MCC).

Returns:

  • (Integer)


15
16
17
# File 'lib/google_maps_platform/models/geolocation_request.rb', line 15

def home_mobile_country_code
  @home_mobile_country_code
end

#home_mobile_network_codeInteger

The cell tower’s Mobile Network Code. This is the MNC for GSM and WCDMA; CDMA uses the System ID (SID).

Returns:

  • (Integer)


20
21
22
# File 'lib/google_maps_platform/models/geolocation_request.rb', line 20

def home_mobile_network_code
  @home_mobile_network_code
end

#radio_typeString

The mobile radio type. Supported values are lte, gsm, cdma, and wcdma. While this field is optional, it should be included if a value is available, for more accurate results.

Returns:

  • (String)


26
27
28
# File 'lib/google_maps_platform/models/geolocation_request.rb', line 26

def radio_type
  @radio_type
end

#wifi_access_pointsArray[WiFiAccessPoint]

An array of two or more WiFi access point objects.

Returns:



45
46
47
# File 'lib/google_maps_platform/models/geolocation_request.rb', line 45

def wifi_access_points
  @wifi_access_points
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/google_maps_platform/models/geolocation_request.rb', line 96

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  home_mobile_country_code =
    hash.key?('homeMobileCountryCode') ? hash['homeMobileCountryCode'] : SKIP
  home_mobile_network_code =
    hash.key?('homeMobileNetworkCode') ? hash['homeMobileNetworkCode'] : SKIP
  radio_type = hash.key?('radioType') ? hash['radioType'] : SKIP
  carrier = hash.key?('carrier') ? hash['carrier'] : SKIP
  consider_ip = hash.key?('considerIp') ? hash['considerIp'] : SKIP
  # Parameter is an array, so we need to iterate through it
  cell_towers = nil
  unless hash['cellTowers'].nil?
    cell_towers = []
    hash['cellTowers'].each do |structure|
      cell_towers << (CellTower.from_hash(structure) if structure)
    end
  end

  cell_towers = SKIP unless hash.key?('cellTowers')
  # Parameter is an array, so we need to iterate through it
  wifi_access_points = nil
  unless hash['wifiAccessPoints'].nil?
    wifi_access_points = []
    hash['wifiAccessPoints'].each do |structure|
      wifi_access_points << (WiFiAccessPoint.from_hash(structure) if structure)
    end
  end

  wifi_access_points = SKIP unless hash.key?('wifiAccessPoints')

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  GeolocationRequest.new(home_mobile_country_code: home_mobile_country_code,
                         home_mobile_network_code: home_mobile_network_code,
                         radio_type: radio_type,
                         carrier: carrier,
                         consider_ip: consider_ip,
                         cell_towers: cell_towers,
                         wifi_access_points: wifi_access_points,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/google_maps_platform/models/geolocation_request.rb', line 48

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['home_mobile_country_code'] = 'homeMobileCountryCode'
  @_hash['home_mobile_network_code'] = 'homeMobileNetworkCode'
  @_hash['radio_type'] = 'radioType'
  @_hash['carrier'] = 'carrier'
  @_hash['consider_ip'] = 'considerIp'
  @_hash['cell_towers'] = 'cellTowers'
  @_hash['wifi_access_points'] = 'wifiAccessPoints'
  @_hash
end

.nullablesObject

An array for nullable fields



74
75
76
# File 'lib/google_maps_platform/models/geolocation_request.rb', line 74

def self.nullables
  []
end

.optionalsObject

An array for optional fields



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/google_maps_platform/models/geolocation_request.rb', line 61

def self.optionals
  %w[
    home_mobile_country_code
    home_mobile_network_code
    radio_type
    carrier
    consider_ip
    cell_towers
    wifi_access_points
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



157
158
159
160
161
162
163
164
# File 'lib/google_maps_platform/models/geolocation_request.rb', line 157

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} home_mobile_country_code: #{@home_mobile_country_code.inspect},"\
  " home_mobile_network_code: #{@home_mobile_network_code.inspect}, radio_type:"\
  " #{@radio_type.inspect}, carrier: #{@carrier.inspect}, consider_ip:"\
  " #{@consider_ip.inspect}, cell_towers: #{@cell_towers.inspect}, wifi_access_points:"\
  " #{@wifi_access_points.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



147
148
149
150
151
152
153
154
# File 'lib/google_maps_platform/models/geolocation_request.rb', line 147

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} home_mobile_country_code: #{@home_mobile_country_code},"\
  " home_mobile_network_code: #{@home_mobile_network_code}, radio_type: #{@radio_type},"\
  " carrier: #{@carrier}, consider_ip: #{@consider_ip}, cell_towers: #{@cell_towers},"\
  " wifi_access_points: #{@wifi_access_points}, additional_properties:"\
  " #{@additional_properties}>"
end