class ThisData::Rule
Public Class Methods
all(options={})
click to toggle source
Fetch an array of Rules from the ThisData
API Available options can be found at
http://help.thisdata.com/docs/v1rules
Returns: Array of OpenStruct Rule
objects
# File lib/this_data/rule.rb, line 23 def self.all(options={}) response = ThisData::Client.new.get(ThisData::RULES_ENDPOINT, query: options) response.parsed_response.collect do |rule_hash| OpenStruct.new(rule_hash) end end
create(rule, options={})
click to toggle source
Create a new rule on the ThisData
API Available options can be found at
http://help.thisdata.com/docs/v1rules-1
Returns: OpenStruct Rule
object
# File lib/this_data/rule.rb, line 35 def self.create(rule, options={}) response = ThisData::Client.new.post(ThisData::RULES_ENDPOINT, body: JSON.generate(rule), query: options) OpenStruct.new(response.parsed_response) end
destroy(id, options={})
click to toggle source
Delete a rule on the ThisData
API Available options can be found at
http://help.thisdata.com/docs/v1rulesid-2
Returns: OpenStruct Rule
object
# File lib/this_data/rule.rb, line 56 def self.destroy(id, options={}) response = ThisData::Client.new.delete("#{ThisData::RULES_ENDPOINT}/#{id}", query: options) response.code.eql?(204) end
find(id, options={})
click to toggle source
Fetch an array of Rules from the ThisData
API Available options can be found at
http://help.thisdata.com/docs/v1rules
Returns: Array of OpenStruct Rule
objects
# File lib/this_data/rule.rb, line 13 def self.find(id, options={}) response = ThisData::Client.new.get("#{ThisData::RULES_ENDPOINT}/#{id}", query: options) OpenStruct.new( response.parsed_response) end
update(rule, options={})
click to toggle source
Update a rule on the ThisData
API Available options can be found at
http://help.thisdata.com/docs/v1rulesid-1
Returns: OpenStruct Rule
object
# File lib/this_data/rule.rb, line 45 def self.update(rule, options={}) rule_id = OpenStruct.new(rule).id response = ThisData::Client.new.post("#{ThisData::RULES_ENDPOINT}/#{rule_id}", body: JSON.generate(rule), query: options) OpenStruct.new(response.parsed_response) end