Permalink
Browse files

Changes to Client.GetCampaigns and List.GetStats

  • Loading branch information...
Marcelo Menezes Marcelo Menezes
Marcelo Menezes authored and Marcelo Menezes committed Nov 30, 2009
1 parent a75fba9 commit 4dd053422609973fc5d3d3daaf0d760a46072a83
@@ -8,13 +8,15 @@ class Campaign
include ModuleMixin
attr_accessor :campaignID
attr_accessor :subject
+ attr_accessor :name
attr_accessor :sentDate
attr_accessor :totalRecipients
-
- def initialize(campaignID = nil, subject = nil, sentDate = nil, totalRecipients = nil, opts={})
+
+ def initialize(campaignID = nil, subject = nil, name = nil, sentDate = nil, totalRecipients = nil, opts={})
@apiKey = opts[:apiKey] || CAMPAIGN_MONITOR_API_KEY
@campaignID = campaignID
@subject = subject
+ @name = name
@sentDate = sentDate
@totalRecipients = totalRecipients
end
@@ -59,7 +61,7 @@ def self.create!(params)
)
campaign_id = handle_response response.campaign_CreateResult
- Campaign.new( campaign_id, nil, nil, nil, :apiKey=> (params[:apiKey] || CAMPAIGN_MONITOR_API_KEY) )
+ Campaign.new( campaign_id, nil, params[:campaignName], nil, nil, :apiKey=> (params[:apiKey] || CAMPAIGN_MONITOR_API_KEY) )
end
#Deletes an existing campaign.
@@ -196,7 +196,7 @@ def campaigns
response = @@soap.getClientCampaigns(:apiKey => @apiKey, :clientID => @clientID )
campaign_list = handle_response response.client_GetCampaignsResult
campaign_list.collect do |campaign|
- Campaign.new(campaign.campaignID, campaign.subject, campaign.sentDate, campaign.totalRecipients, :apiKey=> @apiKey)
+ Campaign.new(campaign.campaignID, campaign.subject, campaign.name, campaign.sentDate, campaign.totalRecipients, :apiKey=> @apiKey)
end
end
View
@@ -97,6 +97,39 @@ def self.delete!(list_id, opts={})
response = @@soap.deleteList(:apiKey => opts[:apiKey] || CAMPAIGN_MONITOR_API_KEY, :listID => list_id)
handle_response response.list_DeleteResult
end
+
+ #Gets statistics for a subscriber list
+ #
+ #*Return*:
+ #
+ #*Success*: A successful call to List.GetStats will return a ListStatistics object, consisting of TotalActiveSubscribers,
+ #NewActiveSubscribersToday, NewActiveSubscribersYesterday, NewActiveSubscribersThisWeek, NewActiveSubscribersThisMonth,
+ #NewActiveSubscribersThisYear, TotalUnsubscribes, UnsubscribesToday, UnsubscribesYesterday, UnsubscribesThisWeek,
+ #UnsubscribesThisMonth, UnsubscribesThisYear, TotalDeleted, DeletedToday, DeletedYesterday, DeletedThisWeek, DeletedThisMonth,
+ #DeletedThisYear, TotalBounces, BouncesToday, BouncesYesterday, BouncesThisWeek, BouncesThisMonth and BouncesThisYear.
+ #
+ #*Error*: An Exception containing the cause of the error will be raised.
+ def stats
+ List.stats(@listID, :apiKey=> @apiKey)
+ end
+
+
+ #Gets statistics for a subscriber list
+ #
+ #*Return*:
+ #
+ #*Success*: A successful call to List.GetStats will return a ListStatistics object, consisting of TotalActiveSubscribers,
+ #NewActiveSubscribersToday, NewActiveSubscribersYesterday, NewActiveSubscribersThisWeek, NewActiveSubscribersThisMonth,
+ #NewActiveSubscribersThisYear, TotalUnsubscribes, UnsubscribesToday, UnsubscribesYesterday, UnsubscribesThisWeek,
+ #UnsubscribesThisMonth, UnsubscribesThisYear, TotalDeleted, DeletedToday, DeletedYesterday, DeletedThisWeek, DeletedThisMonth,
+ #DeletedThisYear, TotalBounces, BouncesToday, BouncesYesterday, BouncesThisWeek, BouncesThisMonth and BouncesThisYear.
+ #
+ #*Error*: An Exception containing the cause of the error will be raised.
+ def self.stats(list_id, opts={})
+ response = @@soap.getListStats(:apiKey => opts[:apiKey] || CAMPAIGN_MONITOR_API_KEY, :listID => list_id)
+ handle_response response.list_GetStatsResult
+ end
+
#Deletes a custom field from a list
#
@@ -3,23 +3,6 @@
module Campaigning
-# {http://api.createsend.com/api/}ArrayOfSubscriberCustomField
-class ArrayOfSubscriberCustomField < ::Array
-end
-
-# {http://api.createsend.com/api/}SubscriberCustomField
-# key - SOAP::SOAPString
-# value - SOAP::SOAPString
-class SubscriberCustomField
- attr_accessor :key
- attr_accessor :value
-
- def initialize(key = nil, value = nil)
- @key = key
- @value = value
- end
-end
-
# {http://api.createsend.com/api/}Result
# code - SOAP::SOAPInt
# message - SOAP::SOAPString
@@ -250,22 +233,104 @@ def initialize(listID = nil, name = nil)
# {http://api.createsend.com/api/}Campaign
# campaignID - SOAP::SOAPString
# subject - SOAP::SOAPString
+# name - SOAP::SOAPString
# sentDate - SOAP::SOAPString
# totalRecipients - SOAP::SOAPInt
class Campaign
attr_accessor :campaignID
attr_accessor :subject
+ attr_accessor :name
attr_accessor :sentDate
attr_accessor :totalRecipients
- def initialize(campaignID = nil, subject = nil, sentDate = nil, totalRecipients = nil)
+ def initialize(campaignID = nil, subject = nil, name = nil, sentDate = nil, totalRecipients = nil)
@campaignID = campaignID
@subject = subject
+ @name = name
@sentDate = sentDate
@totalRecipients = totalRecipients
end
end
+# {http://api.createsend.com/api/}ListStatistics
+# totalActiveSubscribers - SOAP::SOAPInt
+# newActiveSubscribersToday - SOAP::SOAPInt
+# newActiveSubscribersYesterday - SOAP::SOAPInt
+# newActiveSubscribersThisWeek - SOAP::SOAPInt
+# newActiveSubscribersThisMonth - SOAP::SOAPInt
+# newActiveSubscribersThisYear - SOAP::SOAPInt
+# totalUnsubscribes - SOAP::SOAPInt
+# unsubscribesToday - SOAP::SOAPInt
+# unsubscribesYesterday - SOAP::SOAPInt
+# unsubscribesThisWeek - SOAP::SOAPInt
+# unsubscribesThisMonth - SOAP::SOAPInt
+# unsubscribesThisYear - SOAP::SOAPInt
+# totalDeleted - SOAP::SOAPInt
+# deletedToday - SOAP::SOAPInt
+# deletedYesterday - SOAP::SOAPInt
+# deletedThisWeek - SOAP::SOAPInt
+# deletedThisMonth - SOAP::SOAPInt
+# deletedThisYear - SOAP::SOAPInt
+# totalBounces - SOAP::SOAPInt
+# bouncesToday - SOAP::SOAPInt
+# bouncesYesterday - SOAP::SOAPInt
+# bouncesThisWeek - SOAP::SOAPInt
+# bouncesThisMonth - SOAP::SOAPInt
+# bouncesThisYear - SOAP::SOAPInt
+class ListStatistics
+ attr_accessor :totalActiveSubscribers
+ attr_accessor :newActiveSubscribersToday
+ attr_accessor :newActiveSubscribersYesterday
+ attr_accessor :newActiveSubscribersThisWeek
+ attr_accessor :newActiveSubscribersThisMonth
+ attr_accessor :newActiveSubscribersThisYear
+ attr_accessor :totalUnsubscribes
+ attr_accessor :unsubscribesToday
+ attr_accessor :unsubscribesYesterday
+ attr_accessor :unsubscribesThisWeek
+ attr_accessor :unsubscribesThisMonth
+ attr_accessor :unsubscribesThisYear
+ attr_accessor :totalDeleted
+ attr_accessor :deletedToday
+ attr_accessor :deletedYesterday
+ attr_accessor :deletedThisWeek
+ attr_accessor :deletedThisMonth
+ attr_accessor :deletedThisYear
+ attr_accessor :totalBounces
+ attr_accessor :bouncesToday
+ attr_accessor :bouncesYesterday
+ attr_accessor :bouncesThisWeek
+ attr_accessor :bouncesThisMonth
+ attr_accessor :bouncesThisYear
+
+ def initialize(totalActiveSubscribers = nil, newActiveSubscribersToday = nil, newActiveSubscribersYesterday = nil, newActiveSubscribersThisWeek = nil, newActiveSubscribersThisMonth = nil, newActiveSubscribersThisYear = nil, totalUnsubscribes = nil, unsubscribesToday = nil, unsubscribesYesterday = nil, unsubscribesThisWeek = nil, unsubscribesThisMonth = nil, unsubscribesThisYear = nil, totalDeleted = nil, deletedToday = nil, deletedYesterday = nil, deletedThisWeek = nil, deletedThisMonth = nil, deletedThisYear = nil, totalBounces = nil, bouncesToday = nil, bouncesYesterday = nil, bouncesThisWeek = nil, bouncesThisMonth = nil, bouncesThisYear = nil)
+ @totalActiveSubscribers = totalActiveSubscribers
+ @newActiveSubscribersToday = newActiveSubscribersToday
+ @newActiveSubscribersYesterday = newActiveSubscribersYesterday
+ @newActiveSubscribersThisWeek = newActiveSubscribersThisWeek
+ @newActiveSubscribersThisMonth = newActiveSubscribersThisMonth
+ @newActiveSubscribersThisYear = newActiveSubscribersThisYear
+ @totalUnsubscribes = totalUnsubscribes
+ @unsubscribesToday = unsubscribesToday
+ @unsubscribesYesterday = unsubscribesYesterday
+ @unsubscribesThisWeek = unsubscribesThisWeek
+ @unsubscribesThisMonth = unsubscribesThisMonth
+ @unsubscribesThisYear = unsubscribesThisYear
+ @totalDeleted = totalDeleted
+ @deletedToday = deletedToday
+ @deletedYesterday = deletedYesterday
+ @deletedThisWeek = deletedThisWeek
+ @deletedThisMonth = deletedThisMonth
+ @deletedThisYear = deletedThisYear
+ @totalBounces = totalBounces
+ @bouncesToday = bouncesToday
+ @bouncesYesterday = bouncesYesterday
+ @bouncesThisWeek = bouncesThisWeek
+ @bouncesThisMonth = bouncesThisMonth
+ @bouncesThisYear = bouncesThisYear
+ end
+end
+
# {http://api.createsend.com/api/}ListCustomField
# fieldName - SOAP::SOAPString
# key - SOAP::SOAPString
@@ -333,6 +398,23 @@ def initialize(emailAddress = nil, name = nil, date = nil, state = nil, customFi
end
end
+# {http://api.createsend.com/api/}ArrayOfSubscriberCustomField
+class ArrayOfSubscriberCustomField < ::Array
+end
+
+# {http://api.createsend.com/api/}SubscriberCustomField
+# key - SOAP::SOAPString
+# value - SOAP::SOAPString
+class SubscriberCustomField
+ attr_accessor :key
+ attr_accessor :value
+
+ def initialize(key = nil, value = nil)
+ @key = key
+ @value = value
+ end
+end
+
# {http://api.createsend.com/api/}ArrayOfSubscriber
class ArrayOfSubscriber < ::Array
end
@@ -381,6 +463,32 @@ class SubscriberFieldDataType < ::String
Text = SubscriberFieldDataType.new("Text")
end
+# {http://api.createsend.com/api/}User.GetApiKey
+# siteUrl - SOAP::SOAPString
+# username - SOAP::SOAPString
+# password - SOAP::SOAPString
+class UserGetApiKey
+ attr_accessor :siteUrl
+ attr_accessor :username
+ attr_accessor :password
+
+ def initialize(siteUrl = nil, username = nil, password = nil)
+ @siteUrl = siteUrl
+ @username = username
+ @password = password
+ end
+end
+
+# {http://api.createsend.com/api/}User.GetApiKeyResponse
+# user_GetApiKeyResult - (any)
+class UserGetApiKeyResponse
+ attr_accessor :user_GetApiKeyResult
+
+ def initialize(user_GetApiKeyResult = nil)
+ @user_GetApiKeyResult = user_GetApiKeyResult
+ end
+end
+
# {http://api.createsend.com/api/}Subscriber.AddWithCustomFields
# apiKey - SOAP::SOAPString
# listID - SOAP::SOAPString
@@ -856,6 +964,29 @@ def initialize(list_CreateCustomFieldResult = nil)
end
end
+# {http://api.createsend.com/api/}List.GetStats
+# apiKey - SOAP::SOAPString
+# listID - SOAP::SOAPString
+class ListGetStats
+ attr_accessor :apiKey
+ attr_accessor :listID
+
+ def initialize(apiKey = nil, listID = nil)
+ @apiKey = apiKey
+ @listID = listID
+ end
+end
+
+# {http://api.createsend.com/api/}List.GetStatsResponse
+# list_GetStatsResult - (any)
+class ListGetStatsResponse
+ attr_accessor :list_GetStatsResult
+
+ def initialize(list_GetStatsResult = nil)
+ @list_GetStatsResult = list_GetStatsResult
+ end
+end
+
# {http://api.createsend.com/api/}Client.GetCampaigns
# apiKey - SOAP::SOAPString
# clientID - SOAP::SOAPString
@@ -8,6 +8,14 @@ class ApiSoap < ::SOAP::RPC::Driver
DefaultEndpointUrl = "http://api.createsend.com/api/api.asmx"
Methods = [
+ [ "http://api.createsend.com/api/User.GetApiKey",
+ "getApiKey",
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://api.createsend.com/api/", "User.GetApiKey"]],
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://api.createsend.com/api/", "User.GetApiKeyResponse"]] ],
+ { :request_style => :document, :request_use => :literal,
+ :response_style => :document, :response_use => :literal,
+ :faults => {} }
+ ],
[ "http://api.createsend.com/api/Subscriber.AddWithCustomFields",
"addSubscriberWithCustomFields",
[ ["in", "parameters", ["::SOAP::SOAPElement", "http://api.createsend.com/api/", "Subscriber.AddWithCustomFields"]],
@@ -144,6 +152,14 @@ class ApiSoap < ::SOAP::RPC::Driver
:response_style => :document, :response_use => :literal,
:faults => {} }
],
+ [ "http://api.createsend.com/api/List.GetStats",
+ "getListStats",
+ [ ["in", "parameters", ["::SOAP::SOAPElement", "http://api.createsend.com/api/", "List.GetStats"]],
+ ["out", "parameters", ["::SOAP::SOAPElement", "http://api.createsend.com/api/", "List.GetStatsResponse"]] ],
+ { :request_style => :document, :request_use => :literal,
+ :response_style => :document, :response_use => :literal,
+ :faults => {} }
+ ],
[ "http://api.createsend.com/api/Client.GetCampaigns",
"getClientCampaigns",
[ ["in", "parameters", ["::SOAP::SOAPElement", "http://api.createsend.com/api/", "Client.GetCampaigns"]],
Oops, something went wrong.

0 comments on commit 4dd0534

Please sign in to comment.