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.
-
#attendees ⇒ String
a comma separated list of attendee IDs.
-
#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.
-
#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.
-
#send_reminder ⇒ Boolean
whether to send a reminder to attendees.
Attributes inherited from Resource
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, #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
#all_day ⇒ Boolean
whether the event is an all day event
9 10 11 |
# File 'lib/moxiworks_platform/event.rb', line 9 def all_day @all_day end |
#attendees ⇒ String
a comma separated list of attendee IDs
15 16 17 |
# File 'lib/moxiworks_platform/event.rb', line 15 def attendees @attendees end |
#event_end ⇒ Integer
a unix timestamp representing the end time of the event
21 |
# File 'lib/moxiworks_platform/event.rb', line 21 attr_writer :event_end |
#event_location ⇒ String
a short description of the location of the event
27 28 29 |
# File 'lib/moxiworks_platform/event.rb', line 27 def event_location @event_location end |
#event_start ⇒ Integer
a unix timestamp representing the start time of the event
33 |
# File 'lib/moxiworks_platform/event.rb', line 33 attr_writer :event_start |
#event_subject ⇒ String
a short description of the event
39 40 41 |
# File 'lib/moxiworks_platform/event.rb', line 39 def event_subject @event_subject end |
#is_meeting ⇒ Boolean
whether this event is a meeting
45 46 47 |
# File 'lib/moxiworks_platform/event.rb', line 45 def is_meeting @is_meeting end |
#location ⇒ String
a short description of the location of the event
27 |
# File 'lib/moxiworks_platform/event.rb', line 27 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
54 55 56 |
# File 'lib/moxiworks_platform/event.rb', line 54 def moxi_works_agent_id @moxi_works_agent_id end |
#note ⇒ String
a more detailed description of the event
60 61 62 |
# File 'lib/moxiworks_platform/event.rb', line 60 def note @note end |
#partner_event_id ⇒ String
your system's event ID for the event
66 67 68 |
# File 'lib/moxiworks_platform/event.rb', line 66 def partner_event_id @partner_event_id end |
#remind_minutes_before ⇒ Integer
how many minutes before the event a reminder should be sent
72 |
# File 'lib/moxiworks_platform/event.rb', line 72 attr_writer :remind_minutes_before |
#send_reminder ⇒ Boolean
whether to send a reminder to attendees
78 79 80 |
# File 'lib/moxiworks_platform/event.rb', line 78 def send_reminder @send_reminder 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
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/moxiworks_platform/event.rb', line 247 def self.delete(opts={}) raise ::MoxiworksPlatform::Exception::ArgumentError, 'arguments must be passed as named parameters' unless opts.is_a? Hash 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 182 183 184 185 186 187 188 |
# File 'lib/moxiworks_platform/event.rb', line 156 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/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 = 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) results.page_number = 1 results.total_pages = 1 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
292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/moxiworks_platform/event.rb', line 292 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/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
225 226 227 228 229 |
# File 'lib/moxiworks_platform/event.rb', line 225 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
327 328 329 |
# File 'lib/moxiworks_platform/event.rb', line 327 def delete MoxiworksPlatform::Event.delete(self.to_hash) end |
#save ⇒ MoxiWorksPlatform:Event
Save an instance of MoxiWorksPlatform::Event to Moxi Works Platform
315 316 317 |
# File 'lib/moxiworks_platform/event.rb', line 315 def save MoxiworksPlatform::Event.update(self.to_hash) end |