Class: Verizon::CloudConnectorSubscriptionsController

Inherits:
BaseController
  • Object
show all
Defined in:
lib/verizon/controllers/cloud_connector_subscriptions_controller.rb

Overview

CloudConnectorSubscriptionsController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent

Constructor Details

This class inherits a constructor from Verizon::BaseController

Instance Method Details

#create_subscription(body) ⇒ Subscription

Create a subscription to define a streaming channel that sends data from devices in the account to an endpoint defined in a target resource. body provides the details of the subscription that you want to create.

Parameters:

Returns:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/verizon/controllers/cloud_connector_subscriptions_controller.rb', line 14

def create_subscription(body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/subscriptions',
                                 Server::CLOUD_CONNECTOR)
               .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(Single.new('oAuth2')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:custom_type_deserializer))
               .deserialize_into(Subscription.method(:from_hash))
               .is_api_response(true))
    .execute
end

#delete_subscription(body) ⇒ void

This method returns an undefined value.

Remove a subscription from a ThingSpace account. body identifies the subscription to delete.

Parameters:



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/verizon/controllers/cloud_connector_subscriptions_controller.rb', line 58

def delete_subscription(body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/subscriptions/actions/delete',
                                 Server::CLOUD_CONNECTOR)
               .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(Single.new('oAuth2')))
    .response(new_response_handler
               .is_response_void(true)
               .is_api_response(true))
    .execute
end

#query_subscription(body) ⇒ Array[Subscription]

Search for subscriptions by property values. Returns an array of all matching subscription resources. body specifies fields and values to match.

Parameters:

Returns:



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/verizon/controllers/cloud_connector_subscriptions_controller.rb', line 36

def query_subscription(body)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/subscriptions/actions/query',
                                 Server::CLOUD_CONNECTOR)
               .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(Single.new('oAuth2')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:custom_type_deserializer))
               .deserialize_into(Subscription.method(:from_hash))
               .is_api_response(true)
               .is_response_array(true))
    .execute
end