Class: GoogleMapsPlatform::StreetViewResponse

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

Overview

StreetViewResponse 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(status:, copyright: SKIP, date: SKIP, location: SKIP, pano_id: SKIP, additional_properties: nil) ⇒ StreetViewResponse

Returns a new instance of StreetViewResponse.



80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/google_maps_platform/models/street_view_response.rb', line 80

def initialize(status:, copyright: SKIP, date: SKIP, location: SKIP,
               pano_id: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @copyright = copyright unless copyright == SKIP
  @date = date unless date == SKIP
  @location = location unless location == SKIP
  @pano_id = pano_id unless pano_id == SKIP
  @status = status
  @additional_properties = additional_properties
end

Instance Attribute Details

Contains the copyright notices associated with this panorama.

Returns:

  • (String)


14
15
16
# File 'lib/google_maps_platform/models/street_view_response.rb', line 14

def copyright
  @copyright
end

#dateString

A string indicating year and month that the panorama was captured.

Returns:

  • (String)


18
19
20
# File 'lib/google_maps_platform/models/street_view_response.rb', line 18

def date
  @date
end

#locationLatLngLiteral

An object describing a specific location with Latitude and Longitude in decimal degrees.

Returns:



23
24
25
# File 'lib/google_maps_platform/models/street_view_response.rb', line 23

def location
  @location
end

#pano_idString

A specific panorama ID. These are generally stable, though panoramas may change ID over time as imagery is refreshed.

Returns:

  • (String)


28
29
30
# File 'lib/google_maps_platform/models/street_view_response.rb', line 28

def pano_id
  @pano_id
end

#statusStreetViewStatus

The status field within the Streetview Metadata response object contains the status of the request. The status field may contain the following values:

  • OK indicates that no errors occurred; a panorama is found and metadata

is returned.

  • INVALID_REQUEST indicates that the request was malformed.

  • NOT_FOUND indicates that the address string provided in the location

parameter could not be found. This may occur if a non-existent address is given.

  • ZERO_RESULTS indicates that no panorama could be found near the

provided location. This may occur if a non-existent or invalid pano id is given.

  • OVER_QUERY_LIMIT indicates the requestor has exceeded quota.

  • REQUEST_DENIED indicates that your request was denied. This may occur

if you did not [authorize](developers.google.com/maps/documentation/streetview/ge t-api-key) your request, or if the Street View Static API is not activated in the Google Cloud Console project containing your API key.

  • UNKNOWN_ERROR indicates that the request could not be processed due to

a server error. This is often a temporary status. The request may succeed if you try again

Returns:



52
53
54
# File 'lib/google_maps_platform/models/street_view_response.rb', line 52

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/google_maps_platform/models/street_view_response.rb', line 94

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  status = hash.key?('status') ? hash['status'] : nil
  copyright = hash.key?('copyright') ? hash['copyright'] : SKIP
  date = hash.key?('date') ? hash['date'] : SKIP
  location = LatLngLiteral.from_hash(hash['location']) if hash['location']
  pano_id = hash.key?('pano_id') ? hash['pano_id'] : SKIP

  # 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.
  StreetViewResponse.new(status: status,
                         copyright: copyright,
                         date: date,
                         location: location,
                         pano_id: pano_id,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



55
56
57
58
59
60
61
62
63
# File 'lib/google_maps_platform/models/street_view_response.rb', line 55

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['copyright'] = 'copyright'
  @_hash['date'] = 'date'
  @_hash['location'] = 'location'
  @_hash['pano_id'] = 'pano_id'
  @_hash['status'] = 'status'
  @_hash
end

.nullablesObject

An array for nullable fields



76
77
78
# File 'lib/google_maps_platform/models/street_view_response.rb', line 76

def self.nullables
  []
end

.optionalsObject

An array for optional fields



66
67
68
69
70
71
72
73
# File 'lib/google_maps_platform/models/street_view_response.rb', line 66

def self.optionals
  %w[
    copyright
    date
    location
    pano_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



128
129
130
131
132
133
# File 'lib/google_maps_platform/models/street_view_response.rb', line 128

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} copyright: #{@copyright.inspect}, date: #{@date.inspect}, location:"\
  " #{@location.inspect}, pano_id: #{@pano_id.inspect}, status: #{@status.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



121
122
123
124
125
# File 'lib/google_maps_platform/models/street_view_response.rb', line 121

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} copyright: #{@copyright}, date: #{@date}, location: #{@location}, pano_id:"\
  " #{@pano_id}, status: #{@status}, additional_properties: #{@additional_properties}>"
end