exchanger 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -8,9 +8,9 @@ It will keep track of changed properties and will update only them.
8
8
  Supported operations
9
9
  ====================
10
10
 
11
- * FindItem, GetItem, CreateItem, UpdateItem
11
+ * FindItem, GetItem, CreateItem, UpdateItem, DeleteItem
12
12
  * FindFolder, GetFolder
13
-
13
+ * ResolveNames, ExpandDL
14
14
 
15
15
  Installing
16
16
  ==========
@@ -45,6 +45,12 @@ Creating and updating contacts
45
45
  contact.save # CreateItem operation
46
46
  contact.company_name = "Tieto"
47
47
  contact.save # UpdateItem operation
48
+ contact.destroy # DeleteItem operation
49
+
50
+ Searching in Global Address Book
51
+ --------------------------------
52
+
53
+ mailboxes = Exchanger::Mailbox.search("John")
48
54
 
49
55
  Alternatives
50
56
  ============
@@ -7,6 +7,7 @@ require "nokogiri"
7
7
  require "httpclient"
8
8
  require "net/ntlm"
9
9
 
10
+ require "exchanger/version"
10
11
  require "exchanger/config"
11
12
  require "exchanger/client"
12
13
  require "exchanger/boolean"
@@ -55,6 +56,7 @@ require "exchanger/operations/get_item"
55
56
  require "exchanger/operations/find_item"
56
57
  require "exchanger/operations/create_item"
57
58
  require "exchanger/operations/update_item"
59
+ require "exchanger/operations/delete_item"
58
60
  require "exchanger/operations/resolve_names"
59
61
  require "exchanger/operations/expand_dl"
60
62
 
@@ -135,7 +135,9 @@ module Exchanger
135
135
  if element_xml.text.present?
136
136
  set_item_field = doc.create_element("SetItemField")
137
137
  set_item_field << field_uri_xml
138
- set_item_field << doc.create_element(tag_name) << element_xml
138
+ element_wrapper = doc.create_element(tag_name)
139
+ element_wrapper << element_xml
140
+ set_item_field << element_wrapper
139
141
  root << set_item_field
140
142
  else
141
143
  delete_item_field = doc.create_element("DeleteItemField")
@@ -82,5 +82,13 @@ module Exchanger
82
82
  true
83
83
  end
84
84
  end
85
+
86
+ def delete
87
+ if DeleteItem.run(:item_ids => [id])
88
+ true
89
+ else
90
+ false
91
+ end
92
+ end
85
93
  end
86
94
  end
@@ -0,0 +1,41 @@
1
+ module Exchanger
2
+ # The DeleteItem operation deletes items in the Exchanger store.
3
+ #
4
+ # You can use the DeleteItem operation to delete the following:
5
+ # * Calendar items
6
+ # * E-mail messages
7
+ # * Meeting requests
8
+ # * Tasks
9
+ # * Contacts
10
+ #
11
+ # http://msdn.microsoft.com/en-us/library/aa580484.aspx
12
+ class DeleteItem < Operation
13
+ class Request < Operation::Request
14
+ attr_accessor :item_ids
15
+
16
+ # Reset request options to defaults.
17
+ def reset
18
+ @item_ids = []
19
+ end
20
+
21
+ def to_xml
22
+ Nokogiri::XML::Builder.new do |xml|
23
+ xml.send("soap:Envelope", "xmlns:soap" => NS["soap"], "xmlns:t" => NS["t"], "xmlns:xsi" => NS["xsi"], "xmlns:xsd" => NS["xsd"]) do
24
+ xml.send("soap:Body") do
25
+ xml.DeleteItem("xmlns" => NS["m"], "DeleteType" => "HardDelete") do
26
+ xml.ItemIds do
27
+ item_ids.each do |item_id|
28
+ xml["t"].ItemId("Id" => item_id)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ class Response < Operation::Response
39
+ end
40
+ end
41
+ end
@@ -12,6 +12,14 @@ module Exchanger
12
12
  end
13
13
  end
14
14
 
15
+ def destroy
16
+ if new_record?
17
+ false
18
+ else
19
+ delete
20
+ end
21
+ end
22
+
15
23
  # Reloads the +Element+ attributes from Exchanger.
16
24
  def reload
17
25
  if new_record?
@@ -0,0 +1,3 @@
1
+ module Exchanger
2
+ VERSION = "0.1.1"
3
+ end
@@ -1,8 +1,8 @@
1
- require "spec/spec_helper"
1
+ require "spec_helper"
2
2
 
3
3
  describe Exchanger::CalendarFolder do
4
4
  before do
5
- @folder = Exchanger::Folder.find(:calendar, "edgars.beigarts@tieto.com")
5
+ @folder = Exchanger::Folder.find(:calendar)
6
6
  end
7
7
 
8
8
  it "should return calendar folder" do
@@ -16,7 +16,7 @@ end
16
16
 
17
17
  describe Exchanger::CalendarItem do
18
18
  before do
19
- @folder = Exchanger::Folder.find(:calendar, "edgars.beigarts@tieto.com")
19
+ @folder = Exchanger::Folder.find(:calendar)
20
20
  @item = @folder.items.first
