test-pack-1 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +37 -768
- data/lib/test_pack_1.rb +2 -30
- data/lib/test_pack_1/configuration.rb +5 -17
- data/lib/test_pack_1/controllers/simple_calculator_controller.rb +53 -0
- data/lib/test_pack_1/models/operation_type_enum.rb +23 -0
- data/lib/test_pack_1/test_pack1_client.rb +4 -34
- data/test/controllers/test_simple_calculator_controller.rb +33 -0
- metadata +6 -64
- data/lib/test_pack_1/controllers/alerts_controller.rb +0 -381
- data/lib/test_pack_1/controllers/assets_controller.rb +0 -227
- data/lib/test_pack_1/controllers/configuration_data_controller.rb +0 -76
- data/lib/test_pack_1/controllers/data_controller.rb +0 -349
- data/lib/test_pack_1/controllers/statuses_controller.rb +0 -215
- data/lib/test_pack_1/http/auth/custom_query_auth.rb +0 -16
- data/lib/test_pack_1/models/aggregate_mode_enum.rb +0 -23
- data/lib/test_pack_1/models/alert_item.rb +0 -104
- data/lib/test_pack_1/models/calculation_mode_enum.rb +0 -20
- data/lib/test_pack_1/models/client_configuration.rb +0 -62
- data/lib/test_pack_1/models/configuration_item.rb +0 -55
- data/lib/test_pack_1/models/data_item.rb +0 -92
- data/lib/test_pack_1/models/data_per_category_item.rb +0 -82
- data/lib/test_pack_1/models/data_per_category_response.rb +0 -63
- data/lib/test_pack_1/models/data_real_time_item.rb +0 -83
- data/lib/test_pack_1/models/data_signal.rb +0 -53
- data/lib/test_pack_1/models/data_signal_configuration.rb +0 -66
- data/lib/test_pack_1/models/data_signal_item.rb +0 -62
- data/lib/test_pack_1/models/device.rb +0 -208
- data/lib/test_pack_1/models/device_model.rb +0 -53
- data/lib/test_pack_1/models/metadata_field.rb +0 -44
- data/lib/test_pack_1/models/power_curve.rb +0 -60
- data/lib/test_pack_1/models/power_curve_value.rb +0 -44
- data/lib/test_pack_1/models/resolution_enum.rb +0 -41
- data/lib/test_pack_1/models/site.rb +0 -44
- data/lib/test_pack_1/models/site_with_data.rb +0 -78
- data/lib/test_pack_1/models/status_category_enum.rb +0 -26
- data/lib/test_pack_1/models/status_item.rb +0 -161
- data/lib/test_pack_1/models/time_zone_configuration.rb +0 -76
- data/lib/test_pack_1/models/turbine_type.rb +0 -89
- data/test/controllers/test_assets_controller.rb +0 -46
- data/test/controllers/test_configuration_data_controller.rb +0 -44
data/lib/test_pack_1.rb
CHANGED
@@ -20,34 +20,10 @@ require_relative 'test_pack1/http/http_request.rb'
|
|
20
20
|
require_relative 'test_pack1/http/http_response.rb'
|
21
21
|
require_relative 'test_pack1/http/http_context.rb'
|
22
22
|
require_relative 'test_pack1/http/faraday_client.rb'
|
23
|
-
require_relative 'test_pack1/http/auth/custom_query_auth.rb'
|
24
23
|
|
25
24
|
# Models
|
26
25
|
require_relative 'test_pack1/models/base_model.rb'
|
27
|
-
require_relative 'test_pack1/models/
|
28
|
-
require_relative 'test_pack1/models/device_model.rb'
|
29
|
-
require_relative 'test_pack1/models/power_curve_value.rb'
|
30
|
-
require_relative 'test_pack1/models/device.rb'
|
31
|
-
require_relative 'test_pack1/models/data_real_time_item.rb'
|
32
|
-
require_relative 'test_pack1/models/data_signal.rb'
|
33
|
-
require_relative 'test_pack1/models/data_item.rb'
|
34
|
-
require_relative 'test_pack1/models/status_item.rb'
|
35
|
-
require_relative 'test_pack1/models/metadata_field.rb'
|
36
|
-
require_relative 'test_pack1/models/site.rb'
|
37
|
-
require_relative 'test_pack1/models/configuration_item.rb'
|
38
|
-
require_relative 'test_pack1/models/turbine_type.rb'
|
39
|
-
require_relative 'test_pack1/models/power_curve.rb'
|
40
|
-
require_relative 'test_pack1/models/site_with_data.rb'
|
41
|
-
require_relative 'test_pack1/models/data_signal_item.rb'
|
42
|
-
require_relative 'test_pack1/models/data_signal_configuration.rb'
|
43
|
-
require_relative 'test_pack1/models/data_per_category_item.rb'
|
44
|
-
require_relative 'test_pack1/models/client_configuration.rb'
|
45
|
-
require_relative 'test_pack1/models/time_zone_configuration.rb'
|
46
|
-
require_relative 'test_pack1/models/alert_item.rb'
|
47
|
-
require_relative 'test_pack1/models/status_category_enum.rb'
|
48
|
-
require_relative 'test_pack1/models/calculation_mode_enum.rb'
|
49
|
-
require_relative 'test_pack1/models/aggregate_mode_enum.rb'
|
50
|
-
require_relative 'test_pack1/models/resolution_enum.rb'
|
26
|
+
require_relative 'test_pack1/models/operation_type_enum.rb'
|
51
27
|
|
52
28
|
# Exceptions
|
53
29
|
require_relative 'test_pack1/exceptions/api_exception.rb'
|
@@ -56,8 +32,4 @@ require_relative 'test_pack1/configuration.rb'
|
|
56
32
|
|
57
33
|
# Controllers
|
58
34
|
require_relative 'test_pack1/controllers/base_controller.rb'
|
59
|
-
require_relative 'test_pack1/controllers/
|
60
|
-
require_relative 'test_pack1/controllers/data_controller.rb'
|
61
|
-
require_relative 'test_pack1/controllers/alerts_controller.rb'
|
62
|
-
require_relative 'test_pack1/controllers/configuration_data_controller.rb'
|
63
|
-
require_relative 'test_pack1/controllers/assets_controller.rb'
|
35
|
+
require_relative 'test_pack1/controllers/simple_calculator_controller.rb'
|
@@ -14,27 +14,22 @@ module TestPack1
|
|
14
14
|
|
15
15
|
# An enum for SDK environments.
|
16
16
|
class Environment
|
17
|
-
#PRODUCTION:
|
17
|
+
#PRODUCTION: This environment connect to the LIVE calculator API
|
18
18
|
ENVIRONMENT = [PRODUCTION = 0].freeze
|
19
19
|
end
|
20
20
|
|
21
21
|
# An enum for API servers.
|
22
22
|
class Server
|
23
|
-
SERVER = [
|
23
|
+
SERVER = [CALCULATOR = 0].freeze
|
24
24
|
end
|
25
25
|
|
26
26
|
# The environment in which the SDK is running.
|
27
27
|
@environment = Environment::PRODUCTION
|
28
28
|
|
29
|
-
# TODO: Set an appropriate value.
|
30
|
-
@customer = 'intro'
|
31
|
-
|
32
|
-
@api_token = 'TODO: Replace'
|
33
|
-
|
34
29
|
# All the environments the SDK can run in.
|
35
30
|
@environments = {
|
36
31
|
Environment::PRODUCTION => {
|
37
|
-
Server::
|
32
|
+
Server::CALCULATOR => 'http://examples.apimatic.io/apps/calculator'
|
38
33
|
}
|
39
34
|
}
|
40
35
|
|
@@ -42,13 +37,8 @@ module TestPack1
|
|
42
37
|
# @param [Configuration::Server] The server enum for which the base URI is
|
43
38
|
# required.
|
44
39
|
# @return [String] The base URI.
|
45
|
-
def self.get_base_uri(server = Server::
|
46
|
-
|
47
|
-
'customer' => customer
|
48
|
-
}
|
49
|
-
APIHelper.append_url_with_template_parameters(
|
50
|
-
environments[environment][server], parameters
|
51
|
-
)
|
40
|
+
def self.get_base_uri(server = Server::CALCULATOR)
|
41
|
+
environments[environment][server].clone
|
52
42
|
end
|
53
43
|
|
54
44
|
# The attribute accessors for public properties.
|
@@ -56,8 +46,6 @@ module TestPack1
|
|
56
46
|
attr_accessor :array_serialization
|
57
47
|
attr_accessor :environment
|
58
48
|
attr_accessor :environments
|
59
|
-
attr_accessor :customer
|
60
|
-
attr_accessor :api_token
|
61
49
|
end
|
62
50
|
end
|
63
51
|
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
|
+
# SimpleCalculatorController
|
8
|
+
class SimpleCalculatorController < BaseController
|
9
|
+
@instance = SimpleCalculatorController.new
|
10
|
+
|
11
|
+
class << self
|
12
|
+
attr_accessor :instance
|
13
|
+
end
|
14
|
+
|
15
|
+
def instance
|
16
|
+
self.class.instance
|
17
|
+
end
|
18
|
+
|
19
|
+
# Calculates the expression using the specified operation.
|
20
|
+
# @param [OperationTypeEnum] operation Required parameter: The operator to
|
21
|
+
# apply on the variables
|
22
|
+
# @param [Float] x Required parameter: The LHS value
|
23
|
+
# @param [Float] y Required parameter: The RHS value
|
24
|
+
# @return Float response from the API call
|
25
|
+
def get_calculate(options = {})
|
26
|
+
# Prepare query url.
|
27
|
+
_path_url = '/{operation}'
|
28
|
+
_path_url = APIHelper.append_url_with_template_parameters(
|
29
|
+
_path_url,
|
30
|
+
'operation' => options['operation']
|
31
|
+
)
|
32
|
+
_query_builder = Configuration.get_base_uri
|
33
|
+
_query_builder << _path_url
|
34
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
35
|
+
_query_builder,
|
36
|
+
{
|
37
|
+
'x' => options['x'],
|
38
|
+
'y' => options['y']
|
39
|
+
},
|
40
|
+
array_serialization: Configuration.array_serialization
|
41
|
+
)
|
42
|
+
_query_url = APIHelper.clean_url _query_builder
|
43
|
+
# Prepare and execute HttpRequest.
|
44
|
+
_request = @http_client.get(
|
45
|
+
_query_url
|
46
|
+
)
|
47
|
+
_context = execute_request(_request)
|
48
|
+
validate_response(_context)
|
49
|
+
# Return appropriate response type.
|
50
|
+
_context.response.raw_body.to_f
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# test_pack_1
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0 (
|
4
|
+
# https://apimatic.io ).
|
5
|
+
|
6
|
+
module TestPack1
|
7
|
+
# Possible operators are sum, subtract, multiply, divide
|
8
|
+
class OperationTypeEnum
|
9
|
+
OPERATION_TYPE_ENUM = [
|
10
|
+
# Represents the sum operator
|
11
|
+
SUM = 'SUM'.freeze,
|
12
|
+
|
13
|
+
# Represents the subtract operator
|
14
|
+
SUBTRACT = 'SUBTRACT'.freeze,
|
15
|
+
|
16
|
+
# Represents the multiply operator
|
17
|
+
MULTIPLY = 'MULTIPLY'.freeze,
|
18
|
+
|
19
|
+
# Represents the divide operator
|
20
|
+
DIVIDE = 'DIVIDE'.freeze
|
21
|
+
].freeze
|
22
|
+
end
|
23
|
+
end
|
@@ -6,34 +6,10 @@
|
|
6
6
|
module TestPack1
|
7
7
|
# test_pack_1 client class.
|
8
8
|
class TestPack1Client
|
9
|
-
# Singleton access to
|
10
|
-
# @return [
|
11
|
-
def
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
# Singleton access to data controller.
|
16
|
-
# @return [DataController] Returns the controller instance.
|
17
|
-
def data
|
18
|
-
DataController.instance
|
19
|
-
end
|
20
|
-
|
21
|
-
# Singleton access to alerts controller.
|
22
|
-
# @return [AlertsController] Returns the controller instance.
|
23
|
-
def alerts
|
24
|
-
AlertsController.instance
|
25
|
-
end
|
26
|
-
|
27
|
-
# Singleton access to configuration_data controller.
|
28
|
-
# @return [ConfigurationDataController] Returns the controller instance.
|
29
|
-
def configuration_data
|
30
|
-
ConfigurationDataController.instance
|
31
|
-
end
|
32
|
-
|
33
|
-
# Singleton access to assets controller.
|
34
|
-
# @return [AssetsController] Returns the controller instance.
|
35
|
-
def assets
|
36
|
-
AssetsController.instance
|
9
|
+
# Singleton access to simple_calculator controller.
|
10
|
+
# @return [SimpleCalculatorController] Returns the controller instance.
|
11
|
+
def simple_calculator
|
12
|
+
SimpleCalculatorController.instance
|
37
13
|
end
|
38
14
|
|
39
15
|
# Returns the configuration class for easy access.
|
@@ -41,11 +17,5 @@ module TestPack1
|
|
41
17
|
def config
|
42
18
|
Configuration
|
43
19
|
end
|
44
|
-
|
45
|
-
# Initializer with authentication and configuration parameters.
|
46
|
-
def initialize(api_token: nil)
|
47
|
-
Configuration.api_token = api_token if
|
48
|
-
api_token
|
49
|
-
end
|
50
20
|
end
|
51
21
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# test_pack_1
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0 (
|
4
|
+
# https://apimatic.io ).
|
5
|
+
|
6
|
+
require_relative 'controller_test_base'
|
7
|
+
|
8
|
+
class SimpleCalculatorControllerTests < ControllerTestBase
|
9
|
+
# Called only once for the class before any test has executed
|
10
|
+
def self.startup
|
11
|
+
self.controller = @@api_client.simple_calculator
|
12
|
+
end
|
13
|
+
|
14
|
+
# Check if multiplication works
|
15
|
+
def test_multiply()
|
16
|
+
# Parameters for the API call
|
17
|
+
options = {}
|
18
|
+
options['operation'] = 'MULTIPLY'
|
19
|
+
options['x'] = 4
|
20
|
+
options['y'] = 5
|
21
|
+
|
22
|
+
# Perform the API call through the SDK function
|
23
|
+
result = self.class.controller.get_calculate(options)
|
24
|
+
|
25
|
+
# Test response code
|
26
|
+
assert_equal(@response_catcher.response.status_code, 200)
|
27
|
+
|
28
|
+
# Test whether the captured response is as we expected
|
29
|
+
assert_not_nil(result)
|
30
|
+
assert_equal('20', @response_catcher.response.raw_body)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-pack-1
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- APIMatic SDK Generator
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-09-
|
11
|
+
date: 2020-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|
@@ -106,36 +106,7 @@ dependencies:
|
|
106
106
|
- - ">="
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: 1.2.2
|
109
|
-
description:
|
110
|
-
is the beta version of the API,** containing new features that might change. This
|
111
|
-
means that any SDKs downloaded for this version might have minor incompatibilities
|
112
|
-
in the future. If you want to view the latest stable API specification, use the
|
113
|
-
version selection dropdown in the top right of the page. # What''s new ## 2020-06-08
|
114
|
-
– Data endpoint aggregation by group If you have divided you sites into groups of
|
115
|
-
assets, you can now aggregate your data by those groups when calling the Data, Real
|
116
|
-
Time Data, and Data Per Category endpoints. The new `deviceLevel` aggregation mode
|
117
|
-
(`aggregate` parameter) aggregates data based on the hierarchy level directly below
|
118
|
-
site. ## 2020-04-27 – Data signal permissions It is now possible to set permissions
|
119
|
-
for individual data signals for API keys (**Share** > **API Keys** in the Greenbyte
|
120
|
-
Platform). When adding/editing an API key, there is a new option to select authorized
|
121
|
-
data signals in addition to the device selection. Leaving the signal selection blank
|
122
|
-
(nothing selected) gives permission to all current and future data signals, just
|
123
|
-
like previously created API keys. API endpoints affected by data signal permissions:
|
124
|
-
* `datasignals.json`: filters returned data signals based on permissions. * `data.json`,
|
125
|
-
`realtimedata.json`, `datapercategory.json`: gives *401 Unauthorized* error for
|
126
|
-
data signals without permission. * `status.json`, `activestatus.json`: may omit
|
127
|
-
lost production values (in the `lostProduction` field) based on data signal permissions. ##
|
128
|
-
2020-03-30 – Data Per Category endpoint We have added a new endpoint to the Greenbyte
|
129
|
-
Platform to make it possible to extract Lost Production data per contract category
|
130
|
-
from the API. You can find more information about this endpoint here: [Data Per
|
131
|
-
Category](#/http/api-endpoints/data/get-data-per-category). # General notes regarding
|
132
|
-
endpoints * Endpoints that take `page` and `pageSize` parameters return a `Link`
|
133
|
-
header as defined in [RFC 8288](https://tools.ietf.org/html/rfc8288). * Some endpoints
|
134
|
-
return data in your local time zone. This time zone can be fetched from the `configuration.json`
|
135
|
-
endpoint. * All endpoints can also be reached using the POST method, with a JSON
|
136
|
-
request body instead of query parameters. * All endpoints implement rate limiting.
|
137
|
-
More information is available under the *429* error response description for each
|
138
|
-
endpoint. '
|
109
|
+
description: Simple calculator API hosted on APIMATIC
|
139
110
|
email: support@apimatic.io
|
140
111
|
executables: []
|
141
112
|
extensions: []
|
@@ -146,14 +117,9 @@ files:
|
|
146
117
|
- lib/test_pack_1.rb
|
147
118
|
- lib/test_pack_1/api_helper.rb
|
148
119
|
- lib/test_pack_1/configuration.rb
|
149
|
-
- lib/test_pack_1/controllers/alerts_controller.rb
|
150
|
-
- lib/test_pack_1/controllers/assets_controller.rb
|
151
120
|
- lib/test_pack_1/controllers/base_controller.rb
|
152
|
-
- lib/test_pack_1/controllers/
|
153
|
-
- lib/test_pack_1/controllers/data_controller.rb
|
154
|
-
- lib/test_pack_1/controllers/statuses_controller.rb
|
121
|
+
- lib/test_pack_1/controllers/simple_calculator_controller.rb
|
155
122
|
- lib/test_pack_1/exceptions/api_exception.rb
|
156
|
-
- lib/test_pack_1/http/auth/custom_query_auth.rb
|
157
123
|
- lib/test_pack_1/http/faraday_client.rb
|
158
124
|
- lib/test_pack_1/http/http_call_back.rb
|
159
125
|
- lib/test_pack_1/http/http_client.rb
|
@@ -161,35 +127,11 @@ files:
|
|
161
127
|
- lib/test_pack_1/http/http_method_enum.rb
|
162
128
|
- lib/test_pack_1/http/http_request.rb
|
163
129
|
- lib/test_pack_1/http/http_response.rb
|
164
|
-
- lib/test_pack_1/models/aggregate_mode_enum.rb
|
165
|
-
- lib/test_pack_1/models/alert_item.rb
|
166
130
|
- lib/test_pack_1/models/base_model.rb
|
167
|
-
- lib/test_pack_1/models/
|
168
|
-
- lib/test_pack_1/models/client_configuration.rb
|
169
|
-
- lib/test_pack_1/models/configuration_item.rb
|
170
|
-
- lib/test_pack_1/models/data_item.rb
|
171
|
-
- lib/test_pack_1/models/data_per_category_item.rb
|
172
|
-
- lib/test_pack_1/models/data_per_category_response.rb
|
173
|
-
- lib/test_pack_1/models/data_real_time_item.rb
|
174
|
-
- lib/test_pack_1/models/data_signal.rb
|
175
|
-
- lib/test_pack_1/models/data_signal_configuration.rb
|
176
|
-
- lib/test_pack_1/models/data_signal_item.rb
|
177
|
-
- lib/test_pack_1/models/device.rb
|
178
|
-
- lib/test_pack_1/models/device_model.rb
|
179
|
-
- lib/test_pack_1/models/metadata_field.rb
|
180
|
-
- lib/test_pack_1/models/power_curve.rb
|
181
|
-
- lib/test_pack_1/models/power_curve_value.rb
|
182
|
-
- lib/test_pack_1/models/resolution_enum.rb
|
183
|
-
- lib/test_pack_1/models/site.rb
|
184
|
-
- lib/test_pack_1/models/site_with_data.rb
|
185
|
-
- lib/test_pack_1/models/status_category_enum.rb
|
186
|
-
- lib/test_pack_1/models/status_item.rb
|
187
|
-
- lib/test_pack_1/models/time_zone_configuration.rb
|
188
|
-
- lib/test_pack_1/models/turbine_type.rb
|
131
|
+
- lib/test_pack_1/models/operation_type_enum.rb
|
189
132
|
- lib/test_pack_1/test_pack1_client.rb
|
190
133
|
- test/controllers/controller_test_base.rb
|
191
|
-
- test/controllers/
|
192
|
-
- test/controllers/test_configuration_data_controller.rb
|
134
|
+
- test/controllers/test_simple_calculator_controller.rb
|
193
135
|
- test/http_response_catcher.rb
|
194
136
|
- test/test_helper.rb
|
195
137
|
homepage: https://apimatic.io
|
@@ -1,381 +0,0 @@
|
|
1
|
-
# test_pack_1
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0 (
|
4
|
-
# https://apimatic.io ).
|
5
|
-
|
6
|
-
module TestPack1
|
7
|
-
# AlertsController
|
8
|
-
class AlertsController < BaseController
|
9
|
-
@instance = AlertsController.new
|
10
|
-
|
11
|
-
class << self
|
12
|
-
attr_accessor :instance
|
13
|
-
end
|
14
|
-
|
15
|
-
def instance
|
16
|
-
self.class.instance
|
17
|
-
end
|
18
|
-
|
19
|
-
# _This endpoint is deprecated. Please use the new endpoint
|
20
|
-
# `/activealerts.json` instead._
|
21
|
-
# @param [List of Integer] device_ids Required parameter: What devices to
|
22
|
-
# get alerts for.
|
23
|
-
# @param [List of String] fields Optional parameter: Which fields to include
|
24
|
-
# in the response. Valid fields are those defined in the `AlertItem` schema.
|
25
|
-
# By default all fields are included.
|
26
|
-
# @param [List of String] sort_by Optional parameter: Which fields to sort
|
27
|
-
# the response items by. By default the items are sorted by
|
28
|
-
# timestampStart.
|
29
|
-
# @param [Boolean] sort_asc Optional parameter: Whether to sort the items in
|
30
|
-
# ascending order.
|
31
|
-
# @param [Integer] page_size Optional parameter: The number of items to
|
32
|
-
# return per page.
|
33
|
-
# @param [Integer] page Optional parameter: Which page to return when the
|
34
|
-
# number of items exceed the page size.
|
35
|
-
# @return List of AlertItem response from the API call
|
36
|
-
def get_active_alarms(device_ids,
|
37
|
-
fields = nil,
|
38
|
-
sort_by = nil,
|
39
|
-
sort_asc = false,
|
40
|
-
page_size = 50,
|
41
|
-
page = 1)
|
42
|
-
# Prepare query url.
|
43
|
-
_path_url = '/activealarms.json'
|
44
|
-
_query_builder = Configuration.get_base_uri
|
45
|
-
_query_builder << _path_url
|
46
|
-
_query_builder = APIHelper.append_url_with_query_parameters(
|
47
|
-
_query_builder,
|
48
|
-
{
|
49
|
-
'deviceIds' => device_ids,
|
50
|
-
'fields' => fields,
|
51
|
-
'sortBy' => sort_by,
|
52
|
-
'sortAsc' => sort_asc,
|
53
|
-
'pageSize' => page_size,
|
54
|
-
'page' => page
|
55
|
-
},
|
56
|
-
array_serialization: Configuration.array_serialization
|
57
|
-
)
|
58
|
-
_query_url = APIHelper.clean_url _query_builder
|
59
|
-
# Prepare headers.
|
60
|
-
_headers = {
|
61
|
-
'accept' => 'application/json'
|
62
|
-
}
|
63
|
-
# Prepare and execute HttpRequest.
|
64
|
-
_request = @http_client.get(
|
65
|
-
_query_url,
|
66
|
-
headers: _headers
|
67
|
-
)
|
68
|
-
CustomQueryAuth.apply(_request)
|
69
|
-
_context = execute_request(_request)
|
70
|
-
# Validate response against endpoint and global error codes.
|
71
|
-
if _context.response.status_code == 400
|
72
|
-
raise APIException.new(
|
73
|
-
'The request cannot be fulfilled due to bad syntax.',
|
74
|
-
_context
|
75
|
-
)
|
76
|
-
elsif _context.response.status_code == 401
|
77
|
-
raise APIException.new(
|
78
|
-
'One of the following: * The request is missing a valid API key. *' \
|
79
|
-
' The API key does not authorize access the requested' \
|
80
|
-
' data. Devices or data signals can be limited. ',
|
81
|
-
_context
|
82
|
-
)
|
83
|
-
elsif _context.response.status_code == 405
|
84
|
-
raise APIException.new(
|
85
|
-
'The HTTP method is not allowed for the endpoint.',
|
86
|
-
_context
|
87
|
-
)
|
88
|
-
elsif _context.response.status_code == 429
|
89
|
-
raise APIException.new(
|
90
|
-
'The API key has been used in too many requests in a given amount' \
|
91
|
-
' of time. The following headers will be set in the' \
|
92
|
-
' response: * X-Rate-Limit-Limit - The total number of' \
|
93
|
-
' allowed requests for this period. *' \
|
94
|
-
' X-Rate-Limit-Remaining - The remaining number of' \
|
95
|
-
' requests for this period. * X-Rate-Limit-Reset - The' \
|
96
|
-
' number of seconds left until the end of this period. ',
|
97
|
-
_context
|
98
|
-
)
|
99
|
-
end
|
100
|
-
validate_response(_context)
|
101
|
-
# Return appropriate response type.
|
102
|
-
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
103
|
-
decoded.map { |element| AlertItem.from_hash(element) }
|
104
|
-
end
|
105
|
-
|
106
|
-
# Gets active alerts for multiple devices.
|
107
|
-
# @param [List of Integer] device_ids Required parameter: What devices to
|
108
|
-
# get alerts for.
|
109
|
-
# @param [List of String] fields Optional parameter: Which fields to include
|
110
|
-
# in the response. Valid fields are those defined in the `AlertItem` schema.
|
111
|
-
# By default all fields are included.
|
112
|
-
# @param [List of String] sort_by Optional parameter: Which fields to sort
|
113
|
-
# the response items by. By default the items are sorted by
|
114
|
-
# timestampStart.
|
115
|
-
# @param [Boolean] sort_asc Optional parameter: Whether to sort the items in
|
116
|
-
# ascending order.
|
117
|
-
# @param [Integer] page_size Optional parameter: The number of items to
|
118
|
-
# return per page.
|
119
|
-
# @param [Integer] page Optional parameter: Which page to return when the
|
120
|
-
# number of items exceed the page size.
|
121
|
-
# @return List of AlertItem response from the API call
|
122
|
-
def get_active_alerts(device_ids,
|
123
|
-
fields = nil,
|
124
|
-
sort_by = nil,
|
125
|
-
sort_asc = false,
|
126
|
-
page_size = 50,
|
127
|
-
page = 1)
|
128
|
-
# Prepare query url.
|
129
|
-
_path_url = '/activealerts.json'
|
130
|
-
_query_builder = Configuration.get_base_uri
|
131
|
-
_query_builder << _path_url
|
132
|
-
_query_builder = APIHelper.append_url_with_query_parameters(
|
133
|
-
_query_builder,
|
134
|
-
{
|
135
|
-
'deviceIds' => device_ids,
|
136
|
-
'fields' => fields,
|
137
|
-
'sortBy' => sort_by,
|
138
|
-
'sortAsc' => sort_asc,
|
139
|
-
'pageSize' => page_size,
|
140
|
-
'page' => page
|
141
|
-
},
|
142
|
-
array_serialization: Configuration.array_serialization
|
143
|
-
)
|
144
|
-
_query_url = APIHelper.clean_url _query_builder
|
145
|
-
# Prepare headers.
|
146
|
-
_headers = {
|
147
|
-
'accept' => 'application/json'
|
148
|
-
}
|
149
|
-
# Prepare and execute HttpRequest.
|
150
|
-
_request = @http_client.get(
|
151
|
-
_query_url,
|
152
|
-
headers: _headers
|
153
|
-
)
|
154
|
-
CustomQueryAuth.apply(_request)
|
155
|
-
_context = execute_request(_request)
|
156
|
-
# Validate response against endpoint and global error codes.
|
157
|
-
if _context.response.status_code == 400
|
158
|
-
raise APIException.new(
|
159
|
-
'The request cannot be fulfilled due to bad syntax.',
|
160
|
-
_context
|
161
|
-
)
|
162
|
-
elsif _context.response.status_code == 401
|
163
|
-
raise APIException.new(
|
164
|
-
'One of the following: * The request is missing a valid API key. *' \
|
165
|
-
' The API key does not authorize access the requested' \
|
166
|
-
' data. Devices or data signals can be limited. ',
|
167
|
-
_context
|
168
|
-
)
|
169
|
-
elsif _context.response.status_code == 405
|
170
|
-
raise APIException.new(
|
171
|
-
'The HTTP method is not allowed for the endpoint.',
|
172
|
-
_context
|
173
|
-
)
|
174
|
-
elsif _context.response.status_code == 429
|
175
|
-
raise APIException.new(
|
176
|
-
'The API key has been used in too many requests in a given amount' \
|
177
|
-
' of time. The following headers will be set in the' \
|
178
|
-
' response: * X-Rate-Limit-Limit - The total number of' \
|
179
|
-
' allowed requests for this period. *' \
|
180
|
-
' X-Rate-Limit-Remaining - The remaining number of' \
|
181
|
-
' requests for this period. * X-Rate-Limit-Reset - The' \
|
182
|
-
' number of seconds left until the end of this period. ',
|
183
|
-
_context
|
184
|
-
)
|
185
|
-
end
|
186
|
-
validate_response(_context)
|
187
|
-
# Return appropriate response type.
|
188
|
-
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
189
|
-
decoded.map { |element| AlertItem.from_hash(element) }
|
190
|
-
end
|
191
|
-
|
192
|
-
# Gets alerts for multiple devices and the given time period.
|
193
|
-
# @param [List of Integer] device_ids Required parameter: What devices to
|
194
|
-
# get alerts for.
|
195
|
-
# @param [DateTime] timestamp_start Required parameter: The first timestamp
|
196
|
-
# to get data for.
|
197
|
-
# @param [DateTime] timestamp_end Required parameter: The last timestamp to
|
198
|
-
# get data for.
|
199
|
-
# @param [List of String] fields Optional parameter: Which fields to include
|
200
|
-
# in the response. Valid fields are those defined in the `AlertItem` schema.
|
201
|
-
# By default all fields are included.
|
202
|
-
# @param [List of String] sort_by Optional parameter: Which fields to sort
|
203
|
-
# the response items by. By default the items are sorted by
|
204
|
-
# timestampStart.
|
205
|
-
# @param [Boolean] sort_asc Optional parameter: Whether to sort the items in
|
206
|
-
# ascending order.
|
207
|
-
# @param [Integer] page_size Optional parameter: The number of items to
|
208
|
-
# return per page.
|
209
|
-
# @param [Integer] page Optional parameter: Which page to return when the
|
210
|
-
# number of items exceed the page size.
|
211
|
-
# @return List of AlertItem response from the API call
|
212
|
-
def get_alerts(device_ids,
|
213
|
-
timestamp_start,
|
214
|
-
timestamp_end,
|
215
|
-
fields = nil,
|
216
|
-
sort_by = nil,
|
217
|
-
sort_asc = false,
|
218
|
-
page_size = 50,
|
219
|
-
page = 1)
|
220
|
-
# Prepare query url.
|
221
|
-
_path_url = '/alerts.json'
|
222
|
-
_query_builder = Configuration.get_base_uri
|
223
|
-
_query_builder << _path_url
|
224
|
-
_query_builder = APIHelper.append_url_with_query_parameters(
|
225
|
-
_query_builder,
|
226
|
-
{
|
227
|
-
'deviceIds' => device_ids,
|
228
|
-
'timestampStart' => timestamp_start,
|
229
|
-
'timestampEnd' => timestamp_end,
|
230
|
-
'fields' => fields,
|
231
|
-
'sortBy' => sort_by,
|
232
|
-
'sortAsc' => sort_asc,
|
233
|
-
'pageSize' => page_size,
|
234
|
-
'page' => page
|
235
|
-
},
|
236
|
-
array_serialization: Configuration.array_serialization
|
237
|
-
)
|
238
|
-
_query_url = APIHelper.clean_url _query_builder
|
239
|
-
# Prepare headers.
|
240
|
-
_headers = {
|
241
|
-
'accept' => 'application/json'
|
242
|
-
}
|
243
|
-
# Prepare and execute HttpRequest.
|
244
|
-
_request = @http_client.get(
|
245
|
-
_query_url,
|
246
|
-
headers: _headers
|
247
|
-
)
|
248
|
-
CustomQueryAuth.apply(_request)
|
249
|
-
_context = execute_request(_request)
|
250
|
-
# Validate response against endpoint and global error codes.
|
251
|
-
if _context.response.status_code == 400
|
252
|
-
raise APIException.new(
|
253
|
-
'The request cannot be fulfilled due to bad syntax.',
|
254
|
-
_context
|
255
|
-
)
|
256
|
-
elsif _context.response.status_code == 401
|
257
|
-
raise APIException.new(
|
258
|
-
'One of the following: * The request is missing a valid API key. *' \
|
259
|
-
' The API key does not authorize access the requested' \
|
260
|
-
' data. Devices or data signals can be limited. ',
|
261
|
-
_context
|
262
|
-
)
|
263
|
-
elsif _context.response.status_code == 405
|
264
|
-
raise APIException.new(
|
265
|
-
'The HTTP method is not allowed for the endpoint.',
|
266
|
-
_context
|
267
|
-
)
|
268
|
-
elsif _context.response.status_code == 429
|
269
|
-
raise APIException.new(
|
270
|
-
'The API key has been used in too many requests in a given amount' \
|
271
|
-
' of time. The following headers will be set in the' \
|
272
|
-
' response: * X-Rate-Limit-Limit - The total number of' \
|
273
|
-
' allowed requests for this period. *' \
|
274
|
-
' X-Rate-Limit-Remaining - The remaining number of' \
|
275
|
-
' requests for this period. * X-Rate-Limit-Reset - The' \
|
276
|
-
' number of seconds left until the end of this period. ',
|
277
|
-
_context
|
278
|
-
)
|
279
|
-
end
|
280
|
-
validate_response(_context)
|
281
|
-
# Return appropriate response type.
|
282
|
-
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
283
|
-
decoded.map { |element| AlertItem.from_hash(element) }
|
284
|
-
end
|
285
|
-
|
286
|
-
# _This endpoint is deprecated. Please use the new endpoint `/alerts.json`
|
287
|
-
# instead._
|
288
|
-
# @param [List of Integer] device_ids Required parameter: What devices to
|
289
|
-
# get alerts for.
|
290
|
-
# @param [DateTime] timestamp_start Required parameter: The first timestamp
|
291
|
-
# to get data for.
|
292
|
-
# @param [DateTime] timestamp_end Required parameter: The last timestamp to
|
293
|
-
# get data for.
|
294
|
-
# @param [List of String] fields Optional parameter: Which fields to include
|
295
|
-
# in the response. Valid fields are those defined in the `AlertItem` schema.
|
296
|
-
# By default all fields are included.
|
297
|
-
# @param [List of String] sort_by Optional parameter: Which fields to sort
|
298
|
-
# the response items by. By default the items are sorted by
|
299
|
-
# timestampStart.
|
300
|
-
# @param [Boolean] sort_asc Optional parameter: Whether to sort the items in
|
301
|
-
# ascending order.
|
302
|
-
# @param [Integer] page_size Optional parameter: The number of items to
|
303
|
-
# return per page.
|
304
|
-
# @param [Integer] page Optional parameter: Which page to return when the
|
305
|
-
# number of items exceed the page size.
|
306
|
-
# @return List of AlertItem response from the API call
|
307
|
-
def get_alarms(device_ids,
|
308
|
-
timestamp_start,
|
309
|
-
timestamp_end,
|
310
|
-
fields = nil,
|
311
|
-
sort_by = nil,
|
312
|
-
sort_asc = false,
|
313
|
-
page_size = 50,
|
314
|
-
page = 1)
|
315
|
-
# Prepare query url.
|
316
|
-
_path_url = '/alarms.json'
|
317
|
-
_query_builder = Configuration.get_base_uri
|
318
|
-
_query_builder << _path_url
|
319
|
-
_query_builder = APIHelper.append_url_with_query_parameters(
|
320
|
-
_query_builder,
|
321
|
-
{
|
322
|
-
'deviceIds' => device_ids,
|
323
|
-
'timestampStart' => timestamp_start,
|
324
|
-
'timestampEnd' => timestamp_end,
|
325
|
-
'fields' => fields,
|
326
|
-
'sortBy' => sort_by,
|
327
|
-
'sortAsc' => sort_asc,
|
328
|
-
'pageSize' => page_size,
|
329
|
-
'page' => page
|
330
|
-
},
|
331
|
-
array_serialization: Configuration.array_serialization
|
332
|
-
)
|
333
|
-
_query_url = APIHelper.clean_url _query_builder
|
334
|
-
# Prepare headers.
|
335
|
-
_headers = {
|
336
|
-
'accept' => 'application/json'
|
337
|
-
}
|
338
|
-
# Prepare and execute HttpRequest.
|
339
|
-
_request = @http_client.get(
|
340
|
-
_query_url,
|
341
|
-
headers: _headers
|
342
|
-
)
|
343
|
-
CustomQueryAuth.apply(_request)
|
344
|
-
_context = execute_request(_request)
|
345
|
-
# Validate response against endpoint and global error codes.
|
346
|
-
if _context.response.status_code == 400
|
347
|
-
raise APIException.new(
|
348
|
-
'The request cannot be fulfilled due to bad syntax.',
|
349
|
-
_context
|
350
|
-
)
|
351
|
-
elsif _context.response.status_code == 401
|
352
|
-
raise APIException.new(
|
353
|
-
'One of the following: * The request is missing a valid API key. *' \
|
354
|
-
' The API key does not authorize access the requested' \
|
355
|
-
' data. Devices or data signals can be limited. ',
|
356
|
-
_context
|
357
|
-
)
|
358
|
-
elsif _context.response.status_code == 405
|
359
|
-
raise APIException.new(
|
360
|
-
'The HTTP method is not allowed for the endpoint.',
|
361
|
-
_context
|
362
|
-
)
|
363
|
-
elsif _context.response.status_code == 429
|
364
|
-
raise APIException.new(
|
365
|
-
'The API key has been used in too many requests in a given amount' \
|
366
|
-
' of time. The following headers will be set in the' \
|
367
|
-
' response: * X-Rate-Limit-Limit - The total number of' \
|
368
|
-
' allowed requests for this period. *' \
|
369
|
-
' X-Rate-Limit-Remaining - The remaining number of' \
|
370
|
-
' requests for this period. * X-Rate-Limit-Reset - The' \
|
371
|
-
' number of seconds left until the end of this period. ',
|
372
|
-
_context
|
373
|
-
)
|
374
|
-
end
|
375
|
-
validate_response(_context)
|
376
|
-
# Return appropriate response type.
|
377
|
-
decoded = APIHelper.json_deserialize(_context.response.raw_body)
|
378
|
-
decoded.map { |element| AlertItem.from_hash(element) }
|
379
|
-
end
|
380
|
-
end
|
381
|
-
end
|