Class: MoxiworksPlatform::Event
- Defined in:
- lib/moxiworks_platform/event.rb
Overview
Moxi Works Platform Event
Instance Attribute Summary collapse
-
#all_day ⇒ Boolean
whether the event is an all day event.
-
#event_end ⇒ Integer
a unix timestamp representing the end time of the event.
-
#event_location ⇒ String
a short description of the location of the event.
-
#event_start ⇒ Integer
a unix timestamp representing the start time of the event.
-
#event_subject ⇒ String
a short description of the event.
-
#is_meeting ⇒ Boolean
whether this event is a meeting.
-
#location ⇒ String
a short description of the location of the event.
-
#moxi_works_agent_id ⇒ String
moxi_works_agent_id is the Moxi Works Platform ID of the agent which a event is or is to be associated with.
-
#note ⇒ String
a more detailed description of the event.
-
#optional_attendees ⇒ String
a comma separated list of attendee IDs.
-
#partner_event_id ⇒ String
your system’s event ID for the event.
-
#remind_minutes_before ⇒ Integer
how many minutes before the event a reminder should be sent.
-
#required_attendees ⇒ String
a comma separated list of attendee IDs.
Class Method Summary collapse
-
.create(opts = {}) ⇒ MoxiworksPlatform::Event
Creates a new Event in Moxi Works Platform.
-
.delete(opts = {}) ⇒ Boolean
Delete an Event your system has previously created in Moxi Works Platform.
-
.find(opts = {}) ⇒ MoxiworksPlatform::Event
Find an Event your system has previously created in Moxi Works Platform.
-
.search(opts = {}) ⇒ Array
Search an Agent’s Events in Moxi Works Platform.
-
.send_request(method, opts = {}, url = nil) ⇒ MoxiworksPlatform::Event
Send our remote request to the Moxi Works Platform.
-
.update(opts = {}) ⇒ MoxiworksPlatform::Event
Updates a new Event in Moxi Works Platform.
Instance Method Summary collapse
-
#delete ⇒ Boolean
Delete an instance of MoxiWorksPlatform::Event from Moxi Works Platform that your system has previously created.
-
#save ⇒ MoxiWorksPlatform:Event
Save an instance of MoxiWorksPlatform::Event 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, #initialize, #method_missing, #numeric_attrs, #numeric_value_for, #to_hash
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
#all_day ⇒ Boolean
whether the event is an all day event
65 66 67 |
# File 'lib/moxiworks_platform/event.rb', line 65 def all_day @all_day end |
#event_end ⇒ Integer
a unix timestamp representing the end time of the event
59 |
# File 'lib/moxiworks_platform/event.rb', line 59 attr_writer :event_end |
#event_location ⇒ String
a short description of the location of the event
29 30 31 |
# File 'lib/moxiworks_platform/event.rb', line 29 def event_location @event_location end |
#event_start ⇒ Integer
a unix timestamp representing the start time of the event
53 |
# File 'lib/moxiworks_platform/event.rb', line 53 attr_writer :event_start |
#event_subject ⇒ String
a short description of the event
23 24 25 |
# File 'lib/moxiworks_platform/event.rb', line 23 def event_subject @event_subject end |
#is_meeting ⇒ Boolean
whether this event is a meeting
47 48 49 |
# File 'lib/moxiworks_platform/event.rb', line 47 def is_meeting @is_meeting end |
#location ⇒ String
a short description of the location of the event
29 |
# File 'lib/moxiworks_platform/event.rb', line 29 attr_accessor :event_location |
#moxi_works_agent_id ⇒ String
moxi_works_agent_id is the Moxi Works Platform ID of the agent which a event is or is to be associated with.
this must be set for any Moxi Works Platform transaction
11 12 13 |
# File 'lib/moxiworks_platform/event.rb', line 11 def moxi_works_agent_id @moxi_works_agent_id end |
#note ⇒ String
a more detailed description of the event
35 36 37 |
# File 'lib/moxiworks_platform/event.rb', line 35 def note @note end |
#optional_attendees ⇒ String
a comma separated list of attendee IDs
77 78 79 |
# File 'lib/moxiworks_platform/event.rb', line 77 def optional_attendees @optional_attendees end |
#partner_event_id ⇒ String
your system’s event ID for the event
17 18 19 |
# File 'lib/moxiworks_platform/event.rb', line 17 def partner_event_id @partner_event_id end |
#remind_minutes_before ⇒ Integer
how many minutes before the event a reminder should be sent
41 |
# File 'lib/moxiworks_platform/event.rb', line 41 attr_writer :remind_minutes_before |
#required_attendees ⇒ String
a comma separated list of attendee IDs
71 72 73 |
# File 'lib/moxiworks_platform/event.rb', line 71 def required_attendees @required_attendees end |
Class Method Details
.create(opts = {}) ⇒ MoxiworksPlatform::Event
Creates a new Event in Moxi Works Platform
115 116 117 |
# File 'lib/moxiworks_platform/event.rb', line 115 def self.create(opts={}) self.send_request(:post, opts) end |
.delete(opts = {}) ⇒ Boolean
Delete an Event your system has previously created in Moxi Works Platform
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/moxiworks_platform/event.rb', line 241 def self.delete(opts={}) url = "#{MoxiworksPlatform::Config.url}/api/events/#{opts[:partner_event_id]}" required_opts = [:moxi_works_agent_id, :partner_event_id] required_opts.each do |opt| raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if opts[opt].nil? or opts[opt].to_s.empty? end RestClient::Request.execute(method: :delete, url: url, payload: opts, headers: self.headers) do |response| puts response if MoxiworksPlatform::Config.debug json = JSON.parse(response) raise ::MoxiworksPlatform::Exception::RemoteRequestFailure, 'unable to delete' if json['status'] == 'error' json['status'] == 'success' end end |
.find(opts = {}) ⇒ MoxiworksPlatform::Event
Find an Event your system has previously created in Moxi Works Platform
129 130 131 132 |
# File 'lib/moxiworks_platform/event.rb', line 129 def self.find(opts={}) url = "#{MoxiworksPlatform::Config.url}/api/events/#{opts[:partner_event_id]}" self.send_request(:get, opts, url) end |
.search(opts = {}) ⇒ Array
Search an Agent’s Events in Moxi Works Platform
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/moxiworks_platform/event.rb', line 156 def self.search(opts={}) url ||= "#{MoxiworksPlatform::Config.url}/api/events" required_opts = [:moxi_works_agent_id, :date_start, :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 = [] 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) json = JSON.parse(response) json.each do |events_for_date| events = [] events_for_date.each do |date, event_array| event_array.each do |r| events << MoxiworksPlatform::Event.new(r) unless r.nil? or r.empty? end results << {date: date, events: events} end end end results end |
.send_request(method, opts = {}, url = nil) ⇒ MoxiworksPlatform::Event
Send our remote request to the Moxi Works Platform
285 286 287 288 289 290 291 292 293 294 |
# File 'lib/moxiworks_platform/event.rb', line 285 def self.send_request(method, opts={}, url=nil) url ||= "#{MoxiworksPlatform::Config.url}/api/events" required_opts = [:moxi_works_agent_id, :partner_event_id] required_opts.each do |opt| raise ::MoxiworksPlatform::Exception::ArgumentError, "#{opt} required" if opts[opt].nil? or opts[opt].to_s.empty? end opts[:event_id] = opts[:partner_event_id] super(method, opts, url) end |
.update(opts = {}) ⇒ MoxiworksPlatform::Event
Updates a new Event in Moxi Works Platform
219 220 221 222 223 |
# File 'lib/moxiworks_platform/event.rb', line 219 def self.update(opts={}) opts[:event_id] = opts[:partner_event_id] url = "#{MoxiworksPlatform::Config.url}/api/events/#{opts[:partner_event_id]}" self.send_request(:put, opts, url) end |
Instance Method Details
#delete ⇒ Boolean
Delete an instance of MoxiWorksPlatform::Event from Moxi Works Platform that your system has previously created
318 319 320 |
# File 'lib/moxiworks_platform/event.rb', line 318 def delete MoxiworksPlatform::Event.delete(self.to_hash) end |
#save ⇒ MoxiWorksPlatform:Event
Save an instance of MoxiWorksPlatform::Event to Moxi Works Platform
306 307 308 |
# File 'lib/moxiworks_platform/event.rb', line 306 def save MoxiworksPlatform::Event.update(self.to_hash) end |