Class: Sensit::Api::Subscription

Inherits:
Object
  • Object
show all
Defined in:
lib/sensit/api/subscription.rb

Overview

Subscriptions allows feed data to imported using a socket rather than just using the Feed REST API. By creating a subscription sensit will start to listen for feed data being imported using the specified ‘host` and while using the topic name as the `channel` name.

id - The identifier for the subscription

Instance Method Summary collapse

Constructor Details

#initialize(id, client) ⇒ Subscription

Returns a new instance of Subscription.



10
11
12
13
# File 'lib/sensit/api/subscription.rb', line 10

def initialize(id, client)
  @id = id
  @client = client
end

Instance Method Details

#create(subscription, options = {}) ⇒ Object

Create a subscription which will connect to the server and listen for feed data for any of the associated topics. Requires authorization of manage_any_subscriptions, or manage_application_subscriptions. ‘/subscriptions’ POST

subscription - A Hash containing`name`:The channel or name to identify the subscription(required).‘host`:The ip address or host of the connection(required).`protocol`:the protocol to communicate over (http, tcp, udp, mqtt) (required)`port`:The port of the connection.



41
42
43
44
45
46
47
48
# File 'lib/sensit/api/subscription.rb', line 41

def create(subscription, options = {})
  body = options.has_key?(:body) ? options[:body] : {}
  body[:subscription] = subscription

  response = @client.post "/subscriptions", body, options

  return response
end

#delete(options = {}) ⇒ Object

Delete the subscription and stop listening for feed data for the associated topics. Requires authorization of manage_any_subscriptions, or manage_application_subscriptions. ‘/subscriptions/:id’ DELETE



66
67
68
69
70
71
72
# File 'lib/sensit/api/subscription.rb', line 66

def delete(options = {})
  body = options.has_key?(:body) ? options[:body] : {}

  response = @client.delete "/subscriptions/#{@id}", body, options

  return response
end

#find(options = {}) ⇒ Object

Get the information of a specific subscription. Requires authorization of read_any_subscriptions, or read_application_subscriptions. ‘/subscriptions/:id’ GET



29
30
31
32
33
34
35
# File 'lib/sensit/api/subscription.rb', line 29

def find(options = {})
  body = options.has_key?(:query) ? options[:query] : {}

  response = @client.get "/subscriptions/#{@id}", body, options

  return response
end

#list(options = {}) ⇒ Object

Get the list of all subscriptions for importing feed data to the associated topics. Requires authorization of read_any_subscriptions, or read_application_subscriptions. ‘/subscriptions’ GET



18
19
20
21
22
23
24
# File 'lib/sensit/api/subscription.rb', line 18

def list(options = {})
  body = options.has_key?(:query) ? options[:query] : {}

  response = @client.get "/subscriptions", body, options

  return response
end

#update(subscription, options = {}) ⇒ Object

Returns an object with the current configuration that Buffer is using, including supported services, their icons and the varying limits of character and schedules. Requires authorization of manage_any_subscriptions, or manage_application_subscriptions. ‘/subscriptions/:id’ PUT

subscription - A Hash containing`name`:The channel or name to identify the subscription(required).‘host`:The ip address or host of the connection(required).`protocol`:the protocol to communicate over (http, tcp, udp, mqtt) (required)`port`:The port of the connection.



54
55
56
57
58
59
60
61
# File 'lib/sensit/api/subscription.rb', line 54

def update(subscription, options = {})
  body = options.has_key?(:body) ? options[:body] : {}
  body[:subscription] = subscription

  response = @client.put "/subscriptions/#{@id}", body, options

  return response
end