Class: MoxiworksPlatform::ActionLog
- Defined in:
- lib/moxiworks_platform/action_log.rb
Instance Attribute Summary collapse
-
#body ⇒ String
the body of the log entry to be displayed for this ActionLog Entry.
-
#moxi_works_agent_id ⇒ String
moxi_works_agent_id is the Moxi Works Platform ID of the agent which an ActionLog entry is or is to be associated with.
-
#partner_contact_id ⇒ String
*your system’s* unique ID for the Contact.
-
#title ⇒ String
the title to be displayed for this ActionLog Entry.
Attributes inherited from Resource
Class Method Summary collapse
-
.create(opts = {}) ⇒ MoxiworksPlatform::ActionLog
Creates a new ActionLog entry in Moxi Works Platform.
-
.search(opts = {}) ⇒ Array
Search an Agent’s ActionLog entries in Moxi Works Platform.
-
.send_request(method, opts = {}, url = nil) ⇒ MoxiworksPlatform::ActionLog
Send our remote request to the Moxi Works Platform.
Methods inherited from Resource
accept_header, attr_accessor, attributes, #attributes, auth_header, check_for_error_in_response, content_type_header, #float_attrs, headers, #init_attrs_from_hash, #initialize, #int_attrs, #method_missing, #numeric_attrs, #numeric_value_for, #to_hash, underscore, underscore_array, underscore_attribute_names, underscore_hash, user_agent_header
Constructor Details
This class inherits a constructor from MoxiworksPlatform::Resource
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class MoxiworksPlatform::Resource
Instance Attribute Details
#body ⇒ String
the body of the log entry to be displayed for this ActionLog Entry
30 31 32 |
# File 'lib/moxiworks_platform/action_log.rb', line 30 def body @body end |
#moxi_works_agent_id ⇒ String
moxi_works_agent_id is the Moxi Works Platform ID of the agent which an ActionLog entry is or is to be associated with.
this must be set for any Moxi Works Platform transaction
10 11 12 |
# File 'lib/moxiworks_platform/action_log.rb', line 10 def moxi_works_agent_id @moxi_works_agent_id end |
#partner_contact_id ⇒ String
*your system’s* unique ID for the Contact
this must be set for any Moxi Works Platform transaction
18 19 20 |
# File 'lib/moxiworks_platform/action_log.rb', line 18 def partner_contact_id @partner_contact_id end |
#title ⇒ String
the title to be displayed for this ActionLog Entry
24 25 26 |
# File 'lib/moxiworks_platform/action_log.rb', line 24 def title @title end |
Class Method Details
.create(opts = {}) ⇒ MoxiworksPlatform::ActionLog
Creates a new ActionLog entry in Moxi Works Platform
52 53 54 |
# File 'lib/moxiworks_platform/action_log.rb', line 52 def self.create(opts={}) self.send_request(:post, opts) end |
.search(opts = {}) ⇒ Array
Search an Agent’s ActionLog entries in Moxi Works Platform
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/moxiworks_platform/action_log.rb', line 71 def self.search(opts={}) raise ::MoxiworksPlatform::Exception::ArgumentError, 'arguments must be passed as named parameters' unless opts.is_a? Hash url ||= "#{MoxiworksPlatform::Config.url}/api/action_logs" required_opts = [:moxi_works_agent_id, :partner_contact_id] required_opts.each do |opt| raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if opts[opt].nil? or opts[opt].to_s.empty? end results = MoxiResponseArray.new() RestClient::Request.execute(method: :get, url: url, payload: opts, headers: self.headers) do |response| puts response if MoxiworksPlatform::Config.debug results.headers = response.headers self.check_for_error_in_response(response) json = JSON.parse(response) json['actions'].each do |r| results << MoxiworksPlatform::ActionLog.new(r) unless r.nil? or r.empty? end end results end |
.send_request(method, opts = {}, url = nil) ⇒ MoxiworksPlatform::ActionLog
Send our remote request to the Moxi Works Platform
110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/moxiworks_platform/action_log.rb', line 110 def self.send_request(method, opts={}, url=nil) raise ::MoxiworksPlatform::Exception::ArgumentError, 'arguments must be passed as named parameters' unless opts.is_a? Hash url ||= "#{MoxiworksPlatform::Config.url}/api/action_logs" required_opts = [:moxi_works_agent_id, :partner_contact_id, :title, :body] required_opts.each do |opt| raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if opts[opt].nil? or opts[opt].to_s.empty? end super(method, opts, url) end |