-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added accessor methods for meeting actions
- Loading branch information
1 parent
a20277d
commit d73cf56
Showing
5 changed files
with
160 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module Viewpoint::EWS::MeetingAccessors | ||
include Viewpoint::EWS | ||
|
||
def accept_meeting(opts) | ||
ews.create_item({ | ||
message_disposition: 'SendOnly', | ||
items: [ { accept_item: opts_to_item(opts) } ] | ||
}) | ||
end | ||
|
||
def decline_meeting(opts) | ||
ews.create_item({ | ||
message_disposition: 'SendOnly', | ||
items: [ { decline_item: opts_to_item(opts) } ] | ||
}) | ||
end | ||
|
||
def tentatively_accept_meeting(opts) | ||
ews.create_item({ | ||
message_disposition: 'SendOnly', | ||
items: [ { tentatively_accept_item: opts_to_item(opts) } ] | ||
}) | ||
end | ||
|
||
private | ||
|
||
def opts_to_item(opts) | ||
{ | ||
id: opts[:id], | ||
change_key: opts[:change_key], | ||
text: opts[:text], | ||
sensitivity: opts[:sensitivity] | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
require_relative '../spec_helper' | ||
|
||
describe Viewpoint::EWS::MeetingAccessors do | ||
let(:ecli) { Viewpoint::EWSClient.new('dontcare', 'dontcare', 'dontcare') } | ||
|
||
let(:default_opts) do | ||
{ | ||
id: 'foo-id', | ||
change_key: 'change-key', | ||
text: 'example text', | ||
sensitivity: 'Private', | ||
} | ||
end | ||
|
||
context "#accept_meeting" do | ||
let(:create_item_request) do | ||
"<soap:Body> | ||
<CreateItem xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\" MessageDisposition=\"SendOnly\"> | ||
<Items> | ||
<t:AcceptItem> | ||
<t:ReferenceItemId Id=\"foo-id\" ChangeKey=\"change-key\"/> | ||
<t:Body>example text</t:Body> | ||
<t:Sensitivity>Private</t:Sensitivity> | ||
</t:AcceptItem> | ||
</Items> | ||
</CreateItem> | ||
</soap:Body>" | ||
end | ||
|
||
it "should form valid accept item request" do | ||
Viewpoint::EWS::SOAP::ExchangeWebService.any_instance. | ||
should_receive(:do_soap_request) do |request_document| | ||
request_document.at_xpath('//soap:Envelope/soap:Body').to_s.should eq create_item_request | ||
end. | ||
and_return(double(:resp, :status => 'Success')) | ||
|
||
ecli.accept_meeting(default_opts) | ||
end | ||
end | ||
|
||
context "#decline_meeting" do | ||
let(:create_item_request) do | ||
"<soap:Body> | ||
<CreateItem xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\" MessageDisposition=\"SendOnly\"> | ||
<Items> | ||
<t:DeclineItem> | ||
<t:ReferenceItemId Id=\"foo-id\" ChangeKey=\"change-key\"/> | ||
<t:Body>example text</t:Body> | ||
<t:Sensitivity>Private</t:Sensitivity> | ||
</t:DeclineItem> | ||
</Items> | ||
</CreateItem> | ||
</soap:Body>" | ||
end | ||
|
||
it "should form valid accept item request" do | ||
Viewpoint::EWS::SOAP::ExchangeWebService.any_instance. | ||
should_receive(:do_soap_request) do |request_document| | ||
request_document.at_xpath('//soap:Envelope/soap:Body').to_s.should eq create_item_request | ||
end. | ||
and_return(double(:resp, :status => 'success')) | ||
|
||
ecli.decline_meeting(default_opts) | ||
end | ||
end | ||
|
||
context "#tentatively_accept_meeting" do | ||
let(:create_item_request) do | ||
"<soap:Body> | ||
<CreateItem xmlns=\"http://schemas.microsoft.com/exchange/services/2006/messages\" MessageDisposition=\"SendOnly\"> | ||
<Items> | ||
<t:TentativelyAcceptItem> | ||
<t:ReferenceItemId Id=\"foo-id\" ChangeKey=\"change-key\"/> | ||
<t:Body>example text</t:Body> | ||
<t:Sensitivity>Private</t:Sensitivity> | ||
</t:TentativelyAcceptItem> | ||
</Items> | ||
</CreateItem> | ||
</soap:Body>" | ||
end | ||
|
||
it "should form valid accept item request" do | ||
Viewpoint::EWS::SOAP::ExchangeWebService.any_instance. | ||
should_receive(:do_soap_request) do |request_document| | ||
request_document.at_xpath('//soap:Envelope/soap:Body').to_s.should eq create_item_request | ||
end. | ||
and_return(double(:resp, :status => 'success')) | ||
|
||
ecli.tentatively_accept_meeting(default_opts) | ||
end | ||
end | ||
end |