Class: Sensit::Api::Field

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

Overview

.

topic_id - The key for the parent topic id - Username of the user

Instance Method Summary collapse

Constructor Details

#initialize(topic_id, id, client) ⇒ Field

Returns a new instance of Field.



11
12
13
14
15
# File 'lib/sensit/api/field.rb', line 11

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

Instance Method Details

#create(name, key, options = {}) ⇒ Object

Adds a new field that feed data can be added too. Requires authorization of manage_any_data, or manage_application_data ‘/topics/:topic_id/fields’ POST

name - The descriptive name of the field. key - The name that the is used to identify the field in a feed



44
45
46
47
48
49
50
51
52
# File 'lib/sensit/api/field.rb', line 44

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

  response = @client.post "/topics/#{@topic_id}/fields", body, options

  return response
end

#delete(options = {}) ⇒ Object

Deletes a field and the feed data in that field. Requires authorization of manage_any_data, or manage_application_data ‘/api/topics/:topic_id/fields/:id’ DELETE



70
71
72
73
74
75
76
# File 'lib/sensit/api/field.rb', line 70

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

  response = @client.delete "/api/topics/#{@topic_id}/fields/#{@id}", body, options

  return response
end

#find(options = {}) ⇒ Object

Get a Field of the associated a topic and Id. Requires authorization of read_any_data, or read_application_data ‘/topics/:topic_id/fields/:id’ GET



31
32
33
34
35
36
37
# File 'lib/sensit/api/field.rb', line 31

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

  response = @client.get "/topics/#{@topic_id}/fields/#{@id}", body, options

  return response
end

#list(options = {}) ⇒ Object

Get all the fields associated with a topic. Requires authorization of read_any_data, or read_application_data ‘/topics/:topic_id/fields’ GET



20
21
22
23
24
25
26
# File 'lib/sensit/api/field.rb', line 20

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

  response = @client.get "/topics/#{@topic_id}/fields", body, options

  return response
end

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

Updates the Field data and makes the corresponding changes in the index. Requires authorization of manage_any_data, or manage_application_data ‘/api/topics/:topic_id/fields/:id’ PUT

name - The descriptive name of the field.



58
59
60
61
62
63
64
65
# File 'lib/sensit/api/field.rb', line 58

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

  response = @client.put "/api/topics/#{@topic_id}/fields/#{@id}", body, options

  return response
end