21
21
  end
22
22
 
@@ -1,4 +1,4 @@
1
- require "spec/spec_helper"
1
+ require "spec_helper"
2
2
 
3
3
  describe Exchanger::Client do
4
4
  before do
@@ -0,0 +1,4 @@
1
+ endpoint: https://email.tieto.com/EWS/Exchange.asmx
2
+ username: rails_tests
3
+ password: Latvia567
4
+ debug: false
@@ -0,0 +1,4 @@
1
+ endpoint: https://domain.com/EWS/Exchange.asmx
2
+ username: username
3
+ password: password
4
+ debug: true
@@ -1,19 +1,15 @@
1
- require "spec/spec_helper"
1
+ require "spec_helper"
2
2
 
3
3
  describe Exchanger::Contact do
4
4
  before do
5
- @folder = Exchanger::Folder.find(:contacts, "edgars.beigarts@tieto.com")
5
+ @folder = Exchanger::Folder.find(:contacts)
6
6
  end
7
7
 
8
8
  it "should return calendar folder" do
9
9
  @folder.class.should == Exchanger::ContactsFolder
10
10
  end
11
11
 
12
- it "should have contacts" do
13
- @folder.items.size.should > 0
14
- end
15
-
16
- it "should create a new contact and update it" do
12
+ it "should create a new contact, update it and destroy it" do
17
13
  prev_items_size = @folder.items.size
18
14
  @contact = @folder.new_contact(:given_name => "Edgars", :surname => "Beigarts", :nickname => "EBEI")
19
15
  @contact.complete_name = \
@@ -46,15 +42,18 @@ describe Exchanger::Contact do
46
42
  @contact.save
47
43
  @contact.should_not be_changed
48
44
  @contact.physical_addresses.size.should == 1
45
+ @contact.destroy.should be_true
49
46
  end
50
47
 
51
48
  it "should find a contact by id" do
52
49
  @contact = @folder.items.first
50
+ pending "Folder is empty" unless @contact
53
51
  Exchanger::Item.find(@contact.id).should be_an_instance_of(Exchanger::Contact)
54
52
  end
55
53
 
56
54
  it "should have parent folder" do
57
55
  @contact = @folder.items.first
56
+ pending "Folder is empty" unless @contact
58
57
  @contact.parent_folder.should == @folder
59
58
  @contact = Exchanger::Item.find(@contact.id)
60
59
  @contact.parent_folder.should == @folder
@@ -1,4 +1,4 @@
1
- require "spec/spec_helper"
1
+ require "spec_helper"
2
2
 
3
3
  describe Exchanger::Element do
4
4
  end
@@ -1,4 +1,4 @@
1
- require "spec/spec_helper"
1
+ require "spec_helper"
2
2
 
3
3
  describe Exchanger::Field do
4
4
  describe "String (default type)" do
@@ -1,4 +1,4 @@
1
- require "spec/spec_helper"
1
+ require "spec_helper"
2
2
 
3
3
  describe Exchanger::Folder do
4
4
  describe "Root" do
@@ -2,5 +2,6 @@ $:.unshift File.dirname(__FILE__) + '/../lib'
2
2
 
3
3
  require "rubygems"
4
4
  require "exchanger"
5
+ require "kconv"
5
6
 
6
7
  Exchanger::Config.instance.from_hash(YAML.load_file("#{File.dirname(__FILE__)}/config.yml"))
metadata CHANGED
@@ -1,117 +1,132 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: exchanger
3
- version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 1
9
- - 0
10
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Edgars Beigarts
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-10-07 00:00:00 +03:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2011-08-09 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: activesupport
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2155949560 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 2
32
- - 2
33
- - 2
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
34
21
  version: 2.2.2
35
22
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: nokogiri
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2155949560
25
+ - !ruby/object:Gem::Dependency
26
+ name: nokogiri
27
+ requirement: &2155948180 !ruby/object:Gem::Requirement
41
28
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 27
46
- segments:
47
- - 1
48
- - 3
49
- - 0
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
50
32
  version: 1.3.0
51
33
  type: :runtime
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: httpclient
55
34
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *2155948180
36
+ - !ruby/object:Gem::Dependency
37
+ name: httpclient
38
+ requirement: &2155946420 !ruby/object:Gem::Requirement
57
39
  none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- hash: 119
62
- segments:
63
- - 2
64
- - 1
65
- - 5
66
- - 2
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
67
43
  version: 2.1.5.2
68
44
  type: :runtime
69
- version_requirements: *id003
70
- - !ruby/object:Gem::Dependency
71
- name: rubyntlm
72
45
  prerelease: false
73
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *2155946420
47
+ - !ruby/object:Gem::Dependency
48
+ name: rubyntlm
49
+ requirement: &2155944760 !ruby/object:Gem::Requirement
74
50
  none: false
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- hash: 25
79
- segments:
80
- - 0
81
- - 1
82
- - 1
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
83
54
  version: 0.1.1
84
55
  type: :runtime
