Class: Verizon::APIController
- Inherits:
-
BaseController
- Object
- BaseController
- Verizon::APIController
- Defined in:
- lib/verizon/controllers/api_controller.rb
Overview
APIController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_configuration(vendor_id, body) ⇒ ApiResponse
This endpoint creates a new configuration in the system.
-
#delete_configuration(vendor_id, id) ⇒ ApiResponse
This endpoint deletes a specific configuration from the system.
-
#get_configuration(id, vendor_id) ⇒ ApiResponse
This endpoint fetches and returns a specific configuration’s details.
-
#get_configuration_list(vendor_id) ⇒ ApiResponse
This endpoint fetches and returns the list of configurations defined by the Vendor.
-
#get_etx_device_certificate(etx_id, x_transaction_id: nil) ⇒ ApiResponse
With this API call the user can check the certificate of the device.
-
#register_etx_device(body, x_transaction_id: nil) ⇒ ApiResponse
With this API call the user (client) registers its device or software service to the ETX system.
-
#renew_etx_device(etx_device_id, etx_vendor_id, x_transaction_id: nil, body: nil) ⇒ ApiResponse
With this API call the user (client) can: - renew the certificate of a device or software service in the ETX system if the original certificate has expired.
-
#retrieve_mqtturl(etx_vendor_id, body, x_transaction_id: nil) ⇒ ApiResponse
With this API call the device or software service requests the MQTT URL for the location that it needs to connect.
-
#retrieve_mqtturl_multi_mec(etx_vendor_id, body, x_transaction_id: nil) ⇒ ApiResponse
With this API call the device or software service requests the MQTT URL for the location that it needs to connect.
-
#unregister_etx_device(etx_vendor_id, device_i_ds, x_transaction_id: nil) ⇒ ApiResponse
With this API call the user (client) can unregister its devices and software services from the ETX system.
-
#update_configuration(vendor_id, id, body) ⇒ ApiResponse
This endpoint updates an existing configuration.
Methods inherited from BaseController
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent
Constructor Details
This class inherits a constructor from Verizon::BaseController
Instance Method Details
#create_configuration(vendor_id, body) ⇒ ApiResponse
This endpoint creates a new configuration in the system. The data for the new configuration should be provided as JSON in the body of the POST request. The system will return with a unique ID for the configuration, which is needed for any further manipulation (update or delete) of the configuration. Note: The user needs to authenticate with their ThingSpace credentials using the Access/Bearer and Session/M2M tokens in order to call this API. description here
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 119 120 121 122 123 |
# File 'lib/verizon/controllers/api_controller.rb', line 94 def create_configuration(vendor_id, body) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/api/v1/application/configurations/geofence', Server::IMP_SERVER) .header_param(new_parameter(vendor_id, key: 'VendorID')) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(And.new('thingspace_oauth', 'sessionToken'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GeoFenceConfigurationResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid configuration', EtxResponseErrorException) .local_error('403', 'Forbidden', EtxResponseErrorException) .local_error('429', 'Too many requests', EtxResponseErrorException) .local_error('default', 'unexpected error', EtxResponseErrorException)) .execute end |
#delete_configuration(vendor_id, id) ⇒ ApiResponse
This endpoint deletes a specific configuration from the system. It requires the configuration ID parameter, which was provided by the POST (create) operation. Note: The user needs to authenticate with their ThingSpace credentials using the Access/Bearer and Session/M2M tokens in order to call this API.
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/verizon/controllers/api_controller.rb', line 179 def delete_configuration(vendor_id, id) @api_call .request(new_request_builder(HttpMethodEnum::DELETE, '/api/v1/application/configurations/geofence', Server::IMP_SERVER) .header_param(new_parameter(vendor_id, key: 'VendorID')) .query_param(new_parameter(id, key: 'id')) .auth(And.new('thingspace_oauth', 'sessionToken'))) .response(new_response_handler .is_response_void(true) .is_api_response(true) .local_error('403', 'Forbidden', EtxResponseErrorException) .local_error('429', 'Too many requests', EtxResponseErrorException) .local_error('default', 'unexpected error', EtxResponseErrorException)) .execute end |
#get_configuration(id, vendor_id) ⇒ ApiResponse
This endpoint fetches and returns a specific configuration’s details. The configuration ID parameter, which was provided when the configuration was created through the POST request, is need to retrieve the configuration details. Note: The user needs to authenticate with their ThingSpace credentials using the Access/Bearer and Session/M2M tokens in order to call this API.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/verizon/controllers/api_controller.rb', line 54 def get_configuration(id, vendor_id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/api/v1/application/configurations/geofence', Server::IMP_SERVER) .query_param(new_parameter(id, key: 'id')) .header_param(new_parameter(vendor_id, key: 'VendorID')) .header_param(new_parameter('application/json', key: 'accept')) .auth(And.new('thingspace_oauth', 'sessionToken'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GeoFenceConfigurationResponse.method(:from_hash)) .is_api_response(true) .local_error('403', 'Forbidden', EtxResponseErrorException) .local_error('404', 'Configuration not found', EtxResponseErrorException) .local_error('429', 'Too many requests', EtxResponseErrorException) .local_error('default', 'unexpected error', EtxResponseErrorException)) .execute end |
#get_configuration_list(vendor_id) ⇒ ApiResponse
This endpoint fetches and returns the list of configurations defined by the Vendor. The list contains the configurations’ identifier, name, description, and active flag. The vendor ID is provided when the configuration is created through the POST request. Note: The user needs to authenticate with their ThingSpace credentials using the Access/Bearer and Session/M2M tokens in order to call this API.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/verizon/controllers/api_controller.rb', line 17 def get_configuration_list(vendor_id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/api/v1/application/configurations/geofence/ids', Server::IMP_SERVER) .header_param(new_parameter(vendor_id, key: 'VendorID')) .header_param(new_parameter('application/json', key: 'accept')) .auth(And.new('thingspace_oauth', 'sessionToken'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ConfigurationListItem.method(:from_hash)) .is_api_response(true) .is_response_array(true) .local_error('403', 'Forbidden', EtxResponseErrorException) .local_error('404', 'Configuration not found', EtxResponseErrorException) .local_error('429', 'Too many requests', EtxResponseErrorException) .local_error('default', 'unexpected error', EtxResponseErrorException)) .execute end |
#get_etx_device_certificate(etx_id, x_transaction_id: nil) ⇒ ApiResponse
With this API call the user can check the certificate of the device. At least one of the DeviceID, IMEI, ICCID or IMSI is required to make the call. Note: The user needs to authenticate with their ThingSpace credentials using the Access/Bearer and Session/M2M tokens in order to call this API. required- DeviceID, IMEI, ICCID, IMSI. If more than one ID is provided, the API will return the certificate for the first ID found. The IDs are evaluated in the following order: DeviceID, IMEI, ICCID, IMSI. If the first provided ID is not found, the API will return an error. transaction identifier for tracing requests. If not provided, the application will generate one.
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 |
# File 'lib/verizon/controllers/api_controller.rb', line 387 def get_etx_device_certificate(etx_id, x_transaction_id: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/api/v2/clients/registration', Server::IMP_SERVER) .query_param(new_parameter(etx_id, key: 'etxID')) .header_param(new_parameter(x_transaction_id, key: 'X-Transaction-Id')) .header_param(new_parameter('application/json', key: 'accept')) .auth(And.new('thingspace_oauth', 'sessionToken'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ClientPersistenceResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request', ETXRespondingErrorException) .local_error('401', 'Unauthorized', ETXRespondingErrorException) .local_error('403', 'Forbidden Request', ETXRespondingErrorException) .local_error('404', 'Not Found', ETXRespondingErrorException) .local_error('429', 'Too Many Requests', ETXRespondingErrorException) .local_error('500', 'Internal server Error', ETXRespondingErrorException) .local_error('default', 'Forbidden', ETXRespondingErrorException)) .execute end |
#register_etx_device(body, x_transaction_id: nil) ⇒ ApiResponse
With this API call the user (client) registers its device or software service to the ETX system. Therefore, when a connection is initiated from the device or software service to the ETX system along with the credential provided by this registration call, then the connection will be authorized.
-
The user can register multiple devices or software services, which can
all be used at the same time.
-
There rules set in the system that limit the type and subtype of the
clients that are allowed to be registered under the VendorID. The rules are created based ont he agreement between the Vendor and Verizon.
-
The user will only be able to register a limited number of devices or
software services under the same VendorID. This registration limit is specified by the agreement between the Vendor and Verizon. Note: The user needs to authenticate with their ThingSpace credentials using the Access/Bearer and Session/M2M tokens in order to call this API. description here transaction identifier for tracing requests. If not provided, the application will generate one.
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'lib/verizon/controllers/api_controller.rb', line 224 def register_etx_device(body, x_transaction_id: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/api/v2/clients/registration', Server::IMP_SERVER) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter(x_transaction_id, key: 'X-Transaction-Id')) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(And.new('thingspace_oauth', 'sessionToken'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ClientRegistrationResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid Request', ETXRespondingErrorException) .local_error('401', 'Unauthorized Request', ETXRespondingErrorException) .local_error('403', 'Forbidden Request', ETXRespondingErrorException) .local_error('429', 'Too Many Requests', ETXRespondingErrorException) .local_error('503', 'Internal Server Error', ETXRespondingErrorException) .local_error('default', 'Forbidden', ETXRespondingErrorException)) .execute end |
#renew_etx_device(etx_device_id, etx_vendor_id, x_transaction_id: nil, body: nil) ⇒ ApiResponse
With this API call the user (client) can:
-
renew the certificate of a device or software service in the ETX system
if the original certificate has expired. If the client’s certificate expired or going to expire within 30 days and new certificate will be issued. If the certificate expires more than 30 days, the current certificate will be returned to the client.
-
complete its device or software service registration to the ETX system
if the original registration request was not successful because of a pending certificate generation. Whenever the user receives a “client registration is pending” response (HTTP 202) from POST /clients/registration call. The client should initiate this PUT API call to finish the registration process and get the required certificate. Note: The user needs to authenticate with their ThingSpace credentials using the Access/Bearer and Session/M2M tokens in order to call this API. description here the Vendor registration call. transaction identifier for tracing requests. If not provided, the application will generate one.
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
# File 'lib/verizon/controllers/api_controller.rb', line 284 def renew_etx_device(etx_device_id, etx_vendor_id, x_transaction_id: nil, body: nil) @api_call .request(new_request_builder(HttpMethodEnum::PUT, '/api/v2/clients/registration', Server::IMP_SERVER) .header_param(new_parameter(etx_device_id, key: 'etxDeviceID')) .header_param(new_parameter(etx_vendor_id, key: 'etxVendorID')) .header_param(new_parameter('application/json', key: 'Content-Type')) .header_param(new_parameter(x_transaction_id, key: 'X-Transaction-Id')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(APIHelper.method(:json_serialize)) .auth(And.new('thingspace_oauth', 'sessionToken'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ClientRegistrationResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid Request', ETXRespondingErrorException) .local_error('401', 'Unauthorized Request', ETXRespondingErrorException) .local_error('403', 'Forbidden Request', ETXRespondingErrorException) .local_error('429', 'Too Many Requests', ETXRespondingErrorException) .local_error('503', 'Internal Server Error', ETXRespondingErrorException) .local_error('default', 'Forbidden', ETXRespondingErrorException)) .execute end |
#retrieve_mqtturl(etx_vendor_id, body, x_transaction_id: nil) ⇒ ApiResponse
With this API call the device or software service requests the MQTT URL for the location that it needs to connect. To determine the proper URL the device or software service needs to provide its ID (the one that was provided in the registration request), location (GPS coordinates), and whether it is on the Verizon cellular network or not. Note: The user needs to authenticate with their ThingSpace credentials using the Access/Bearer and Session/M2M tokens in order to call this API. the Vendor registration call. here transaction identifier for tracing requests. If not provided, the application will generate one.
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
# File 'lib/verizon/controllers/api_controller.rb', line 440 def retrieve_mqtturl(etx_vendor_id, body, x_transaction_id: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/api/v2/clients/connection', Server::IMP_SERVER) .header_param(new_parameter(etx_vendor_id, key: 'etxVendorID')) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter(x_transaction_id, key: 'X-Transaction-Id')) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(And.new('thingspace_oauth', 'sessionToken'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ConnectionResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request', ETXRespondingErrorException) .local_error('401', 'Unauthorized', ETXRespondingErrorException) .local_error('403', 'Forbidden Request', ETXRespondingErrorException) .local_error('429', 'Too Many Requests', ETXRespondingErrorException) .local_error('503', 'Internal server Error', ETXRespondingErrorException) .local_error('default', 'Forbidden', ETXRespondingErrorException)) .execute end |
#retrieve_mqtturl_multi_mec(etx_vendor_id, body, x_transaction_id: nil) ⇒ ApiResponse
With this API call the device or software service requests the MQTT URL for the location that it needs to connect. To determine the proper URL the device or software service needs to provide its ID (the one that was provided in the registration request), location (GPS coordinates), and whether it is on the Verizon cellular network or not. If there are multiple MECs that serve the location of the client all options are provided in the response, and the client is free to choose which MEC they want to connect. Note: The user needs to authenticate with their ThingSpace credentials using the Access/Bearer and Session/M2M tokens in order to call this API. the Vendor registration call. here transaction identifier for tracing requests. If not provided, the application will generate one.
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
# File 'lib/verizon/controllers/api_controller.rb', line 497 def retrieve_mqtturl_multi_mec(etx_vendor_id, body, x_transaction_id: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/api/v3/clients/connection', Server::IMP_SERVER) .header_param(new_parameter(etx_vendor_id, key: 'etxVendorID')) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter(x_transaction_id, key: 'X-Transaction-Id')) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(And.new('thingspace_oauth', 'sessionToken'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ConnectionResponseV3.method(:from_hash)) .is_api_response(true) .local_error('400', 'Invalid request', ETXRespondingErrorException) .local_error('401', 'Unauthorized', ETXRespondingErrorException) .local_error('403', 'Forbidden Request', ETXRespondingErrorException) .local_error('429', 'Too Many Requests', ETXRespondingErrorException) .local_error('503', 'Internal server Error', ETXRespondingErrorException) .local_error('default', 'Forbidden', ETXRespondingErrorException)) .execute end |
#unregister_etx_device(etx_vendor_id, device_i_ds, x_transaction_id: nil) ⇒ ApiResponse
With this API call the user (client) can unregister its devices and software services from the ETX system. The unregistered devices and services will no longer be able to use the ETX Message Exchange. Note: The user needs to authenticate with their ThingSpace credentials using the Access/Bearer and Session/M2M tokens in order to call this API. the Vendor registration call. device IDs and software service IDs to be unregistered transaction identifier for tracing requests. If not provided, the application will generate one.
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
# File 'lib/verizon/controllers/api_controller.rb', line 338 def unregister_etx_device(etx_vendor_id, device_i_ds, x_transaction_id: nil) @api_call .request(new_request_builder(HttpMethodEnum::DELETE, '/api/v2/clients/registration', Server::IMP_SERVER) .header_param(new_parameter(etx_vendor_id, key: 'etxVendorID')) .query_param(new_parameter(device_i_ds, key: 'DeviceIDs')) .header_param(new_parameter(x_transaction_id, key: 'X-Transaction-Id')) .auth(And.new('thingspace_oauth', 'sessionToken'))) .response(new_response_handler .is_response_void(true) .is_api_response(true) .local_error('400', 'Invalid Request', ETXRespondingErrorException) .local_error('401', 'Unauthorized Request', ETXRespondingErrorException) .local_error('403', 'Forbidden Request', ETXRespondingErrorException) .local_error('429', 'Too Many Requests', ETXRespondingErrorException) .local_error('503', 'Internal Server Error', ETXRespondingErrorException) .local_error('default', 'Forbidden', ETXRespondingErrorException)) .execute end |
#update_configuration(vendor_id, id, body) ⇒ ApiResponse
This endpoint updates an existing configuration. Similar to POST, the updated data for the configuration should be provided as JSON in the body of the PUT request. The configuration ID parameter, which was provided by the POST (create) operation, is required to do any updates on the configuration. Note: The user needs to authenticate with their ThingSpace credentials using the Access/Bearer and Session/M2M tokens in order to call this API. type description here
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/verizon/controllers/api_controller.rb', line 137 def update_configuration(vendor_id, id, body) @api_call .request(new_request_builder(HttpMethodEnum::PUT, '/api/v1/application/configurations/geofence', Server::IMP_SERVER) .header_param(new_parameter(vendor_id, key: 'VendorID')) .query_param(new_parameter(id, key: 'id')) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(And.new('thingspace_oauth', 'sessionToken'))) .response(new_response_handler .is_response_void(true) .is_api_response(true) .local_error('400', 'Invalid configuration', EtxResponseErrorException) .local_error('403', 'Forbidden', EtxResponseErrorException) .local_error('404', 'Configuration not found', EtxResponseErrorException) .local_error('429', 'Too many requests', EtxResponseErrorException) .local_error('default', 'unexpected error', EtxResponseErrorException)) .execute end |