Permalink
Browse files

Added unsubscribe method

  • Loading branch information...
1 parent c6eb513 commit 0ad5dea4960a27fe026f955e8d7ebe49d9d77f36 @cannikin cannikin committed Feb 4, 2012
Showing with 24 additions and 0 deletions.
  1. +18 −0 lib/postal/driver.rb
  2. +6 −0 lib/postal/member.rb
View
@@ -22,16 +22,19 @@ def initialize(wsdl_url = nil, proxy = nil, username = nil, password = nil)
end
end
+
def soap_actions
@client.wsdl.soap_actions
end
+
def selectMembers(args)
response = @client.request :wsdl, :select_members do |soap|
soap.body = { "FilterCriteriaArray" => {'item' => args} }
end
response.to_hash[:select_members_response][:return]
end
+
def createSingleMember(email, name, list_name)
response = @client.request :wsdl, :create_single_member do |soap|
@@ -41,6 +44,7 @@ def createSingleMember(email, name, list_name)
end
response.to_hash[:create_single_member_response][:return].to_i
end
+
def deleteMembers(args)
response = @client.request :wsdl, :delete_members do |soap|
@@ -50,6 +54,17 @@ def deleteMembers(args)
end
+ def unsubscribe(list_name, id, email)
+ response = @client.request :wsdl, :unsubscribe do |soap|
+ soap.body = { 'SimpleMemberStructArrayIn' => {
+ 'item' => {
+ 'ListName' => list_name,
+ 'MemberID' => id,
+ 'EmailAddress' => email }}}
+ end
+ response.to_hash[:unsubscribe_response][:return]
+ end
+
def updateMemberDemographics(list_name, id, email, demographics)
response = @client.request :wsdl, :update_member_demographics do |soap|
@@ -62,12 +77,14 @@ def updateMemberDemographics(list_name, id, email, demographics)
response.to_hash[:update_member_demographics_response][:return]
end
+
def selectContent(args)
response = @client.request :wsdl, :select_content do |soap|
soap.body = { "FilterCriteriaArray" => {'item' => args} }
end
response.to_hash[:select_content_response][:return]
end
+
def selectLists(list_name, site_name)
response = @client.request :wsdl, :select_lists do |soap|
@@ -81,6 +98,7 @@ def selectLists(list_name, site_name)
end
end
+
def importContent(content_id)
response = @client.request :wsdl, :import_content do |soap|
soap.body = { "ContentID" => content_id }
View
@@ -136,6 +136,12 @@ def save!
raise Postal::CouldNotCreateMember, 'Could not create a new member. The most likely cause is that the specified list already contains this email address.'
end
end
+
+
+ def unsubscribe
+ list_name = @list_name
+ return Postal.driver.unsubscribe(list_name, @id, @email)
+ end
# Update the demographics for a user

0 comments on commit 0ad5dea

Please sign in to comment.