Class: Comet::Office365Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/comet/models/office_365connection.rb

Overview

Office365Connection is a typed class wrapper around the underlying Comet Server API data structure.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOffice365Connection

Returns a new instance of Office365Connection.



36
37
38
# File 'lib/comet/models/office_365connection.rb', line 36

def initialize
  clear
end

Instance Attribute Details

#credentialObject

Returns the value of attribute credential.



19
20
21
# File 'lib/comet/models/office_365connection.rb', line 19

def credential
  @credential
end

#custom_settingObject

Returns the value of attribute custom_setting.



22
23
24
# File 'lib/comet/models/office_365connection.rb', line 22

def custom_setting
  @custom_setting
end

#custom_setting_v2Object

Returns the value of attribute custom_setting_v2.



31
32
33
# File 'lib/comet/models/office_365connection.rb', line 31

def custom_setting_v2
  @custom_setting_v2
end

#feature_flagObject

Returns the value of attribute feature_flag.



16
17
18
# File 'lib/comet/models/office_365connection.rb', line 16

def feature_flag
  @feature_flag
end

#mailbox_unique_membersObject

Returns the value of attribute mailbox_unique_members.



25
26
27
# File 'lib/comet/models/office_365connection.rb', line 25

def mailbox_unique_members
  @mailbox_unique_members
end

#site_unique_membersObject

Returns the value of attribute site_unique_members.



28
29
30
# File 'lib/comet/models/office_365connection.rb', line 28

def site_unique_members
  @site_unique_members
end

#unknown_json_fieldsObject

Returns the value of attribute unknown_json_fields.



34
35
36
# File 'lib/comet/models/office_365connection.rb', line 34

def unknown_json_fields
  @unknown_json_fields
end

Instance Method Details

#clearObject



40
41
42
43
44
45
46
47
48
# File 'lib/comet/models/office_365connection.rb', line 40

def clear
  @feature_flag = ''
  @credential = Comet::Office365Credential.new
  @custom_setting = Comet::Office365CustomSetting.new
  @mailbox_unique_members = []
  @site_unique_members = []
  @custom_setting_v2 = Comet::Office365CustomSettingV2.new
  @unknown_json_fields = {}
end

#from_hash(obj) ⇒ Object

Parameters:

  • obj (Hash)

    The complete object as a Ruby hash

Raises:

  • (TypeError)


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/comet/models/office_365connection.rb', line 58

def from_hash(obj)
  raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash

  obj.each do |k, v|
    case k
    when 'FeatureFlag'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String

      @feature_flag = v
    when 'Credential'
      @credential = Comet::Office365Credential.new
      @credential.from_hash(v)
    when 'CustomSetting'
      @custom_setting = Comet::Office365CustomSetting.new
      @custom_setting.from_hash(v)
    when 'MailboxUniqueMembers'
      if v.nil?
        @mailbox_unique_members = []
      else
        @mailbox_unique_members = Array.new(v.length)
        v.each_with_index do |v1, i1|
          raise TypeError, "'v1' expected String, got #{v1.class}" unless v1.is_a? String

          @mailbox_unique_members[i1] = v1
        end
      end
    when 'SiteUniqueMembers'
      if v.nil?
        @site_unique_members = []
      else
        @site_unique_members = Array.new(v.length)
        v.each_with_index do |v1, i1|
          raise TypeError, "'v1' expected String, got #{v1.class}" unless v1.is_a? String

          @site_unique_members[i1] = v1
        end
      end
    when 'CustomSettingV2'
      @custom_setting_v2 = Comet::Office365CustomSettingV2.new
      @custom_setting_v2.from_hash(v)
    else
      @unknown_json_fields[k] = v
    end
  end
end

#from_json(json_string) ⇒ Object

Parameters:

  • json_string (String)

    The complete object in JSON format

Raises:

  • (TypeError)


51
52
53
54
55
# File 'lib/comet/models/office_365connection.rb', line 51

def from_json(json_string)
  raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String

  from_hash(JSON.parse(json_string))
end

#to_hHash

Returns The complete object as a Ruby hash.

Returns:

  • (Hash)

    The complete object as a Ruby hash



120
121
122
# File 'lib/comet/models/office_365connection.rb', line 120

def to_h
  to_hash
end

#to_hashHash

Returns The complete object as a Ruby hash.

Returns:

  • (Hash)

    The complete object as a Ruby hash



105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/comet/models/office_365connection.rb', line 105

def to_hash
  ret = {}
  ret['FeatureFlag'] = @feature_flag
  ret['Credential'] = @credential
  ret['CustomSetting'] = @custom_setting
  ret['MailboxUniqueMembers'] = @mailbox_unique_members
  ret['SiteUniqueMembers'] = @site_unique_members
  ret['CustomSettingV2'] = @custom_setting_v2
  @unknown_json_fields.each do |k, v|
    ret[k] = v
  end
  ret
end

#to_json(options = {}) ⇒ String

Returns The complete object as a JSON string.

Returns:

  • (String)

    The complete object as a JSON string



125
126
127
# File 'lib/comet/models/office_365connection.rb', line 125

def to_json(options = {})
  to_hash.to_json(options)
end