Class: GoogleMapsPlatform::TimeZoneResponse

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

Overview

TimeZoneResponse 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:, dst_offset: SKIP, raw_offset: SKIP, time_zone_id: SKIP, time_zone_name: SKIP, error_message: SKIP, additional_properties: nil) ⇒ TimeZoneResponse



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/google_maps_platform/models/time_zone_response.rb', line 93

def initialize(status:, dst_offset: SKIP, raw_offset: SKIP,
               time_zone_id: SKIP, time_zone_name: SKIP,
               error_message: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @dst_offset = dst_offset unless dst_offset == SKIP
  @raw_offset = raw_offset unless raw_offset == SKIP
  @time_zone_id = time_zone_id unless time_zone_id == SKIP
  @time_zone_name = time_zone_name unless time_zone_name == SKIP
  @status = status
  @error_message = error_message unless error_message == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#dst_offsetFloat

The offset for daylight-savings time in seconds. This will be zero if the time zone is not in Daylight Savings Time during the specified timestamp.



16
17
18
# File 'lib/google_maps_platform/models/time_zone_response.rb', line 16

def dst_offset
  @dst_offset
end

#error_messageString

Detailed information about the reasons behind the given status code. Included if status other than Ok.



63
64
65
# File 'lib/google_maps_platform/models/time_zone_response.rb', line 63

def error_message
  @error_message
end

#raw_offsetFloat

The offset from UTC (in seconds) for the given location. This does not take into effect daylight savings.



21
22
23
# File 'lib/google_maps_platform/models/time_zone_response.rb', line 21

def raw_offset
  @raw_offset
end

#statusTimeZoneStatus

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

  • OK indicates that the request was successful.

  • INVALID_REQUEST indicates that the request was malformed.

  • OVER_DAILY_LIMIT indicates any of the following:

    • The API key is missing or invalid.

    • Billing has not been enabled on your account.

    • A self-imposed usage cap has been exceeded.

    • The provided method of payment is no longer valid (for example, a

credit card has expired).

  • OVER_QUERY_LIMIT indicates the requestor has exceeded quota.

  • REQUEST_DENIED indicates that the API did not complete the request.

Confirm that the request was sent over HTTPS instead of HTTP.

  • UNKNOWN_ERROR indicates an unknown error.

  • ZERO_RESULTS indicates that no time zone data could be found for the

specified position or time. Confirm that the request is for a location on land, and not over water.



58
59
60
# File 'lib/google_maps_platform/models/time_zone_response.rb', line 58

def status
  @status
end

#time_zone_idString

a string containing the ID of the time zone, such as “America/Los_Angeles” or “Australia/Sydney”. These IDs are defined by [Unicode Common Locale Data Repository (CLDR) project](cldr.unicode.org/), and currently available in file timezone.xml. When a timezone has several IDs, the canonical one is returned. In xml responses, this is the first alias of each timezone. For example, “Asia/Calcutta” is returned, not “Asia/Kolkata”.



31
32
33
# File 'lib/google_maps_platform/models/time_zone_response.rb', line 31

def time_zone_id
  @time_zone_id
end

#time_zone_nameString

The long form name of the time zone. This field will be localized if the language parameter is set. eg. ‘Pacific Daylight Time` or `Australian Eastern Daylight Time`.



37
38
39
# File 'lib/google_maps_platform/models/time_zone_response.rb', line 37

def time_zone_name
  @time_zone_name
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/google_maps_platform/models/time_zone_response.rb', line 109

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  status = hash.key?('status') ? hash['status'] : nil
  dst_offset = hash.key?('dstOffset') ? hash['dstOffset'] : SKIP
  raw_offset = hash.key?('rawOffset') ? hash['rawOffset'] : SKIP
  time_zone_id = hash.key?('timeZoneId') ? hash['timeZoneId'] : SKIP
  time_zone_name = hash.key?('timeZoneName') ? hash['timeZoneName'] : SKIP
  error_message = hash.key?('errorMessage') ? hash['errorMessage'] : 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.
  TimeZoneResponse.new(status: status,
                       dst_offset: dst_offset,
                       raw_offset: raw_offset,
                       time_zone_id: time_zone_id,
                       time_zone_name: time_zone_name,
                       error_message: error_message,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['dst_offset'] = 'dstOffset'
  @_hash['raw_offset'] = 'rawOffset'
  @_hash['time_zone_id'] = 'timeZoneId'
  @_hash['time_zone_name'] = 'timeZoneName'
  @_hash['status'] = 'status'
  @_hash['error_message'] = 'errorMessage'
  @_hash
end

.nullablesObject

An array for nullable fields



89
90
91
# File 'lib/google_maps_platform/models/time_zone_response.rb', line 89

def self.nullables
  []
end

.optionalsObject

An array for optional fields



78
79
80
81
82
83
84
85
86
# File 'lib/google_maps_platform/models/time_zone_response.rb', line 78

def self.optionals
  %w[
    dst_offset
    raw_offset
    time_zone_id
    time_zone_name
    error_message
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



146
147
148
149
150
151
152
# File 'lib/google_maps_platform/models/time_zone_response.rb', line 146

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} dst_offset: #{@dst_offset.inspect}, raw_offset: #{@raw_offset.inspect},"\
  " time_zone_id: #{@time_zone_id.inspect}, time_zone_name: #{@time_zone_name.inspect},"\
  " status: #{@status.inspect}, error_message: #{@error_message.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



138
139
140
141
142
143
# File 'lib/google_maps_platform/models/time_zone_response.rb', line 138

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} dst_offset: #{@dst_offset}, raw_offset: #{@raw_offset}, time_zone_id:"\
  " #{@time_zone_id}, time_zone_name: #{@time_zone_name}, status: #{@status}, error_message:"\
  " #{@error_message}, additional_properties: #{@additional_properties}>"
end