Class: MoxiworksPlatform::Task
- Defined in:
- lib/moxiworks_platform/task.rb
Instance Attribute Summary collapse
-
#completed_at ⇒ Integer|nil
the Unix timestamp representing the Date/Time this task was completed.
-
#created_at ⇒ Object
the Unix timestamp representing the Date/Time this Task was created.
-
#description ⇒ String
a detailed description to be displayed to the agent for this Task.
-
#due_at ⇒ Integer
the Unix timestamp representing the due date of this Task.
-
#duration ⇒ Integer
the length (in minutes) estimated to complete this Task.
-
#moxi_works_agent_id ⇒ String
moxi_works_agent_id is the Moxi Works Platform ID of the agent which a Task is or is to be associated with.
-
#name ⇒ String
the title to be displayed to the agent for this Task.
-
#partner_contact_id ⇒ String
*your system's* unique ID for the Contact.
-
#partner_task_id ⇒ String
Your system's unique identifier for the Task.
-
#status ⇒ String, enumerated
an enumerated string representing the state of this Task.
Attributes inherited from Resource
Class Method Summary collapse
-
.create(opts = {}) ⇒ MoxiworksPlatform::Task
Creates a new Task in Moxi Works Platform.
-
.find(opts = {}) ⇒ MoxiworksPlatform::Task
Find an Task your system has previously created in Moxi Works Platform.
-
.search(opts = {}) ⇒ Hash
Search Agent's Tasks in Moxi Works Platform.
-
.send_request(method, opts = {}, url = nil) ⇒ MoxiworksPlatform::Task
Send our remote request to the Moxi Works Platform.
-
.update(opts = {}) ⇒ MoxiworksPlatform::Task
Updates an existing Task in Moxi Works Platform.
Instance Method Summary collapse
-
#save ⇒ MoxiWorksPlatform:Task
Save an instance of MoxiWorksPlatform::Task to 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, #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
#completed_at ⇒ Integer|nil
the Unix timestamp representing the Date/Time this task was completed.
When the task is not in a 'completed' state, this attribute will be nil.
When updating the completed_at attribute, the status attribute must be set to 'completed'
82 |
# File 'lib/moxiworks_platform/task.rb', line 82 attr_writer :completed_at |
#created_at ⇒ Object
the Unix timestamp representing the Date/Time this Task was created
71 |
# File 'lib/moxiworks_platform/task.rb', line 71 attr_writer :created_at |
#description ⇒ String
a detailed description to be displayed to the agent for this Task
35 36 37 |
# File 'lib/moxiworks_platform/task.rb', line 35 def description @description end |
#due_at ⇒ Integer
the Unix timestamp representing the due date of this Task
41 |
# File 'lib/moxiworks_platform/task.rb', line 41 attr_writer :due_at |
#duration ⇒ Integer
the length (in minutes) estimated to complete this Task
47 |
# File 'lib/moxiworks_platform/task.rb', line 47 attr_writer :duration |
#moxi_works_agent_id ⇒ String
moxi_works_agent_id is the Moxi Works Platform ID of the agent which a Task is or is to be associated with.
this must be set for any Moxi Works Platform transaction
10 11 12 |
# File 'lib/moxiworks_platform/task.rb', line 10 def moxi_works_agent_id @moxi_works_agent_id end |
#name ⇒ String
the title to be displayed to the agent for this Task
29 30 31 |
# File 'lib/moxiworks_platform/task.rb', line 29 def name @name 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/task.rb', line 18 def partner_contact_id @partner_contact_id end |
#partner_task_id ⇒ String
Returns your system's unique identifier for the Task.
23 24 25 |
# File 'lib/moxiworks_platform/task.rb', line 23 def partner_task_id @partner_task_id end |
#status ⇒ String, enumerated
an enumerated string representing the state of this Task
allowed values:
active
completed
[nil]
When creating a new task, the assumed state is 'active;' this attribute does not need to be populated when creating or updating a Task unless the status is 'completed.'
63 64 65 |
# File 'lib/moxiworks_platform/task.rb', line 63 def status @status end |
Class Method Details
.create(opts = {}) ⇒ MoxiworksPlatform::Task
Creates a new Task in Moxi Works Platform
113 114 115 116 117 118 119 120 |
# File 'lib/moxiworks_platform/task.rb', line 113 def self.create(opts={}) required_opts = [:moxi_works_agent_id, :partner_task_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 self.send_request(:post, opts) end |
.find(opts = {}) ⇒ MoxiworksPlatform::Task
Find an Task your system has previously created in Moxi Works Platform
132 133 134 135 136 137 138 139 140 |
# File 'lib/moxiworks_platform/task.rb', line 132 def self.find(opts={}) required_opts = [:moxi_works_agent_id, :partner_task_id] required_opts.each do |opt| raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if opts[opt].nil? or opts[opt].to_s.empty? end url = "#{MoxiworksPlatform::Config.url}/api/tasks/#{opts[:partner_task_id]}" self.send_request(:get, opts, url) end |
.search(opts = {}) ⇒ Hash
Search Agent's Tasks in Moxi Works Platform
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/moxiworks_platform/task.rb', line 174 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/tasks" required_opts = [:moxi_works_agent_id, :due_date_start, :due_date_end] 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() json = { 'page_number': 1, 'total_pages': 0, 'tasks':[]} RestClient::Request.execute(method: :get, url: url, payload: opts, headers: self.headers) do |response| puts response if MoxiworksPlatform::Config.debug self.check_for_error_in_response(response) results.headers = response.headers json = JSON.parse(response) results.page_number = json['page_number'] if(json.is_a?(Hash) && json['page_number']) results.total_pages = json['total_pages'] if(json.is_a?(Hash) && json['total_pages']) json['tasks'].each do |r| results << MoxiworksPlatform::Task.new(r) unless r.nil? or r.empty? end json['tasks'] = results end json end |
.send_request(method, opts = {}, url = nil) ⇒ MoxiworksPlatform::Task
Send our remote request to the Moxi Works Platform
269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/moxiworks_platform/task.rb', line 269 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/tasks" required_opts = [:moxi_works_agent_id, :partner_task_id] 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 |
.update(opts = {}) ⇒ MoxiworksPlatform::Task
Updates an existing Task in Moxi Works Platform
237 238 239 240 241 242 243 244 245 |
# File 'lib/moxiworks_platform/task.rb', line 237 def self.update(opts={}) required_opts = [:moxi_works_agent_id, :partner_task_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 url = "#{MoxiworksPlatform::Config.url}/api/tasks/#{opts[:partner_task_id]}" self.send_request(:put, opts, url) end |
Instance Method Details
#save ⇒ MoxiWorksPlatform:Task
Save an instance of MoxiWorksPlatform::Task to Moxi Works Platform
292 293 294 |
# File 'lib/moxiworks_platform/task.rb', line 292 def save MoxiworksPlatform::Task.update(self.to_hash) end |