airthings 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,237 @@
1
+ # frozen_string_literal: true
2
+
3
+ # #Airthings API
4
+ #
5
+ # No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6
+ #
7
+ # The version of the OpenAPI document: v1
8
+ #
9
+ # Generated by: https://openapi-generator.tech
10
+ # OpenAPI Generator version: 6.2.0
11
+ #
12
+
13
+ require "date"
14
+ require "time"
15
+
16
+ module Airthings
17
+ class DeviceSimpleResponse
18
+ attr_accessor :id, :device_type, :segment
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ id: :id,
24
+ device_type: :deviceType,
25
+ segment: :segment
26
+ }
27
+ end
28
+
29
+ # Returns all the JSON keys this model knows about
30
+ def self.acceptable_attributes
31
+ attribute_map.values
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.openapi_types
36
+ {
37
+ id: :String,
38
+ device_type: :DeviceType,
39
+ segment: :SegmentSimpleResponse
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new([])
46
+ end
47
+
48
+ # Initializes the object
49
+ # @param [Hash] attributes Model attributes in the form of hash
50
+ def initialize(attributes = {})
51
+ unless attributes.is_a?(Hash)
52
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Airthings::DeviceSimpleResponse` initialize method"
53
+ end
54
+
55
+ # check to see if the attribute exists and convert string to symbol for hash key
56
+ attributes = attributes.each_with_object({}) do |(k, v), h|
57
+ unless self.class.attribute_map.key?(k.to_sym)
58
+ raise ArgumentError, "`#{k}` is not a valid attribute in `Airthings::DeviceSimpleResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
59
+ end
60
+
61
+ h[k.to_sym] = v
62
+ end
63
+
64
+ self.id = attributes[:id] if attributes.key?(:id)
65
+
66
+ self.device_type = attributes[:device_type] if attributes.key?(:device_type)
67
+
68
+ self.segment = attributes[:segment] if attributes.key?(:segment)
69
+ end
70
+
71
+ # Show invalid properties with the reasons. Usually used together with valid?
72
+ # @return Array for valid properties with the reasons
73
+ def list_invalid_properties
74
+ invalid_properties = []
75
+ invalid_properties.push('invalid value for "id", id cannot be nil.') if @id.nil?
76
+
77
+ invalid_properties.push('invalid value for "device_type", device_type cannot be nil.') if @device_type.nil?
78
+
79
+ invalid_properties.push('invalid value for "segment", segment cannot be nil.') if @segment.nil?
80
+
81
+ invalid_properties
82
+ end
83
+
84
+ # Check to see if the all the properties in the model are valid
85
+ # @return true if the model is valid
86
+ def valid?
87
+ return false if @id.nil?
88
+ return false if @device_type.nil?
89
+ return false if @segment.nil?
90
+
91
+ true
92
+ end
93
+
94
+ # Checks equality by comparing each attribute.
95
+ # @param [Object] Object to be compared
96
+ def ==(other)
97
+ return true if equal?(other)
98
+
99
+ self.class == other.class &&
100
+ id == other.id &&
101
+ device_type == other.device_type &&
102
+ segment == other.segment
103
+ end
104
+
105
+ # @see the `==` method
106
+ # @param [Object] Object to be compared
107
+ def eql?(other)
108
+ self == other
109
+ end
110
+
111
+ # Calculates hash code according to all attributes.
112
+ # @return [Integer] Hash code
113
+ def hash
114
+ [id, device_type, segment].hash
115
+ end
116
+
117
+ # Builds the object from hash
118
+ # @param [Hash] attributes Model attributes in the form of hash
119
+ # @return [Object] Returns the model itself
120
+ def self.build_from_hash(attributes)
121
+ new.build_from_hash(attributes)
122
+ end
123
+
124
+ # Builds the object from hash
125
+ # @param [Hash] attributes Model attributes in the form of hash
126
+ # @return [Object] Returns the model itself
127
+ def build_from_hash(attributes)
128
+ return nil unless attributes.is_a?(Hash)
129
+
130
+ attributes = attributes.transform_keys(&:to_sym)
131
+ self.class.openapi_types.each_pair do |key, type|
132
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
133
+ send("#{key}=", nil)
134
+ elsif type =~ /\AArray<(.*)>/i
135
+ # check to ensure the input is an array given that the attribute
136
+ # is documented as an array but the input is not
137
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
138
+ send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
139
+ end
140
+ elsif !attributes[self.class.attribute_map[key]].nil?
141
+ send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
142
+ end
143
+ end
144
+
145
+ self
146
+ end
147
+
148
+ # Deserializes the data based on type
149
+ # @param string type Data type
150
+ # @param string value Value to be deserialized
151
+ # @return [Object] Deserialized data
152
+ def _deserialize(type, value)
153
+ case type.to_sym
154
+ when :Time
155
+ Time.parse(value)
156
+ when :Date
157
+ Date.parse(value)
158
+ when :String
159
+ value.to_s
160
+ when :Integer
161
+ value.to_i
162
+ when :Float
163
+ value.to_f
164
+ when :Boolean
165
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
166
+ true
167
+ else
168
+ false
169
+ end
170
+ when :Object
171
+ # generic object (usually a Hash), return directly
172
+ value
173
+ when /\AArray<(?<inner_type>.+)>\z/
174
+ inner_type = Regexp.last_match[:inner_type]
175
+ value.map { |v| _deserialize(inner_type, v) }
176
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
177
+ k_type = Regexp.last_match[:k_type]
178
+ v_type = Regexp.last_match[:v_type]
179
+ {}.tap do |hash|
180
+ value.each do |k, v|
181
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
182
+ end
183
+ end
184
+ else # model
185
+ # models (e.g. Pet) or oneOf
186
+ klass = Airthings.const_get(type)
187
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
188
+ end
189
+ end
190
+
191
+ # Returns the string representation of the object
192
+ # @return [String] String presentation of the object
193
+ def to_s
194
+ to_hash.to_s
195
+ end
196
+
197
+ # to_body is an alias to to_hash (backward compatibility)
198
+ # @return [Hash] Returns the object in the form of hash
199
+ def to_body
200
+ to_hash
201
+ end
202
+
203
+ # Returns the object in the form of hash
204
+ # @return [Hash] Returns the object in the form of hash
205
+ def to_hash
206
+ hash = {}
207
+ self.class.attribute_map.each_pair do |attr, param|
208
+ value = send(attr)
209
+ if value.nil?
210
+ is_nullable = self.class.openapi_nullable.include?(attr)
211
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
212
+ end
213
+
214
+ hash[param] = _to_hash(value)
215
+ end
216
+ hash
217
+ end
218
+
219
+ # Outputs non-array value in the form of hash
220
+ # For object, use to_hash. Otherwise, just return the value
221
+ # @param [Object] value Any valid value
222
+ # @return [Hash] Returns the value in the form of hash
223
+ def _to_hash(value)
224
+ if value.is_a?(Array)
225
+ value.compact.map { |v| _to_hash(v) }
226
+ elsif value.is_a?(Hash)
227
+ {}.tap do |hash|
228
+ value.each { |k, v| hash[k] = _to_hash(v) }
229
+ end
230
+ elsif value.respond_to? :to_hash
231
+ value.to_hash
232
+ else
233
+ value
234
+ end
235
+ end
236
+ end
237
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ # #Airthings API
4
+ #
5
+ # No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6
+ #
7
+ # The version of the OpenAPI document: v1
8
+ #
9
+ # Generated by: https://openapi-generator.tech
10
+ # OpenAPI Generator version: 6.2.0
11
+ #
12
+
13
+ require "date"
14
+ require "time"
15
+
16
+ module Airthings
17
+ class DeviceType
18
+ WAVE = "WAVE"
19
+ WAVE_MIST = "WAVE_MIST"
20
+ WAVE_GEN2 = "WAVE_GEN2"
21
+ WAVE_MINI = "WAVE_MINI"
22
+ WAVE_PLUS = "WAVE_PLUS"
23
+ WAVE_CO2 = "WAVE_CO2"
24
+ VIEW_PLUS = "VIEW_PLUS"
25
+ VIEW_PLUS_BUSINESS = "VIEW_PLUS_BUSINESS"
26
+ VIEW_POLLUTION = "VIEW_POLLUTION"
27
+ VIEW_RADON = "VIEW_RADON"
28
+ VIEW_CO2 = "VIEW_CO2"
29
+ SPACE_CO2_MINI = "SPACE_CO2_MINI"
30
+ WAVE_ENHANCE = "WAVE_ENHANCE"
31
+ HUB = "HUB"
32
+ HOME = "HOME"
33
+ PRO = "PRO"
34
+ CLOUDBERRY = "CLOUDBERRY"
35
+ AIRTIGHT = "AIRTIGHT"
36
+ AGGREGATED_GROUP = "AGGREGATED_GROUP"
37
+ ZONE_GROUP = "ZONE_GROUP"
38
+ BALANCE_CONTROL = "BALANCE_CONTROL"
39
+ INLET_AIR_CONTROL = "INLET_AIR_CONTROL"
40
+ VENT_CONTROLLER = "VENT_CONTROLLER"
41
+ AIRLY = "AIRLY"
42
+ AIRLY_NO2 = "AIRLY_NO2"
43
+ AIRLY_CO = "AIRLY_CO"
44
+ AIRLY_NO = "AIRLY_NO"
45
+ BREEZOMETER_WEATHER = "BREEZOMETER_WEATHER"
46
+ BACNET = "BACNET"
47
+ UNKNOWN = "UNKNOWN"
48
+
49
+ def self.all_vars
50
+ @all_vars ||= [WAVE, WAVE_MIST, WAVE_GEN2, WAVE_MINI, WAVE_PLUS, WAVE_CO2, VIEW_PLUS, VIEW_PLUS_BUSINESS, VIEW_POLLUTION, VIEW_RADON, VIEW_CO2, SPACE_CO2_MINI, WAVE_ENHANCE, HUB, HOME, PRO, CLOUDBERRY, AIRTIGHT, AGGREGATED_GROUP, ZONE_GROUP, BALANCE_CONTROL, INLET_AIR_CONTROL, VENT_CONTROLLER, AIRLY, AIRLY_NO2, AIRLY_CO, AIRLY_NO, BREEZOMETER_WEATHER, BACNET, UNKNOWN].freeze
51
+ end
52
+
53
+ # Builds the enum from string
54
+ # @param [String] The enum value in the form of the string
55
+ # @return [String] The enum value
56
+ def self.build_from_hash(value)
57
+ new.build_from_hash(value)
58
+ end
59
+
60
+ # Builds the enum from string
61
+ # @param [String] The enum value in the form of the string
62
+ # @return [String] The enum value
63
+ def build_from_hash(value)
64
+ return value if DeviceType.all_vars.include?(value)
65
+
66
+ raise "Invalid ENUM value #{value} for class #DeviceType"
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,255 @@
1
+ # frozen_string_literal: true
2
+
3
+ # #Airthings API
4
+ #
5
+ # No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6
+ #
7
+ # The version of the OpenAPI document: v1
8
+ #
9
+ # Generated by: https://openapi-generator.tech
10
+ # OpenAPI Generator version: 6.2.0
11
+ #
12
+
13
+ require "date"
14
+ require "time"
15
+
16
+ module Airthings
17
+ class GetDeviceDetailedResponse
18
+ attr_accessor :id, :device_type, :sensors, :segment, :location
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ id: :id,
24
+ device_type: :deviceType,
25
+ sensors: :sensors,
26
+ segment: :segment,
27
+ location: :location
28
+ }
29
+ end
30
+
31
+ # Returns all the JSON keys this model knows about
32
+ def self.acceptable_attributes
33
+ attribute_map.values
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ id: :String,
40
+ device_type: :DeviceType,
41
+ sensors: :"Array<SensorType>",
42
+ segment: :SegmentSimpleResponse,
43
+ location: :LocationSimpleResponse
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new([])
50
+ end
51
+
52
+ # Initializes the object
53
+ # @param [Hash] attributes Model attributes in the form of hash
54
+ def initialize(attributes = {})
55
+ unless attributes.is_a?(Hash)
56
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Airthings::GetDeviceDetailedResponse` initialize method"
57
+ end
58
+
59
+ # check to see if the attribute exists and convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}) do |(k, v), h|
61
+ unless self.class.attribute_map.key?(k.to_sym)
62
+ raise ArgumentError, "`#{k}` is not a valid attribute in `Airthings::GetDeviceDetailedResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
63
+ end
64
+
65
+ h[k.to_sym] = v
66
+ end
67
+
68
+ self.id = attributes[:id] if attributes.key?(:id)
69
+
70
+ self.device_type = attributes[:device_type] if attributes.key?(:device_type)
71
+
72
+ if attributes.key?(:sensors) && (value = attributes[:sensors]).is_a?(Array)
73
+ self.sensors = value
74
+ end
75
+
76
+ self.segment = attributes[:segment] if attributes.key?(:segment)
77
+
78
+ self.location = attributes[:location] if attributes.key?(:location)
79
+ end
80
+
81
+ # Show invalid properties with the reasons. Usually used together with valid?
82
+ # @return Array for valid properties with the reasons
83
+ def list_invalid_properties
84
+ invalid_properties = []
85
+ invalid_properties.push('invalid value for "id", id cannot be nil.') if @id.nil?
86
+
87
+ invalid_properties.push('invalid value for "device_type", device_type cannot be nil.') if @device_type.nil?
88
+
89
+ invalid_properties.push('invalid value for "sensors", sensors cannot be nil.') if @sensors.nil?
90
+
91
+ invalid_properties.push('invalid value for "segment", segment cannot be nil.') if @segment.nil?
92
+
93
+ invalid_properties.push('invalid value for "location", location cannot be nil.') if @location.nil?
94
+
95
+ invalid_properties
96
+ end
97
+
98
+ # Check to see if the all the properties in the model are valid
99
+ # @return true if the model is valid
100
+ def valid?
101
+ return false if @id.nil?
102
+ return false if @device_type.nil?
103
+ return false if @sensors.nil?
104
+ return false if @segment.nil?
105
+ return false if @location.nil?
106
+
107
+ true
108
+ end
109
+
110
+ # Checks equality by comparing each attribute.
111
+ # @param [Object] Object to be compared
112
+ def ==(other)
113
+ return true if equal?(other)
114
+
115
+ self.class == other.class &&
116
+ id == other.id &&
117
+ device_type == other.device_type &&
118
+ sensors == other.sensors &&
119
+ segment == other.segment &&
120
+ location == other.location
121
+ end
122
+
123
+ # @see the `==` method
124
+ # @param [Object] Object to be compared
125
+ def eql?(other)
126
+ self == other
127
+ end
128
+
129
+ # Calculates hash code according to all attributes.
130
+ # @return [Integer] Hash code
131
+ def hash
132
+ [id, device_type, sensors, segment, location].hash
133
+ end
134
+
135
+ # Builds the object from hash
136
+ # @param [Hash] attributes Model attributes in the form of hash
137
+ # @return [Object] Returns the model itself
138
+ def self.build_from_hash(attributes)
139
+ new.build_from_hash(attributes)
140
+ end
141
+
142
+ # Builds the object from hash
143
+ # @param [Hash] attributes Model attributes in the form of hash
144
+ # @return [Object] Returns the model itself
145
+ def build_from_hash(attributes)
146
+ return nil unless attributes.is_a?(Hash)
147
+
148
+ attributes = attributes.transform_keys(&:to_sym)
149
+ self.class.openapi_types.each_pair do |key, type|
150
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
151
+ send("#{key}=", nil)
152
+ elsif type =~ /\AArray<(.*)>/i
153
+ # check to ensure the input is an array given that the attribute
154
+ # is documented as an array but the input is not
155
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
156
+ send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
157
+ end
158
+ elsif !attributes[self.class.attribute_map[key]].nil?
159
+ send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
160
+ end
161
+ end
162
+
163
+ self
164
+ end
165
+
166
+ # Deserializes the data based on type
167
+ # @param string type Data type
168
+ # @param string value Value to be deserialized
169
+ # @return [Object] Deserialized data
170
+ def _deserialize(type, value)
171
+ case type.to_sym
172
+ when :Time
173
+ Time.parse(value)
174
+ when :Date
175
+ Date.parse(value)
176
+ when :String
177
+ value.to_s
178
+ when :Integer
179
+ value.to_i
180
+ when :Float
181
+ value.to_f
182
+ when :Boolean
183
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
184
+ true
185
+ else
186
+ false
187
+ end
188
+ when :Object
189
+ # generic object (usually a Hash), return directly
190
+ value
191
+ when /\AArray<(?<inner_type>.+)>\z/
192
+ inner_type = Regexp.last_match[:inner_type]
193
+ value.map { |v| _deserialize(inner_type, v) }
194
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
195
+ k_type = Regexp.last_match[:k_type]
196
+ v_type = Regexp.last_match[:v_type]
197
+ {}.tap do |hash|
198
+ value.each do |k, v|
199
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
200
+ end
201
+ end
202
+ else # model
203
+ # models (e.g. Pet) or oneOf
204
+ klass = Airthings.const_get(type)
205
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
206
+ end
207
+ end
208
+
209
+ # Returns the string representation of the object
210
+ # @return [String] String presentation of the object
211
+ def to_s
212
+ to_hash.to_s
213
+ end
214
+
215
+ # to_body is an alias to to_hash (backward compatibility)
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_body
218
+ to_hash
219
+ end
220
+
221
+ # Returns the object in the form of hash
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_hash
224
+ hash = {}
225
+ self.class.attribute_map.each_pair do |attr, param|
226
+ value = send(attr)
227
+ if value.nil?
228
+ is_nullable = self.class.openapi_nullable.include?(attr)
229
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
230
+ end
231
+
232
+ hash[param] = _to_hash(value)
233
+ end
234
+ hash
235
+ end
236
+
237
+ # Outputs non-array value in the form of hash
238
+ # For object, use to_hash. Otherwise, just return the value
239
+ # @param [Object] value Any valid value
240
+ # @return [Hash] Returns the value in the form of hash
241
+ def _to_hash(value)
242
+ if value.is_a?(Array)
243
+ value.compact.map { |v| _to_hash(v) }
244
+ elsif value.is_a?(Hash)
245
+ {}.tap do |hash|
246
+ value.each { |k, v| hash[k] = _to_hash(v) }
247
+ end
248
+ elsif value.respond_to? :to_hash
249
+ value.to_hash
250
+ else
251
+ value
252
+ end
253
+ end
254
+ end
255
+ end