Class: Viewpoint::EWS::Types::OutOfOffice

Inherits:
Object
  • Object
show all
Includes:
Viewpoint::EWS, Viewpoint::EWS::Types
Defined in:
lib/ews/types/out_of_office.rb

Overview

This represents OutOfOffice settings

Constant Summary

Constants included from Viewpoint::EWS::Types

KEY_ALIAS, KEY_PATHS, KEY_TYPES, OOF_KEY_ALIAS, OOF_KEY_PATHS, OOF_KEY_TYPES

Constants included from StringUtils

StringUtils::DURATION_RE

Constants included from Viewpoint::EWS

ConnectingSID

Instance Attribute Summary collapse

Attributes included from Viewpoint::EWS::Types

#ews_item

Attributes included from Viewpoint::EWS

#logger

Instance Method Summary collapse

Methods included from Viewpoint::EWS::Types

#auto_deepen?, #deepen!, #ews_methods, #freeze!, #frozen?, #mark_deep!, #method_missing, #methods, #respond_to?, #shallow?, #to_s, #unfreeze!

Methods included from StringUtils

included

Methods included from Viewpoint::EWS

#remove_impersonation, root_logger, #set_impersonation

Constructor Details

#initialize(user, ews_item) ⇒ OutOfOffice

Returns a new instance of OutOfOffice.

Parameters:



45
46
47
48
49
50
51
# File 'lib/ews/types/out_of_office.rb', line 45

def initialize(user, ews_item)
  @ews =  user.ews
  @user = user
  @ews_item = ews_item
  @changed = false
  simplify!
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Viewpoint::EWS::Types

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



41
42
43
# File 'lib/ews/types/out_of_office.rb', line 41

def user
  @user
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/ews/types/out_of_office.rb', line 53

def changed?
  @changed
end

#disableObject



75
76
77
78
79
# File 'lib/ews/types/out_of_office.rb', line 75

def disable
  return true unless enabled? || scheduled?
  @changed = true
  @ews_item[:oof_settings][:oof_state] = :disabled
end

#enableObject



69
70
71
72
73
# File 'lib/ews/types/out_of_office.rb', line 69

def enable
  return true if enabled?
  @changed = true
  @ews_item[:oof_settings][:oof_state] = :enabled
end

#external_reply=(message) ⇒ Object

A message to send to external users

Parameters:

  • message (String)


108
109
110
111
# File 'lib/ews/types/out_of_office.rb', line 108

def external_reply=(message)
  @changed = true
  @ews_item[:oof_settings][:external_reply] = message
end

#internal_reply=(message) ⇒ Object

A message to send to internal users

Parameters:

  • message (String)


101
102
103
104
# File 'lib/ews/types/out_of_office.rb', line 101

def internal_reply=(message)
  @changed = true
  @ews_item[:oof_settings][:internal_reply] = message
end

#save!Object



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/ews/types/out_of_office.rb', line 57

def save!
  return true unless changed?
  opts = { mailbox: {address: user.email_address} }.merge(@ews_item[:oof_settings])
  resp = @ews.set_user_oof_settings(opts)
  if resp.success?
    @changed = false
    true
  else
    raise SaveFailed, "Could not save #{self.class}. #{resp.code}: #{resp.message}"
  end
end

#schedule(start_time, end_time) ⇒ Object

Schedule an out of office.

Parameters:

  • start_time (DateTime)
  • end_time (DateTime)


84
85
86
87
88
# File 'lib/ews/types/out_of_office.rb', line 84

def schedule(start_time, end_time)
  @changed = true
  @ews_item[:oof_settings][:oof_state] = :scheduled
  set_duration start_time, end_time
end

#set_duration(start_time, end_time) ⇒ Object

Specify a duration for this Out Of Office setting

Parameters:

  • start_time (DateTime)
  • end_time (DateTime)


93
94
95
96
97
# File 'lib/ews/types/out_of_office.rb', line 93

def set_duration(start_time, end_time)
  @changed = true
  @ews_item[:oof_settings][:duration][:start_time] = start_time
  @ews_item[:oof_settings][:duration][:end_time] = end_time
end