viewpoint 0.1.20 → 0.1.21
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/model/contact.rb +47 -0
- data/lib/model/item_field_uri_map.rb +1 -1
- data/lib/model/mailbox_user.rb +8 -4
- data/lib/viewpoint.rb +1 -1
- metadata +2 -2
data/lib/model/contact.rb
CHANGED
@@ -95,6 +95,53 @@ module Viewpoint
|
|
95
95
|
@updates.merge!({:preformatted => changes}) {|k,v1,v2| v1 + v2}
|
96
96
|
end
|
97
97
|
|
98
|
+
# Set the phone number. You must give a type based on the available Exchange phone number types
|
99
|
+
# @param [Symbol] type the type of number to set. It must be one of these:
|
100
|
+
# :assistant_phone, :business_fax, :business_phone, :business_phone2, :callback, :car_phone, :company_main_phone,
|
101
|
+
# :home_fax, :home_phone, :home_phone2, :isdn, :mobile_phone, :other_fax, :other_telephone, :pager, :primary_phone,
|
102
|
+
# :radio_phone, :telex, :tty_tdd_phone
|
103
|
+
# @param [String] phone_number The phone number
|
104
|
+
# @TODO: Check to make sure the passed type is valid
|
105
|
+
def set_phone_number(phone_type, phone_number)
|
106
|
+
valid_types = [:assistant_phone, :business_fax, :business_phone, :business_phone2, :callback, :car_phone, :company_main_phone,
|
107
|
+
:home_fax, :home_phone, :home_phone2, :isdn, :mobile_phone, :other_fax, :other_telephone, :pager, :primary_phone,
|
108
|
+
:radio_phone, :telex, :tty_tdd_phone]
|
109
|
+
raise EwsError, "Invalid phone type (#{phone_type}) passed to Contact#set_phone_number." unless valid_types.index phone_type
|
110
|
+
type = self.class.name.split(/::/).last.ruby_case.to_sym
|
111
|
+
|
112
|
+
changes = []
|
113
|
+
k = :phone_numbers
|
114
|
+
v = phone_type.to_s.camel_case
|
115
|
+
changes << {:set_item_field =>
|
116
|
+
[{:indexed_field_uRI => {:field_uRI => FIELD_URIS[k][:text], :field_index => v}}, {type=>{k => {:entry => {:key => v, :text => phone_number}}}}]}
|
117
|
+
@updates.merge!({:preformatted => changes}) {|k,v1,v2| v1 + v2}
|
118
|
+
end
|
119
|
+
|
120
|
+
# Set an address for this contact
|
121
|
+
# @param [Symbol] address_type the type of Exchange address to set. It must be one of the following:
|
122
|
+
# :business, :home, :other
|
123
|
+
# @param [Hash] address the address elements to set. It may include the following keys
|
124
|
+
# :street, :city, :state, :country_or_region, :postal_code
|
125
|
+
def set_address(address_type, address)
|
126
|
+
valid_types = [:business, :home, :other]
|
127
|
+
raise EwsError, "Invalid address type (#{address_type}) passed to Contact#set_address." unless valid_types.index address_type
|
128
|
+
valid_field_types = [:street, :city, :state, :country_or_region, :postal_code]
|
129
|
+
type = self.class.name.split(/::/).last.ruby_case.to_sym
|
130
|
+
v = address_type.to_s.camel_case
|
131
|
+
|
132
|
+
changes = []
|
133
|
+
field = 'PhysicalAddresses'
|
134
|
+
address.keys.each do |addr_item|
|
135
|
+
raise EwsError, "Invalid address element (#{addr_item}) passed to Contact#set_address." unless valid_field_types.index addr_item
|
136
|
+
index_field = "contacts:PhysicalAddress:#{addr_item.to_s.camel_case}"
|
137
|
+
changes << {:set_item_field =>
|
138
|
+
[{:indexed_field_uRI => {
|
139
|
+
:field_uRI => index_field, :field_index => v}}, {type => {field => {:entry => {:key => v, addr_item =>{ :text => address[addr_item]}}}}}
|
140
|
+
]}
|
141
|
+
end
|
142
|
+
@updates.merge!({:preformatted => changes}) {|k,v1,v2| v1 + v2}
|
143
|
+
end
|
144
|
+
|
98
145
|
|
99
146
|
private
|
100
147
|
|
@@ -162,7 +162,7 @@ module Viewpoint
|
|
162
162
|
:mileage => {:text => 'contacts:Mileage', :writable => true},
|
163
163
|
:nickname => {:text => 'contacts:Nickname', :writable => true},
|
164
164
|
:office_location => {:text => 'contacts:OfficeLocation', :writable => true},
|
165
|
-
:phone_numbers => {:text => 'contacts:
|
165
|
+
:phone_numbers => {:ftype => :indexed_field_uRI, :text => 'contacts:PhoneNumber', :writable => true},
|
166
166
|
:physical_addresses => {:text => 'contacts:PhysicalAddresses', :writable => true},
|
167
167
|
:postal_address_index => {:text => 'contacts:PostalAddressIndex', :writable => true},
|
168
168
|
:profession => {:text => 'contacts:Profession', :writable => true},
|
data/lib/model/mailbox_user.rb
CHANGED
@@ -79,12 +79,15 @@ module Viewpoint
|
|
79
79
|
# @return [true] This method either returns true or raises an error with the message
|
80
80
|
# as to why this operation did not succeed.
|
81
81
|
def add_delegate!(delegate_email, permissions)
|
82
|
+
# Use a new hash so the passed hash is not modified in case we are in a loop.
|
83
|
+
# Thanks to Markus Roberts for pointing this out.
|
84
|
+
formatted_perms = {}
|
82
85
|
# Modify permissions so we can pass it to the builders
|
83
86
|
permissions.each_pair do |k,v|
|
84
|
-
|
87
|
+
formatted_perms[k] = {:text => v}
|
85
88
|
end
|
86
89
|
|
87
|
-
resp = (Viewpoint::EWS::EWS.instance).ews.add_delegate(self.email_address, delegate_email,
|
90
|
+
resp = (Viewpoint::EWS::EWS.instance).ews.add_delegate(self.email_address, delegate_email, formatted_perms)
|
88
91
|
if(resp.status == 'Success')
|
89
92
|
return true
|
90
93
|
else
|
@@ -94,11 +97,12 @@ module Viewpoint
|
|
94
97
|
|
95
98
|
def update_delegate!(delegate_email, permissions)
|
96
99
|
# Modify permissions so we can pass it to the builders
|
100
|
+
formatted_perms = {}
|
97
101
|
permissions.each_pair do |k,v|
|
98
|
-
|
102
|
+
formatted_perms[k] = {:text => v}
|
99
103
|
end
|
100
104
|
|
101
|
-
resp = (Viewpoint::EWS::EWS.instance).ews.update_delegate(self.email_address, delegate_email,
|
105
|
+
resp = (Viewpoint::EWS::EWS.instance).ews.update_delegate(self.email_address, delegate_email, formatted_perms)
|
102
106
|
if(resp.status == 'Success')
|
103
107
|
return true
|
104
108
|
else
|
data/lib/viewpoint.rb
CHANGED
@@ -127,7 +127,7 @@ module Viewpoint
|
|
127
127
|
|
128
128
|
# The MailboxUser object that represents the user connected to EWS.
|
129
129
|
def me
|
130
|
-
|
130
|
+
MailboxUser.find_user((@@user.include?('@') ? @@user : "#{@@user}@"))
|
131
131
|
end
|
132
132
|
|
133
133
|
end # class EWS
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: viewpoint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.21
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Dan Wanek
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-03-
|
13
|
+
date: 2011-03-10 00:00:00 -06:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|