em-msn 0.6 → 0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -89,15 +89,25 @@ class Msn::NotificationServer < EventMachine::Connection
89
89
  contacts.values
90
90
  end
91
91
 
92
- def get_soap_contacts
92
+ def get_soap_contacts(url = "https://local-bay.contacts.msn.com/abservice/SharingService.asmx")
93
93
  msn_get_contacts_template_file = File.expand_path('../soap/msn_get_contacts_template.xml', __FILE__)
94
94
  msn_get_contacts_template = ERB.new File.read(msn_get_contacts_template_file)
95
95
  soap = msn_get_contacts_template.result(binding)
96
96
 
97
- RestClient.post "https://local-bay.contacts.msn.com/abservice/SharingService.asmx", soap, {
97
+ RestClient.post url, soap, {
98
98
  'SOAPAction' => 'http://www.msn.com/webservices/AddressBook/FindMembership',
99
99
  'Content-Type' => 'text/xml',
100
100
  }
101
+ rescue RestClient::ExceptionWithResponse => ex
102
+ # Assume the CacheKey changed and we need to request to another URL
103
+ xml = Nokogiri::XML(ex.response.body)
104
+ cache_key = xml.xpath("//ns:CacheKey", ContactsNamespace).first
105
+ @cache_key = cache_key.text if cache_key
106
+ get_soap_contacts(ex.response.headers[:location])
107
+ end
108
+
109
+ def cache_key_xml
110
+ @cache_key ? "<CacheKey>#{REXML::Text.normalize @cache_key}</CacheKey>" : ""
101
111
  end
102
112
 
103
113
  def post_init
@@ -5,6 +5,7 @@
5
5
  <ApplicationId xmlns="http://www.msn.com/webservices/AddressBook"><%= Msn::ApplicationId %></ApplicationId>
6
6
  <IsMigration xmlns="http://www.msn.com/webservices/AddressBook">false</IsMigration>
7
7
  <PartnerScenario xmlns="http://www.msn.com/webservices/AddressBook">Initial</PartnerScenario>
8
+ <%= cache_key_xml %>
8
9
  </ABApplicationHeader>
9
10
  <ABAuthHeader xmlns="http://www.msn.com/webservices/AddressBook">
10
11
  <ManagedGroupRequest xmlns="http://www.msn.com/webservices/AddressBook">false</ManagedGroupRequest>
data/lib/msn/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Msn
2
- VERSION = "0.6"
2
+ VERSION = "0.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-msn
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.6'
4
+ version: '0.7'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: