test-pack-1 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +28 -0
- data/README.md +872 -0
- data/lib/test_pack_1.rb +63 -0
- data/lib/test_pack_1/api_helper.rb +275 -0
- data/lib/test_pack_1/configuration.rb +63 -0
- data/lib/test_pack_1/controllers/alerts_controller.rb +381 -0
- data/lib/test_pack_1/controllers/assets_controller.rb +227 -0
- data/lib/test_pack_1/controllers/base_controller.rb +51 -0
- data/lib/test_pack_1/controllers/configuration_data_controller.rb +76 -0
- data/lib/test_pack_1/controllers/data_controller.rb +349 -0
- data/lib/test_pack_1/controllers/statuses_controller.rb +215 -0
- data/lib/test_pack_1/exceptions/api_exception.rb +20 -0
- data/lib/test_pack_1/http/auth/custom_query_auth.rb +16 -0
- data/lib/test_pack_1/http/faraday_client.rb +64 -0
- data/lib/test_pack_1/http/http_call_back.rb +24 -0
- data/lib/test_pack_1/http/http_client.rb +104 -0
- data/lib/test_pack_1/http/http_context.rb +20 -0
- data/lib/test_pack_1/http/http_method_enum.rb +13 -0
- data/lib/test_pack_1/http/http_request.rb +50 -0
- data/lib/test_pack_1/http/http_response.rb +23 -0
- data/lib/test_pack_1/models/aggregate_mode_enum.rb +23 -0
- data/lib/test_pack_1/models/alert_item.rb +104 -0
- data/lib/test_pack_1/models/base_model.rb +36 -0
- data/lib/test_pack_1/models/calculation_mode_enum.rb +20 -0
- data/lib/test_pack_1/models/client_configuration.rb +62 -0
- data/lib/test_pack_1/models/configuration_item.rb +55 -0
- data/lib/test_pack_1/models/data_item.rb +92 -0
- data/lib/test_pack_1/models/data_per_category_item.rb +82 -0
- data/lib/test_pack_1/models/data_per_category_response.rb +63 -0
- data/lib/test_pack_1/models/data_real_time_item.rb +83 -0
- data/lib/test_pack_1/models/data_signal.rb +53 -0
- data/lib/test_pack_1/models/data_signal_configuration.rb +66 -0
- data/lib/test_pack_1/models/data_signal_item.rb +62 -0
- data/lib/test_pack_1/models/device.rb +208 -0
- data/lib/test_pack_1/models/device_model.rb +53 -0
- data/lib/test_pack_1/models/metadata_field.rb +44 -0
- data/lib/test_pack_1/models/power_curve.rb +60 -0
- data/lib/test_pack_1/models/power_curve_value.rb +44 -0
- data/lib/test_pack_1/models/resolution_enum.rb +41 -0
- data/lib/test_pack_1/models/site.rb +44 -0
- data/lib/test_pack_1/models/site_with_data.rb +78 -0
- data/lib/test_pack_1/models/status_category_enum.rb +26 -0
- data/lib/test_pack_1/models/status_item.rb +161 -0
- data/lib/test_pack_1/models/time_zone_configuration.rb +76 -0
- data/lib/test_pack_1/models/turbine_type.rb +89 -0
- data/lib/test_pack_1/test_pack1_client.rb +51 -0
- data/test/controllers/controller_test_base.rb +33 -0
- data/test/controllers/test_assets_controller.rb +46 -0
- data/test/controllers/test_configuration_data_controller.rb +44 -0
- data/test/http_response_catcher.rb +20 -0
- data/test/test_helper.rb +99 -0
- metadata +219 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
# test_pack_1
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0 (
|
4
|
+
# https://apimatic.io ).
|
5
|
+
|
6
|
+
module TestPack1
|
7
|
+
# Data for a single aggregate group and contract category combination.
|
8
|
+
class DataPerCategoryItem < BaseModel
|
9
|
+
# The id of this aggregate group: device id, site id, or the constant -1 for
|
10
|
+
# portfolio
|
11
|
+
# @return [Integer]
|
12
|
+
attr_accessor :aggregate_id
|
13
|
+
|
14
|
+
# The ids of the devices in this aggregate group.
|
15
|
+
# @return [List of Integer]
|
16
|
+
attr_accessor :device_ids
|
17
|
+
|
18
|
+
# The ids of the devices in this aggregate group.
|
19
|
+
# @return [String]
|
20
|
+
attr_accessor :contract_title
|
21
|
+
|
22
|
+
# The ids of the devices in this aggregate group.
|
23
|
+
# @return [String]
|
24
|
+
attr_accessor :category_title
|
25
|
+
|
26
|
+
# The aggregated value of the selected data signal.
|
27
|
+
# @return [Float]
|
28
|
+
attr_accessor :value
|
29
|
+
|
30
|
+
# The summed duration in seconds allocated to this contract category and
|
31
|
+
# aggregate group.
|
32
|
+
# @return [Float]
|
33
|
+
attr_accessor :duration
|
34
|
+
|
35
|
+
# A mapping from model property names to API property names.
|
36
|
+
def self.names
|
37
|
+
@_hash = {} if @_hash.nil?
|
38
|
+
@_hash['aggregate_id'] = 'aggregateId'
|
39
|
+
@_hash['device_ids'] = 'deviceIds'
|
40
|
+
@_hash['contract_title'] = 'contractTitle'
|
41
|
+
@_hash['category_title'] = 'categoryTitle'
|
42
|
+
@_hash['value'] = 'value'
|
43
|
+
@_hash['duration'] = 'duration'
|
44
|
+
@_hash
|
45
|
+
end
|
46
|
+
|
47
|
+
def initialize(aggregate_id = nil,
|
48
|
+
device_ids = nil,
|
49
|
+
contract_title = nil,
|
50
|
+
category_title = nil,
|
51
|
+
value = nil,
|
52
|
+
duration = nil)
|
53
|
+
@aggregate_id = aggregate_id
|
54
|
+
@device_ids = device_ids
|
55
|
+
@contract_title = contract_title
|
56
|
+
@category_title = category_title
|
57
|
+
@value = value
|
58
|
+
@duration = duration
|
59
|
+
end
|
60
|
+
|
61
|
+
# Creates an instance of the object from a hash.
|
62
|
+
def self.from_hash(hash)
|
63
|
+
return nil unless hash
|
64
|
+
|
65
|
+
# Extract variables from the hash.
|
66
|
+
aggregate_id = hash['aggregateId']
|
67
|
+
device_ids = hash['deviceIds']
|
68
|
+
contract_title = hash['contractTitle']
|
69
|
+
category_title = hash['categoryTitle']
|
70
|
+
value = hash['value']
|
71
|
+
duration = hash['duration']
|
72
|
+
|
73
|
+
# Create object from extracted values.
|
74
|
+
DataPerCategoryItem.new(aggregate_id,
|
75
|
+
device_ids,
|
76
|
+
contract_title,
|
77
|
+
category_title,
|
78
|
+
value,
|
79
|
+
duration)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# test_pack_1
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0 (
|
4
|
+
# https://apimatic.io ).
|
5
|
+
|
6
|
+
module TestPack1
|
7
|
+
# An object containing data grouped by contract category and aggregate.
|
8
|
+
class DataPerCategoryResponse < BaseModel
|
9
|
+
# A data signal.
|
10
|
+
# @return [DataSignal]
|
11
|
+
attr_accessor :data_signal
|
12
|
+
|
13
|
+
# Which operation to use when aggregating data.
|
14
|
+
# @return [CalculationModeEnum]
|
15
|
+
attr_accessor :calculation
|
16
|
+
|
17
|
+
# A list of objects: one per combination of
|
18
|
+
# * aggregate
|
19
|
+
# * contract category
|
20
|
+
# @return [List of DataPerCategoryItem]
|
21
|
+
attr_accessor :data
|
22
|
+
|
23
|
+
# A mapping from model property names to API property names.
|
24
|
+
def self.names
|
25
|
+
@_hash = {} if @_hash.nil?
|
26
|
+
@_hash['data_signal'] = 'dataSignal'
|
27
|
+
@_hash['calculation'] = 'calculation'
|
28
|
+
@_hash['data'] = 'data'
|
29
|
+
@_hash
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialize(data_signal = nil,
|
33
|
+
calculation = nil,
|
34
|
+
data = nil)
|
35
|
+
@data_signal = data_signal
|
36
|
+
@calculation = calculation
|
37
|
+
@data = data
|
38
|
+
end
|
39
|
+
|
40
|
+
# Creates an instance of the object from a hash.
|
41
|
+
def self.from_hash(hash)
|
42
|
+
return nil unless hash
|
43
|
+
|
44
|
+
# Extract variables from the hash.
|
45
|
+
data_signal = DataSignal.from_hash(hash['dataSignal']) if
|
46
|
+
hash['dataSignal']
|
47
|
+
calculation = hash['calculation']
|
48
|
+
# Parameter is an array, so we need to iterate through it
|
49
|
+
data = nil
|
50
|
+
unless hash['data'].nil?
|
51
|
+
data = []
|
52
|
+
hash['data'].each do |structure|
|
53
|
+
data << (DataPerCategoryItem.from_hash(structure) if structure)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Create object from extracted values.
|
58
|
+
DataPerCategoryResponse.new(data_signal,
|
59
|
+
calculation,
|
60
|
+
data)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# test_pack_1
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0 (
|
4
|
+
# https://apimatic.io ).
|
5
|
+
|
6
|
+
module TestPack1
|
7
|
+
# An object containing a single data point for a specific aggregate, data
|
8
|
+
# signal and interval.
|
9
|
+
class DataRealTimeItem < BaseModel
|
10
|
+
# How data is aggregated in the asset structure.
|
11
|
+
# @return [AggregateModeEnum]
|
12
|
+
attr_accessor :aggregate
|
13
|
+
|
14
|
+
# The id of this aggregate group: device id, site id, or the constant -1 for
|
15
|
+
# portfolio
|
16
|
+
# @return [Integer]
|
17
|
+
attr_accessor :aggregate_id
|
18
|
+
|
19
|
+
# The ids of the devices in this aggregate group.
|
20
|
+
# @return [List of Integer]
|
21
|
+
attr_accessor :device_ids
|
22
|
+
|
23
|
+
# Which operation to use when aggregating data.
|
24
|
+
# @return [CalculationModeEnum]
|
25
|
+
attr_accessor :calculation
|
26
|
+
|
27
|
+
# A data signal.
|
28
|
+
# @return [DataSignal]
|
29
|
+
attr_accessor :data_signal
|
30
|
+
|
31
|
+
# A data signal.
|
32
|
+
# @return [Array<String, Float>]
|
33
|
+
attr_accessor :data
|
34
|
+
|
35
|
+
# A mapping from model property names to API property names.
|
36
|
+
def self.names
|
37
|
+
@_hash = {} if @_hash.nil?
|
38
|
+
@_hash['aggregate'] = 'aggregate'
|
39
|
+
@_hash['aggregate_id'] = 'aggregateId'
|
40
|
+
@_hash['device_ids'] = 'deviceIds'
|
41
|
+
@_hash['calculation'] = 'calculation'
|
42
|
+
@_hash['data_signal'] = 'dataSignal'
|
43
|
+
@_hash['data'] = 'data'
|
44
|
+
@_hash
|
45
|
+
end
|
46
|
+
|
47
|
+
def initialize(aggregate = nil,
|
48
|
+
aggregate_id = nil,
|
49
|
+
device_ids = nil,
|
50
|
+
calculation = nil,
|
51
|
+
data_signal = nil,
|
52
|
+
data = nil)
|
53
|
+
@aggregate = aggregate
|
54
|
+
@aggregate_id = aggregate_id
|
55
|
+
@device_ids = device_ids
|
56
|
+
@calculation = calculation
|
57
|
+
@data_signal = data_signal
|
58
|
+
@data = data
|
59
|
+
end
|
60
|
+
|
61
|
+
# Creates an instance of the object from a hash.
|
62
|
+
def self.from_hash(hash)
|
63
|
+
return nil unless hash
|
64
|
+
|
65
|
+
# Extract variables from the hash.
|
66
|
+
aggregate = hash['aggregate']
|
67
|
+
aggregate_id = hash['aggregateId']
|
68
|
+
device_ids = hash['deviceIds']
|
69
|
+
calculation = hash['calculation']
|
70
|
+
data_signal = DataSignal.from_hash(hash['dataSignal']) if
|
71
|
+
hash['dataSignal']
|
72
|
+
data = hash['data']
|
73
|
+
|
74
|
+
# Create object from extracted values.
|
75
|
+
DataRealTimeItem.new(aggregate,
|
76
|
+
aggregate_id,
|
77
|
+
device_ids,
|
78
|
+
calculation,
|
79
|
+
data_signal,
|
80
|
+
data)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# test_pack_1
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0 (
|
4
|
+
# https://apimatic.io ).
|
5
|
+
|
6
|
+
module TestPack1
|
7
|
+
# A data signal.
|
8
|
+
class DataSignal < BaseModel
|
9
|
+
# The unique id of a data signal.
|
10
|
+
# @return [Integer]
|
11
|
+
attr_accessor :data_signal_id
|
12
|
+
|
13
|
+
# The unique id of a data signal.
|
14
|
+
# @return [String]
|
15
|
+
attr_accessor :title
|
16
|
+
|
17
|
+
# The unique id of a data signal.
|
18
|
+
# @return [String]
|
19
|
+
attr_accessor :unit
|
20
|
+
|
21
|
+
# A mapping from model property names to API property names.
|
22
|
+
def self.names
|
23
|
+
@_hash = {} if @_hash.nil?
|
24
|
+
@_hash['data_signal_id'] = 'dataSignalId'
|
25
|
+
@_hash['title'] = 'title'
|
26
|
+
@_hash['unit'] = 'unit'
|
27
|
+
@_hash
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(data_signal_id = nil,
|
31
|
+
title = nil,
|
32
|
+
unit = nil)
|
33
|
+
@data_signal_id = data_signal_id
|
34
|
+
@title = title
|
35
|
+
@unit = unit
|
36
|
+
end
|
37
|
+
|
38
|
+
# Creates an instance of the object from a hash.
|
39
|
+
def self.from_hash(hash)
|
40
|
+
return nil unless hash
|
41
|
+
|
42
|
+
# Extract variables from the hash.
|
43
|
+
data_signal_id = hash['dataSignalId']
|
44
|
+
title = hash['title']
|
45
|
+
unit = hash['unit']
|
46
|
+
|
47
|
+
# Create object from extracted values.
|
48
|
+
DataSignal.new(data_signal_id,
|
49
|
+
title,
|
50
|
+
unit)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# test_pack_1
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0 (
|
4
|
+
# https://apimatic.io ).
|
5
|
+
|
6
|
+
module TestPack1
|
7
|
+
# Your data signal configuration. These only apply to wind devices.
|
8
|
+
class DataSignalConfiguration < BaseModel
|
9
|
+
# The id of the data signal used for time-based availability data.
|
10
|
+
# @return [Integer]
|
11
|
+
attr_accessor :availability_time_data_signal_id
|
12
|
+
|
13
|
+
# The id of the data signal used for production-based availability data.
|
14
|
+
# @return [Integer]
|
15
|
+
attr_accessor :availability_production_data_signal_id
|
16
|
+
|
17
|
+
# The id of the data signal used for lost production data.
|
18
|
+
# @return [Integer]
|
19
|
+
attr_accessor :lost_production_data_signal_id
|
20
|
+
|
21
|
+
# The id of the data signal used for performance data.
|
22
|
+
# @return [Integer]
|
23
|
+
attr_accessor :performance_data_signal_id
|
24
|
+
|
25
|
+
# A mapping from model property names to API property names.
|
26
|
+
def self.names
|
27
|
+
@_hash = {} if @_hash.nil?
|
28
|
+
@_hash['availability_time_data_signal_id'] =
|
29
|
+
'availabilityTimeDataSignalId'
|
30
|
+
@_hash['availability_production_data_signal_id'] =
|
31
|
+
'availabilityProductionDataSignalId'
|
32
|
+
@_hash['lost_production_data_signal_id'] = 'lostProductionDataSignalId'
|
33
|
+
@_hash['performance_data_signal_id'] = 'performanceDataSignalId'
|
34
|
+
@_hash
|
35
|
+
end
|
36
|
+
|
37
|
+
def initialize(availability_time_data_signal_id = nil,
|
38
|
+
availability_production_data_signal_id = nil,
|
39
|
+
lost_production_data_signal_id = nil,
|
40
|
+
performance_data_signal_id = nil)
|
41
|
+
@availability_time_data_signal_id = availability_time_data_signal_id
|
42
|
+
@availability_production_data_signal_id =
|
43
|
+
availability_production_data_signal_id
|
44
|
+
@lost_production_data_signal_id = lost_production_data_signal_id
|
45
|
+
@performance_data_signal_id = performance_data_signal_id
|
46
|
+
end
|
47
|
+
|
48
|
+
# Creates an instance of the object from a hash.
|
49
|
+
def self.from_hash(hash)
|
50
|
+
return nil unless hash
|
51
|
+
|
52
|
+
# Extract variables from the hash.
|
53
|
+
availability_time_data_signal_id = hash['availabilityTimeDataSignalId']
|
54
|
+
availability_production_data_signal_id =
|
55
|
+
hash['availabilityProductionDataSignalId']
|
56
|
+
lost_production_data_signal_id = hash['lostProductionDataSignalId']
|
57
|
+
performance_data_signal_id = hash['performanceDataSignalId']
|
58
|
+
|
59
|
+
# Create object from extracted values.
|
60
|
+
DataSignalConfiguration.new(availability_time_data_signal_id,
|
61
|
+
availability_production_data_signal_id,
|
62
|
+
lost_production_data_signal_id,
|
63
|
+
performance_data_signal_id)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# test_pack_1
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0 (
|
4
|
+
# https://apimatic.io ).
|
5
|
+
|
6
|
+
module TestPack1
|
7
|
+
# A data signal, including type.
|
8
|
+
class DataSignalItem < BaseModel
|
9
|
+
# The unique id of a data signal.
|
10
|
+
# @return [Integer]
|
11
|
+
attr_accessor :data_signal_id
|
12
|
+
|
13
|
+
# The unique id of a data signal.
|
14
|
+
# @return [String]
|
15
|
+
attr_accessor :title
|
16
|
+
|
17
|
+
# The unique id of a data signal.
|
18
|
+
# @return [String]
|
19
|
+
attr_accessor :type
|
20
|
+
|
21
|
+
# The unique id of a data signal.
|
22
|
+
# @return [String]
|
23
|
+
attr_accessor :unit
|
24
|
+
|
25
|
+
# A mapping from model property names to API property names.
|
26
|
+
def self.names
|
27
|
+
@_hash = {} if @_hash.nil?
|
28
|
+
@_hash['data_signal_id'] = 'dataSignalId'
|
29
|
+
@_hash['title'] = 'title'
|
30
|
+
@_hash['type'] = 'type'
|
31
|
+
@_hash['unit'] = 'unit'
|
32
|
+
@_hash
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(data_signal_id = nil,
|
36
|
+
title = nil,
|
37
|
+
type = nil,
|
38
|
+
unit = nil)
|
39
|
+
@data_signal_id = data_signal_id
|
40
|
+
@title = title
|
41
|
+
@type = type
|
42
|
+
@unit = unit
|
43
|
+
end
|
44
|
+
|
45
|
+
# Creates an instance of the object from a hash.
|
46
|
+
def self.from_hash(hash)
|
47
|
+
return nil unless hash
|
48
|
+
|
49
|
+
# Extract variables from the hash.
|
50
|
+
data_signal_id = hash['dataSignalId']
|
51
|
+
title = hash['title']
|
52
|
+
type = hash['type']
|
53
|
+
unit = hash['unit']
|
54
|
+
|
55
|
+
# Create object from extracted values.
|
56
|
+
DataSignalItem.new(data_signal_id,
|
57
|
+
title,
|
58
|
+
type,
|
59
|
+
unit)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,208 @@
|
|
1
|
+
# test_pack_1
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0 (
|
4
|
+
# https://apimatic.io ).
|
5
|
+
|
6
|
+
require 'date'
|
7
|
+
module TestPack1
|
8
|
+
# Device Model.
|
9
|
+
class Device < BaseModel
|
10
|
+
# The id of a device.
|
11
|
+
# @return [Integer]
|
12
|
+
attr_accessor :device_id
|
13
|
+
|
14
|
+
# The id of a device.
|
15
|
+
# @return [String]
|
16
|
+
attr_accessor :title
|
17
|
+
|
18
|
+
# An alternative title.
|
19
|
+
# @return [String]
|
20
|
+
attr_accessor :alt_title
|
21
|
+
|
22
|
+
# Device identification number.
|
23
|
+
# @return [String]
|
24
|
+
attr_accessor :identity
|
25
|
+
|
26
|
+
# Device identification number.
|
27
|
+
# @return [Site]
|
28
|
+
attr_accessor :site
|
29
|
+
|
30
|
+
# The string representation of the device type.
|
31
|
+
# @return [String]
|
32
|
+
attr_accessor :device_type
|
33
|
+
|
34
|
+
# The id of a device type.
|
35
|
+
# @return [Integer]
|
36
|
+
attr_accessor :device_type_id
|
37
|
+
|
38
|
+
# The id of the parent device, if any.
|
39
|
+
# @return [Integer]
|
40
|
+
attr_accessor :parent_id
|
41
|
+
|
42
|
+
# Ids of child devices, if any.
|
43
|
+
# @return [List of Integer]
|
44
|
+
attr_accessor :child_ids
|
45
|
+
|
46
|
+
# General device model information.
|
47
|
+
# @return [DeviceModel]
|
48
|
+
attr_accessor :device_model
|
49
|
+
|
50
|
+
# Turbine-specific type information.
|
51
|
+
# @return [TurbineType]
|
52
|
+
attr_accessor :turbine_type
|
53
|
+
|
54
|
+
# The maximum power for a device.
|
55
|
+
# @return [Integer]
|
56
|
+
attr_accessor :max_power
|
57
|
+
|
58
|
+
# Only applies to Nordic countries and the UK.
|
59
|
+
# @return [String]
|
60
|
+
attr_accessor :bidding_area
|
61
|
+
|
62
|
+
# The earliest timestamp device data is available for.
|
63
|
+
# @return [DateTime]
|
64
|
+
attr_accessor :timestamp_start
|
65
|
+
|
66
|
+
# The latitude of the device in the WGS84 system.
|
67
|
+
# @return [String]
|
68
|
+
attr_accessor :latitude
|
69
|
+
|
70
|
+
# The longitude of the device in the WGS84 system.
|
71
|
+
# @return [String]
|
72
|
+
attr_accessor :longitude
|
73
|
+
|
74
|
+
# The elevation of the device in meters above sea level.
|
75
|
+
# @return [String]
|
76
|
+
attr_accessor :elevation
|
77
|
+
|
78
|
+
# The target availability for the device.
|
79
|
+
# @return [Float]
|
80
|
+
attr_accessor :target_availability
|
81
|
+
|
82
|
+
# A list of metadata fields and their values.
|
83
|
+
# @return [List of MetadataField]
|
84
|
+
attr_accessor :metadata
|
85
|
+
|
86
|
+
# A mapping from model property names to API property names.
|
87
|
+
def self.names
|
88
|
+
@_hash = {} if @_hash.nil?
|
89
|
+
@_hash['device_id'] = 'deviceId'
|
90
|
+
@_hash['title'] = 'title'
|
91
|
+
@_hash['alt_title'] = 'altTitle'
|
92
|
+
@_hash['identity'] = 'identity'
|
93
|
+
@_hash['site'] = 'site'
|
94
|
+
@_hash['device_type'] = 'deviceType'
|
95
|
+
@_hash['device_type_id'] = 'deviceTypeId'
|
96
|
+
@_hash['parent_id'] = 'parentId'
|
97
|
+
@_hash['child_ids'] = 'childIds'
|
98
|
+
@_hash['device_model'] = 'deviceModel'
|
99
|
+
@_hash['turbine_type'] = 'turbineType'
|
100
|
+
@_hash['max_power'] = 'maxPower'
|
101
|
+
@_hash['bidding_area'] = 'biddingArea'
|
102
|
+
@_hash['timestamp_start'] = 'timestampStart'
|
103
|
+
@_hash['latitude'] = 'latitude'
|
104
|
+
@_hash['longitude'] = 'longitude'
|
105
|
+
@_hash['elevation'] = 'elevation'
|
106
|
+
@_hash['target_availability'] = 'targetAvailability'
|
107
|
+
@_hash['metadata'] = 'metadata'
|
108
|
+
@_hash
|
109
|
+
end
|
110
|
+
|
111
|
+
def initialize(device_id = nil,
|
112
|
+
title = nil,
|
113
|
+
alt_title = nil,
|
114
|
+
identity = nil,
|
115
|
+
site = nil,
|
116
|
+
device_type = nil,
|
117
|
+
device_type_id = nil,
|
118
|
+
parent_id = nil,
|
119
|
+
child_ids = nil,
|
120
|
+
device_model = nil,
|
121
|
+
turbine_type = nil,
|
122
|
+
max_power = nil,
|
123
|
+
bidding_area = nil,
|
124
|
+
timestamp_start = nil,
|
125
|
+
latitude = nil,
|
126
|
+
longitude = nil,
|
127
|
+
elevation = nil,
|
128
|
+
target_availability = nil,
|
129
|
+
metadata = nil)
|
130
|
+
@device_id = device_id
|
131
|
+
@title = title
|
132
|
+
@alt_title = alt_title
|
133
|
+
@identity = identity
|
134
|
+
@site = site
|
135
|
+
@device_type = device_type
|
136
|
+
@device_type_id = device_type_id
|
137
|
+
@parent_id = parent_id
|
138
|
+
@child_ids = child_ids
|
139
|
+
@device_model = device_model
|
140
|
+
@turbine_type = turbine_type
|
141
|
+
@max_power = max_power
|
142
|
+
@bidding_area = bidding_area
|
143
|
+
@timestamp_start = timestamp_start
|
144
|
+
@latitude = latitude
|
145
|
+
@longitude = longitude
|
146
|
+
@elevation = elevation
|
147
|
+
@target_availability = target_availability
|
148
|
+
@metadata = metadata
|
149
|
+
end
|
150
|
+
|
151
|
+
# Creates an instance of the object from a hash.
|
152
|
+
def self.from_hash(hash)
|
153
|
+
return nil unless hash
|
154
|
+
|
155
|
+
# Extract variables from the hash.
|
156
|
+
device_id = hash['deviceId']
|
157
|
+
title = hash['title']
|
158
|
+
alt_title = hash['altTitle']
|
159
|
+
identity = hash['identity']
|
160
|
+
site = Site.from_hash(hash['site']) if hash['site']
|
161
|
+
device_type = hash['deviceType']
|
162
|
+
device_type_id = hash['deviceTypeId']
|
163
|
+
parent_id = hash['parentId']
|
164
|
+
child_ids = hash['childIds']
|
165
|
+
device_model = DeviceModel.from_hash(hash['deviceModel']) if
|
166
|
+
hash['deviceModel']
|
167
|
+
turbine_type = TurbineType.from_hash(hash['turbineType']) if
|
168
|
+
hash['turbineType']
|
169
|
+
max_power = hash['maxPower']
|
170
|
+
bidding_area = hash['biddingArea']
|
171
|
+
timestamp_start = APIHelper.rfc3339(hash['timestampStart']) if
|
172
|
+
hash['timestampStart']
|
173
|
+
latitude = hash['latitude']
|
174
|
+
longitude = hash['longitude']
|
175
|
+
elevation = hash['elevation']
|
176
|
+
target_availability = hash['targetAvailability']
|
177
|
+
# Parameter is an array, so we need to iterate through it
|
178
|
+
metadata = nil
|
179
|
+
unless hash['metadata'].nil?
|
180
|
+
metadata = []
|
181
|
+
hash['metadata'].each do |structure|
|
182
|
+
metadata << (MetadataField.from_hash(structure) if structure)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
# Create object from extracted values.
|
187
|
+
Device.new(device_id,
|
188
|
+
title,
|
189
|
+
alt_title,
|
190
|
+
identity,
|
191
|
+
site,
|
192
|
+
device_type,
|
193
|
+
device_type_id,
|
194
|
+
parent_id,
|
195
|
+
child_ids,
|
196
|
+
device_model,
|
197
|
+
turbine_type,
|
198
|
+
max_power,
|
199
|
+
bidding_area,
|
200
|
+
timestamp_start,
|
201
|
+
latitude,
|
202
|
+
longitude,
|
203
|
+
elevation,
|
204
|
+
target_availability,
|
205
|
+
metadata)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|