Class: Sensit::Api::Field
- Inherits:
-
Object
- Object
- Sensit::Api::Field
- 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
-
#create(field, options = {}) ⇒ Object
Adds a new field that feed data can be added too.
-
#delete(options = {}) ⇒ Object
Deletes a field and the feed data in that field.
-
#find(options = {}) ⇒ Object
Get a Field of the associated a topic and Id.
-
#initialize(topic_id, id, client) ⇒ Field
constructor
A new instance of Field.
-
#list(options = {}) ⇒ Object
Get all the fields associated with a topic.
-
#update(field, options = {}) ⇒ Object
Updates the Field data and makes the corresponding changes in the index.
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(field, 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
field - A Hash containing`name`: A descriptive name of the field.‘key`:The name that is used to identify the field in a feed (required).`datatype`:The type of data that is stored in the field. ie. integer, float, string, bool, datetime
43 44 45 46 47 48 49 50 |
# File 'lib/sensit/api/field.rb', line 43 def create(field, = {}) body = .has_key?(:body) ? [:body] : {} body[:field] = field response = @client.post "/topics/#{@topic_id}/fields", body, 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
68 69 70 71 72 73 74 |
# File 'lib/sensit/api/field.rb', line 68 def delete( = {}) body = .has_key?(:body) ? [:body] : {} response = @client.delete "/api/topics/#{@topic_id}/fields/#{@id}", body, 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( = {}) body = .has_key?(:query) ? [:query] : {} response = @client.get "/topics/#{@topic_id}/fields/#{@id}", body, 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( = {}) body = .has_key?(:query) ? [:query] : {} response = @client.get "/topics/#{@topic_id}/fields", body, return response end |
#update(field, 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
field - A Hash containing`name`: A descriptive name of the field.‘key`:The name that is used to identify the field in a feed (required).`datatype`:The type of data that is stored in the field. ie. integer, float, string, bool, datetime
56 57 58 59 60 61 62 63 |
# File 'lib/sensit/api/field.rb', line 56 def update(field, = {}) body = .has_key?(:body) ? [:body] : {} body[:field] = field response = @client.put "/api/topics/#{@topic_id}/fields/#{@id}", body, return response end |