85
- version_requirements: *id004
86
- - !ruby/object:Gem::Dependency
87
- name: rspec
88
56
  prerelease: false
89
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *2155944760
58
+ - !ruby/object:Gem::Dependency
59
+ name: rake
60
+ requirement: &2155943420 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *2155943420
69
+ - !ruby/object:Gem::Dependency
70
+ name: i18n
71
+ requirement: &2155941920 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *2155941920
80
+ - !ruby/object:Gem::Dependency
81
+ name: rspec
82
+ requirement: &2155940420 !ruby/object:Gem::Requirement
90
83
  none: false
91
- requirements:
84
+ requirements:
92
85
  - - ~>
93
- - !ruby/object:Gem::Version
94
- hash: 27
95
- segments:
96
- - 1
97
- - 3
98
- - 0
99
- version: 1.3.0
86
+ - !ruby/object:Gem::Version
87
+ version: 2.6.0
100
88
  type: :development
101
- version_requirements: *id005
89
+ prerelease: false
90
+ version_requirements: *2155940420
91
+ - !ruby/object:Gem::Dependency
92
+ name: rcov
93
+ requirement: &2155939500 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *2155939500
102
+ - !ruby/object:Gem::Dependency
103
+ name: yard
104
+ requirement: &2155938420 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *2155938420
113
+ - !ruby/object:Gem::Dependency
114
+ name: BlueCloth
115
+ requirement: &2155937360 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: *2155937360
102
124
  description: Ruby library for accessing Microsoft Exchange using Exchange Web Services
103
125
  email: 1@wb4.lv
104
126
  executables: []
105
-
106
127
  extensions: []
107
-
108
- extra_rdoc_files:
109
- - LICENSE
110
- - README.md
111
- files:
112
- - LICENSE
113
- - README.md
114
- - lib/exchanger.rb
128
+ extra_rdoc_files: []
129
+ files:
115
130
  - lib/exchanger/attributes.rb
116
131
  - lib/exchanger/boolean.rb
117
132
  - lib/exchanger/client.rb
@@ -147,6 +162,7 @@ files:
147
162
  - lib/exchanger/field.rb
148
163
  - lib/exchanger/operation.rb
149
164
  - lib/exchanger/operations/create_item.rb
165
+ - lib/exchanger/operations/delete_item.rb
150
166
  - lib/exchanger/operations/expand_dl.rb
151
167
  - lib/exchanger/operations/find_folder.rb
152
168
  - lib/exchanger/operations/find_item.rb
@@ -155,54 +171,48 @@ files:
155
171
  - lib/exchanger/operations/resolve_names.rb
156
172
  - lib/exchanger/operations/update_item.rb
157
173
  - lib/exchanger/persistence.rb
174
+ - lib/exchanger/version.rb
175
+ - lib/exchanger.rb
158
176
  - spec/calendar_item_spec.rb
159
177
  - spec/client_spec.rb
178
+ - spec/config.yml
179
+ - spec/config.yml.example
160
180
  - spec/contact_spec.rb
161
181
  - spec/element_spec.rb
162
182
  - spec/field_spec.rb
163
183
  - spec/folder_spec.rb
164
184
  - spec/mailbox_spec.rb
165
185
  - spec/spec_helper.rb
166
- has_rdoc: true
186
+ - README.md
187
+ - LICENSE
167
188
  homepage: http://github.com/ebeigarts/exchanger
168
189
  licenses: []
169
-
170
190
  post_install_message:
171
- rdoc_options:
172
- - --charset=UTF-8
173
- require_paths:
191
+ rdoc_options: []
192
+ require_paths:
174
193
  - lib
175
- required_ruby_version: !ruby/object:Gem::Requirement
194
+ required_ruby_version: !ruby/object:Gem::Requirement
176
195
  none: false
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- hash: 3
181
- segments:
196
+ requirements:
197
+ - - ! '>='
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ segments:
182
201
  - 0
183
- version: "0"
184
- required_rubygems_version: !ruby/object:Gem::Requirement
202
+ hash: 4456452976116017583
203
+ required_rubygems_version: !ruby/object:Gem::Requirement
185
204
  none: false
186
- requirements:
187
- - - ">="
188
- - !ruby/object:Gem::Version
189
- hash: 3
190
- segments:
205
+ requirements:
206
+ - - ! '>='
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ segments:
191
210
  - 0
192
- version: "0"
211
+ hash: 4456452976116017583
193
212
  requirements: []
194
-
195
213
  rubyforge_project:
196
- rubygems_version: 1.3.7
214
+ rubygems_version: 1.8.6
197
215
  signing_key:
198
216
  specification_version: 3
199
217
  summary: Ruby library for accessing Microsoft Exchange using Exchange Web Services
200
- test_files:
201
- - spec/calendar_item_spec.rb
202
- - spec/client_spec.rb
203
- - spec/contact_spec.rb
204
- - spec/element_spec.rb
205
- - spec/field_spec.rb
206
- - spec/folder_spec.rb
207
- - spec/mailbox_spec.rb
208
- - spec/spec_helper.rb
218
+ test_files: []