gnumarcelo-campaigning 0.5.0 → 0.6.0

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.
data/TODO.txt ADDED
@@ -0,0 +1,48 @@
1
+ *
2
+ Campaigns
3
+ o Campaign.Create - OK (Not tested)
4
+ o Campaign.GetBounces - OK
5
+ o Campaign.GetLists - OK
6
+ o Campaign.GetOpens - OK
7
+ o Campaign.GetSubscriberClicks - OK
8
+ o Campaign.GetSummary - OK
9
+ o Campaign.GetUnsubscribes - OK
10
+ o Campaign.Send - OK (Not Tested)
11
+ *
12
+ Clients
13
+ o Client.Create - OK
14
+ o Client.Delete - OK
15
+ o Client.GetCampaigns - OK
16
+ o Client.GetDetail - OK
17
+ o Client.GetLists - OK
18
+ o Client.GetSegments - OK
19
+ o Client.GetSuppressionList - OK (Not tested)
20
+ o Client.UpdateAccessAndBilling - OK
21
+ o Client.UpdateBasics - OK
22
+ *
23
+ Subscribers
24
+ o Subscriber.Add - OK
25
+ o Subscriber.AddAndResubscribe - OK
26
+ o Subscriber.AddAndResubscribeWithCustomFields - OK
27
+ o Subscriber.AddWithCustomFields - OK
28
+ o Subscriber.Unsubscribe - OK
29
+ o Subscribers.GetActive - OK - Here?
30
+ o Subscribers.GetBounced - OK
31
+ o Subscribers.GetIsSubscribed - OK
32
+ o Subscribers.GetSingleSubscriber - OK
33
+ o Subscribers.GetUnsubscribed - OK - Here?
34
+ *
35
+ Lists
36
+ o List.Create - OK
37
+ o List.CreateCustomField - OK
38
+ o List.Delete - OK
39
+ o List.DeleteCustomField - OK
40
+ o List.GetCustomFields - OK
41
+ o List.GetDetail - OK
42
+ o List.Update - OK
43
+ *
44
+ Users
45
+ o User.GetClients - OK
46
+ o User.GetCountries - OK
47
+ o User.GetSystemDate - OK
48
+ o User.GetTimezones - OK
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 5
3
+ :minor: 6
4
4
  :patch: 0
@@ -2,50 +2,40 @@ gem "soap4r", "~> 1.5.0"
2
2
  require File.expand_path(File.dirname(__FILE__)) + '/soap/defaultDriver.rb'
3
3
  require File.expand_path(File.dirname(__FILE__)) + '/types/client.rb'
4
4
  require File.expand_path(File.dirname(__FILE__)) + '/types/campaign.rb'
5
+ require File.expand_path(File.dirname(__FILE__)) + '/types/subscriber.rb'
6
+ require File.expand_path(File.dirname(__FILE__)) + '/types/list.rb'
7
+ require File.expand_path(File.dirname(__FILE__)) + '/helpers/helpers.rb'
5
8
 
6
9
  class Connection
10
+ include Helpers
7
11
  DefaultEndpointUrl = "http://api.createsend.com/api/api.asmx"
8
12
  attr_reader :api_key
9
13
  attr_reader :soap
10
14
 
11
-
12
15
  def initialize(api_key=CAMPAIGN_MONITOR_API_KEY)
13
16
  @api_key = api_key
14
17
  @soap = Campaigning::ApiSoap.new(DefaultEndpointUrl)
18
+ setup_debug_mode true
15
19
  end
16
20
 
17
-
18
21
  def clients
19
22
  response = soap.getClients(:apiKey => @api_key)
20
- Connection.handle_request response.user_GetClientsResult
23
+ handle_request response.user_GetClientsResult
21
24
  end
22
25
 
23
-
24
26
  def system_date
25
- Connection.handle_request soap.getSystemDate(:apiKey => @api_key).user_GetSystemDateResult
27
+ handle_request soap.getSystemDate(:apiKey => @api_key).user_GetSystemDateResult
26
28
  end
27
29
 
28
30
  def time_zones
29
- Connection.handle_request soap.getTimezones(:apiKey => @api_key).user_GetTimezonesResult
31
+ handle_request soap.getTimezones(:apiKey => @api_key).user_GetTimezonesResult
30
32
  end
31
33
 
32
- # TODO: Define this method in a another file like a helper???
33
- def Connection.handle_request(response)
34
- if (response.class == Campaigning::Result && response.code != 0)
35
- raise response.code.to_s + " - " + response.message
36
- end
37
- response
38
- end
39
-
40
-
41
34
  def setup_debug_mode(dev)
42
- if dev == true
43
- dev = STDERR
44
- end
35
+ dev = STDERR if dev == true
45
36
  soap.wiredump_dev = dev
46
37
  end
47
38
 
48
-
49
39
  def endpoint_url(url)
50
40
  soap.endpoint_url = url
51
41
  end
@@ -0,0 +1,14 @@
1
+ module Helpers
2
+
3
+ def handle_request(response)
4
+ Helpers.handle_request response
5
+ end
6
+
7
+ def Helpers.handle_request(response)
8
+ if (response.class == Campaigning::Result && response.code != 0)
9
+ raise response.code.to_s + " - " + response.message
10
+ end
11
+ response
12
+ end
13
+
14
+ end
@@ -1,8 +1,12 @@
1
1
  # Campaign is defined in soap/default.rb which is automatically generated.
2
2
  # In this file we add additional methods to the Campaign class.
3
+ require File.expand_path(File.dirname(__FILE__)) + '/../helpers/helpers'
4
+
5
+
3
6
  module Campaigning
4
7
 
5
8
  class Campaign
9
+ include Helpers
6
10
  attr_accessor :campaignID
7
11
  attr_accessor :subject
8
12
  attr_accessor :sentDate
@@ -16,8 +20,8 @@ module Campaigning
16
20
  @cm = Connection.new
17
21
  end
18
22
 
19
- def create(params)
20
- response = @cm.soap.createCampaign(
23
+ def self.create(params)
24
+ response = Connection.new.soap.createCampaign(
21
25
  :apiKey => CAMPAIGN_MONITOR_API_KEY,
22
26
  :clientID => params[:clientID],
23
27
  :campaignName => params[:campaignName],
@@ -31,25 +35,48 @@ module Campaigning
31
35
  :listSegments => params[:listSegments]
32
36
  )
33
37
 
34
- response.campaign_CreateResult # TODO: Handle the request
35
- end
36
-
37
- def create_old(clientID, campaignName, campaignSubject, fromName, fromEmail, replyTo, htmlUrl, textUrl, subscriberListIDs, listSegments)
38
- response = @cm.soap.createCampaign(
39
- :apiKey => CAMPAIGN_MONITOR_API_KEY,
40
- :clientID => clientID,
41
- :campaignName => campaignName,
42
- :campaignSubject => campaignSubject,
43
- :fromName => fromName,
44
- :fromEmail => fromEmail,
45
- :replyTo => replyTo,
46
- :htmlUrl => htmlUrl,
47
- :textUrl => textUrl,
48
- :subscriberListIDs => subscriberListIDs,
49
- :listSegments => listSegments
50
- )
51
-
52
- response.campaign_CreateResult # TODO: Handle the request
38
+ campaign_id = Helpers.handle_request response.campaign_CreateResult
39
+ Campaign.new campaign_id
40
+ end
41
+
42
+ def bounces
43
+ response = @cm.soap.getCampaignBounces(:apiKey => CAMPAIGN_MONITOR_API_KEY, :campaignID => @campaignID )
44
+ handle_request response.campaign_GetBouncesResult
45
+ end
46
+
47
+ def lists
48
+ response = @cm.soap.getCampaignLists(:apiKey => CAMPAIGN_MONITOR_API_KEY, :campaignID => @campaignID )
49
+ handle_request response.campaign_GetListsResult
50
+ end
51
+
52
+ def opens
53
+ response = @cm.soap.getCampaignOpens(:apiKey => CAMPAIGN_MONITOR_API_KEY, :campaignID => @campaignID )
54
+ handle_request response.campaign_GetOpensResult
55
+ end
56
+
57
+ def subscriber_clicks
58
+ response = @cm.soap.getSubscriberClicks(:apiKey => CAMPAIGN_MONITOR_API_KEY, :campaignID => @campaignID )
59
+ handle_request response.campaign_GetSubscriberClicksResult
60
+ end
61
+
62
+ def summary
63
+ response = @cm.soap.getCampaignSummary(:apiKey => CAMPAIGN_MONITOR_API_KEY, :campaignID => @campaignID )
64
+ handle_request response.campaign_GetSummaryResult
65
+ end
66
+
67
+ def unsubscribes
68
+ response = @cm.soap.getCampaignUnsubscribes(:apiKey => CAMPAIGN_MONITOR_API_KEY, :campaignID => @campaignID )
69
+ handle_request response.campaign_GetUnsubscribesResult
70
+ end
71
+
72
+ def send(params)
73
+ response = @cm.soap.sendCampaign(
74
+ :apiKey => CAMPAIGN_MONITOR_API_KEY,
75
+ :campaignID => @campaignID,
76
+ :confirmationEmail => params[:confirmation_email],
77
+ :sendDate => params[:send_date]
78
+ )
79
+ handle_request response.campaign_SendResult
53
80
  end
54
81
 
55
82
  end
@@ -1,8 +1,11 @@
1
1
  # Client is defined in default.rb which is automatically generated.
2
2
  # In this file we add additional methods to the Client class.
3
+ require File.expand_path(File.dirname(__FILE__)) + '/../helpers/helpers'
4
+
3
5
  module Campaigning
4
6
 
5
- class Client
7
+ class Client
8
+ include Helpers
6
9
  attr_accessor :clientID
7
10
  attr_accessor :name
8
11
 
@@ -13,59 +16,120 @@ class Client
13
16
  end
14
17
 
15
18
 
16
- def create
17
- hash = {
18
- :companyName => @company_name,
19
- :contactName => @contact_name,
20
- :emailAddress => @email_address,
21
- :country => @country,
22
- :timezone => @time_zone
23
- }
24
-
25
- # generate a hash
26
- # send @cm.createClient request to campaign monitor
27
- #@clientID = response.client_CreateResult
28
- end
19
+ # def create
20
+ # hash = {
21
+ # :companyName => @company_name,
22
+ # :contactName => @name,
23
+ # :emailAddress => @email_address,
24
+ # :country => @country,
25
+ # :timezone => @time_zone
26
+ # }
27
+ #
28
+ # generate a hash
29
+ # send @cm.createClient request to campaign monitor
30
+ # @clientID = response.client_CreateResult
31
+ # end
29
32
 
30
-
31
33
  def lists
32
34
  response = @cm.soap.getClientLists(:apiKey => CAMPAIGN_MONITOR_API_KEY, :clientID => @clientID)
33
- Connection.handle_request response.client_GetListsResult # TODO: handle the request
35
+ lists = handle_request response.client_GetListsResult
36
+ lists.collect {|list| List.new(list.listID, list.name)}
34
37
  end
35
38
 
39
+ def find_list_by_name(list_name)
40
+ lists.find {|list| list_name == list.name}
41
+ end
36
42
 
37
43
  # TODO: Refactor this method and increase performance?
38
44
  # TODO: Tha campaign monitor permit two users with the same name, what to do?
39
45
  def self.find_by_name(name)
40
- response = Connection.new.soap.getClients(:apiKey => CAMPAIGN_MONITOR_API_KEY)
41
- client_list = Connection.handle_request response.user_GetClientsResult
42
- client_found = client_list.collect.detect { |client| client.name == name }
46
+ client_list = Helpers.handle_request Connection.new.clients
47
+ client_found = client_list.find {|client| name == client.name}
43
48
  Client.new(client_found.clientID, client_found.name) if client_found
44
49
  end
45
50
 
46
-
47
51
  def self.create(params)
48
- response = Connection.new.soap.createClient(:apiKey => CAMPAIGN_MONITOR_API_KEY,
52
+ response = Connection.new.soap.createClient(
53
+ :apiKey => CAMPAIGN_MONITOR_API_KEY,
49
54
  :companyName => params[:company_name],
50
55
  :contactName => params[:contact_name],
51
56
  :emailAddress => params[:email_address],
52
57
  :country => params[:country],
53
58
  :timezone => params[:time_zone]
54
59
  )
55
- new_client_id = Connection.handle_request response.client_CreateResult # TODO: handle the request
56
- Client.new(new_client_id)
60
+ Client.new(Helpers.handle_request response.client_CreateResult)
57
61
  end
58
62
 
59
-
60
- def self.delete(param)
61
- response = Connection.new.soap.deleteClient(:apiKey => CAMPAIGN_MONITOR_API_KEY, :clientID => param[:client_id])
62
- Connection.handle_request response.client_DeleteResult
63
+ def delete
64
+ Client.delete(@clientID)
65
+ self.clientID = nil
66
+ self.name = nil
63
67
  end
64
68
 
69
+ def self.delete(client_id)
70
+ response = Connection.new.soap.deleteClient(:apiKey => CAMPAIGN_MONITOR_API_KEY, :clientID => client_id)
71
+ Helpers.handle_request response.client_DeleteResult
72
+ end
65
73
 
66
74
  def segments
67
75
  response = @cm.soap.getClientSegments(:apiKey => CAMPAIGN_MONITOR_API_KEY, :clientID => @clientID )
68
- Connection.handle_request response.client_GetSegmentsResult
76
+ handle_request response.client_GetSegmentsResult
77
+ end
78
+
79
+ # TODO: Refactor this method
80
+ def find_campaigns_by_subject(subject, params=nil)
81
+ arr = []
82
+ return campaigns.find {|campaign| subject == campaign.subject} if params[:unique]
83
+
84
+ campaigns.each { |campaign| arr << campaign if campaign.subject == subject }
85
+ arr
86
+ end
87
+
88
+ def campaigns
89
+ response = @cm.soap.getClientCampaigns(:apiKey => CAMPAIGN_MONITOR_API_KEY, :clientID => @clientID )
90
+ campaign_list = handle_request response.client_GetCampaignsResult
91
+ campaign_list.collect do |campaign|
92
+ Campaign.new(campaign.campaignID, campaign.subject, campaign.sentDate, campaign.totalRecipients)
93
+ end
94
+ end
95
+
96
+ def details
97
+ response = @cm.soap.getClientDetail(:apiKey => CAMPAIGN_MONITOR_API_KEY, :clientID => @clientID )
98
+ handle_request response.client_GetDetailResult
99
+ end
100
+
101
+ def suppression_list
102
+ response = @cm.soap.getClientSuppressionList(:apiKey => CAMPAIGN_MONITOR_API_KEY, :clientID => @clientID )
103
+ handle_request response.client_GetSuppressionListResult
104
+ end
105
+
106
+ def update_access_and_billing(params)
107
+ response = @cm.soap.updateClientAccessAndBilling(
108
+ :apiKey => CAMPAIGN_MONITOR_API_KEY,
109
+ :clientID => @clientID,
110
+ :accessLevel => params[:access_level],
111
+ :username => params[:username],
112
+ :password => params[:password],
113
+ :billingType => params[:billing_type],
114
+ :currency => params[:currency],
115
+ :deliveryFee => params[:delivery_fee],
116
+ :costPerRecipient => params[:cost_per_recipient],
117
+ :designAndSpamTestFee => params[:design_and_spam_test_fee]
118
+ )
119
+ handle_request response.client_UpdateAccessAndBillingResult
120
+ end
121
+
122
+ def update_basics(params)
123
+ response = @cm.soap.updateClientBasics(
124
+ :apiKey => CAMPAIGN_MONITOR_API_KEY,
125
+ :clientID => @clientID,
126
+ :companyName => params[:company_name],
127
+ :contactName => params[:contact_name],
128
+ :emailAddress => params[:email_address],
129
+ :country => params[:country],
130
+ :timezone => params[:time_zone]
131
+ )
132
+ handle_request response.client_UpdateBasicsResult
69
133
  end
70
134
 
71
135
 
@@ -0,0 +1,91 @@
1
+ # Campaign is defined in soap/default.rb which is automatically generated.
2
+ # In this file we add additional methods to the Campaign class.
3
+ require File.expand_path(File.dirname(__FILE__)) + '/../helpers/helpers'
4
+
5
+
6
+ module Campaigning
7
+
8
+ class List
9
+ include Helpers
10
+ attr_accessor :listID
11
+ attr_accessor :name
12
+
13
+ def initialize(listID = nil, name = nil)
14
+ @listID = listID
15
+ @name = name
16
+ @cm = Connection.new
17
+ end
18
+
19
+ def self.create(params)
20
+ params = {:unsubscribe_page => "", :confirmation_success_page => ""}.merge! params
21
+ response = Connection.new.soap.createList(
22
+ :apiKey => CAMPAIGN_MONITOR_API_KEY,
23
+ :clientID => params[:client_id],
24
+ :title => params[:title],
25
+ :unsubscribePage => params[:unsubscribe_page],
26
+ :confirmOptIn => params[:comfirm_opt_in],
27
+ :confirmationSuccessPage => params[:confirmation_success_page]
28
+ )
29
+ new_list_id = Helpers.handle_request response.list_CreateResult
30
+ List.new(new_list_id, params[:title])
31
+ end
32
+
33
+ def create_custom_field(params)
34
+ params = {:options => ""}.merge! params
35
+ response = @cm.soap.createListCustomField(
36
+ :apiKey => CAMPAIGN_MONITOR_API_KEY,
37
+ :listID => @listID,
38
+ :fieldName => params[:field_name],
39
+ :dataType => params[:data_type],
40
+ :options => params[:options]
41
+ )
42
+ handle_request response.list_CreateCustomFieldResult
43
+ end
44
+
45
+ def delete
46
+ List.delete(@listID)
47
+ self.listID, self.name = nil, nil
48
+ end
49
+
50
+ def self.delete(list_id)
51
+ response = Connection.new.soap.deleteList(:apiKey => CAMPAIGN_MONITOR_API_KEY, :listID => list_id)
52
+ Helpers.handle_request response.list_DeleteResult
53
+ end
54
+
55
+ def delete_custom_field(key)
56
+ response = @cm.soap.deleteListCustomField(:apiKey => CAMPAIGN_MONITOR_API_KEY, :listID => @listID, :key => '['+key+']')
57
+ handle_request response.list_DeleteCustomFieldResult
58
+ end
59
+
60
+ def custom_fields
61
+ response = @cm.soap.getListCustomFields(:apiKey => CAMPAIGN_MONITOR_API_KEY, :listID => @listID)
62
+ handle_request response.list_GetCustomFieldsResult
63
+ end
64
+
65
+ def details
66
+ response = @cm.soap.getListDetail(:apiKey => CAMPAIGN_MONITOR_API_KEY, :listID => @listID)
67
+ handle_request response.list_GetDetailResult
68
+ end
69
+
70
+
71
+ def update(params)
72
+ params = {:unsubscribe_page => "", :confirmation_success_page => ""}.merge! params
73
+ response = @cm.soap.updateList(
74
+ :apiKey => CAMPAIGN_MONITOR_API_KEY,
75
+ :listID => @listID,
76
+ :title => params[:title],
77
+ :unsubscribePage => params[:unsubscribe_page],
78
+ :confirmOptIn => params[:comfirm_opt_in],
79
+ :confirmationSuccessPage => params[:confirmation_success_page]
80
+ )
81
+ handle_request response.list_UpdateResult
82
+ end
83
+
84
+ protected
85
+
86
+ def custom_field_options(custom_fields)
87
+ custom_fields.join("||").to_s
88
+ end
89
+
90
+ end
91
+ end
@@ -0,0 +1,129 @@
1
+ # Subscriber is defined in default.rb which is automatically generated.
2
+ # In this file we add additional methods to the Subscriber class.
3
+ require File.expand_path(File.dirname(__FILE__)) + '/../helpers/helpers'
4
+
5
+ module Campaigning
6
+
7
+ class Subscriber
8
+ include Helpers
9
+ attr_accessor :emailAddress
10
+ attr_accessor :name
11
+ attr_accessor :date
12
+ attr_accessor :state
13
+ attr_accessor :customFields
14
+
15
+ def initialize(emailAddress = nil, name = nil, date = nil, state = nil, customFields = nil)
16
+ @emailAddress = emailAddress
17
+ @name = name
18
+ @date = date
19
+ @state = state
20
+ @customFields = customFields
21
+ @cm = Connection.new
22
+ end
23
+
24
+ def add(list_id)
25
+ response = @cm.soap.addSubscriber(
26
+ :apiKey => CAMPAIGN_MONITOR_API_KEY,
27
+ :listID => list_id,
28
+ :email => @emailAddress,
29
+ :name => @name
30
+ )
31
+ handle_request response.subscriber_AddResult
32
+ end
33
+
34
+ def add_and_resubscribe(list_id)
35
+ response = @cm.soap.addAndResubscribe(
36
+ :apiKey => CAMPAIGN_MONITOR_API_KEY,
37
+ :listID => list_id,
38
+ :email => @emailAddress,
39
+ :name => @name
40
+ )
41
+ handle_request response.subscriber_AddAndResubscribeResult
42
+ end
43
+
44
+ def add_and_resubscribe_with_custom_fields(list_id, custom_fields)
45
+ response = @cm.soap.addAndResubscribeWithCustomFields(
46
+ :apiKey => CAMPAIGN_MONITOR_API_KEY,
47
+ :listID => list_id,
48
+ :email => @emailAddress,
49
+ :name => @name,
50
+ :customFields => custom_fields_array(custom_fields)
51
+ )
52
+ Helpers.handle_request response.subscriber_AddAndResubscribeWithCustomFieldsResult
53
+ end
54
+
55
+ def add_with_custom_fields(list_id, custom_fields)
56
+ response = @cm.soap.addSubscriberWithCustomFields(
57
+ :apiKey => CAMPAIGN_MONITOR_API_KEY,
58
+ :listID => list_id,
59
+ :email => @emailAddress,
60
+ :name => @name,
61
+ :customFields => custom_fields_array(custom_fields)
62
+ )
63
+ handle_request response.subscriber_AddWithCustomFieldsResult
64
+ end
65
+
66
+ def unsubscribe(list_id)
67
+ response = @cm.soap.unsubscribe(
68
+ :apiKey => CAMPAIGN_MONITOR_API_KEY,
69
+ :listID => list_id,
70
+ :email => @emailAddress
71
+ )
72
+ handle_request response.subscriber_UnsubscribeResult
73
+ end
74
+
75
+ # TODO: May I move this method to List type?
76
+ def self.active_subscribers(list_id, datetime)
77
+ response = Connection.new.soap.getSubscribers(
78
+ :apiKey => CAMPAIGN_MONITOR_API_KEY,
79
+ :listID => list_id,
80
+ :date => datetime.strftime('%Y-%m-%d %H:%M:%S') # TODO: Move that to a helper method
81
+ )
82
+ Helpers.handle_request response.subscribers_GetActiveResult
83
+ end
84
+
85
+ # TODO: May I move this method to List type?
86
+ def self.get_unsubscribed(list_id, datetime)
87
+ response = Connection.new.soap.getUnsubscribed(
88
+ :apiKey => CAMPAIGN_MONITOR_API_KEY,
89
+ :listID => list_id,
90
+ :date => datetime.strftime('%Y-%m-%d %H:%M:%S') # TODO: Move that to a helper method
91
+ )
92
+ Helpers.handle_request response.subscribers_GetUnsubscribedResult
93
+ end
94
+
95
+ def is_subscribed?(list_id)
96
+ response = @cm.soap.getIsSubscribed(
97
+ :apiKey => CAMPAIGN_MONITOR_API_KEY,
98
+ :listID => list_id,
99
+ :email => @emailAddress
100
+ )
101
+ response = handle_request response.subscribers_GetIsSubscribedResult
102
+ response == 'True' ? true : false
103
+ end
104
+
105
+ # TODO: Create a mehod to handle with custom fields returned like (names from "State Name" to "state_name")
106
+ def self.get_single_subscriber(list_id, email_address)
107
+ response = Connection.new.soap.getSingleSubscriber(
108
+ :apiKey => CAMPAIGN_MONITOR_API_KEY,
109
+ :listID => list_id,
110
+ :emailAddress => email_address
111
+ )
112
+ Helpers.handle_request response.subscribers_GetSingleSubscriberResult
113
+ end
114
+
115
+
116
+ protected
117
+
118
+ def custom_fields_array(custom_fields)
119
+ arr = []
120
+ custom_fields.each do |key, value|
121
+ arr << { :key => key, :value => value }
122
+ end
123
+ arr
124
+ end
125
+
126
+
127
+ end
128
+
129
+ end
@@ -10,82 +10,321 @@ class CampaigningTest < Test::Unit::TestCase
10
10
  def setup
11
11
  @cm = Connection.new
12
12
  end
13
-
14
-
15
- def test_clients
16
- clients = @cm.clients
17
- assert clients.length > 0
18
- clients.each{ |c| puts c.clientID + " - " + c.name }
19
- end
20
-
21
-
22
- def test_client_lists
23
- client = Campaigning::Client.new(CLIENT_ID)
24
- assert client.lists.length > 0
25
- end
26
-
27
-
28
- def test_client_create
29
- client_created = Campaigning::Client.create(
30
- :company_name => "Orange Company 11",
31
- :contact_name => "Oswald Green11",
32
- :email_address => "og13@user.com",
33
- :country => "Ireland",
34
- :time_zone => @cm.time_zones[1]
35
- )
36
- end
37
-
38
-
39
- def test_client_delete
40
- response = Campaigning::Client.delete(:client_id => "50a1893ea0a02fc94f2ee9563766e539")
41
- puts response.inspect
42
- end
43
-
44
-
45
- def test_client_segments
46
- client = Campaigning::Client.new(CLIENT_TWO_ID)
47
- assert client.segments.length > 0
48
- puts client.segments.inspect
49
- end
50
13
 
51
-
52
- def test_find_client_by_name
53
- client = Campaigning::Client.find_by_name("Client One Company")
54
- assert client != nil && client.name == "Client One Company"
55
- end
56
-
57
-
58
- def test_user_get_time_zones
59
- time_zones = @cm.time_zones
60
- assert !time_zones.nil?
61
- end
62
-
63
-
64
- def test_system_date
65
- sys_date = @cm.system_date
66
- assert !sys_date.nil?
67
- puts sys_date
68
- end
69
14
 
15
+ # def test_clients
16
+ # clients = @cm.clients
17
+ # assert clients.length > 0
18
+ # clients.each{ |c| puts c.clientID + " - " + c.name }
19
+ # end
20
+ #
21
+ #
22
+ # def test_client_lists
23
+ # client = Campaigning::Client.new(CLIENT_ID)
24
+ # assert client.lists.length > 0
25
+ # end
26
+ #
27
+ #
28
+ # def test_client_create
29
+ # client_created = Campaigning::Client.create(
30
+ # :company_name => "Orange Company 14",
31
+ # :contact_name => "Oswald Green11",
32
+ # :email_address => "og1@user.com",
33
+ # :country => "Ireland",
34
+ # :time_zone => @cm.time_zones[1]
35
+ # )
36
+ # assert client_created.clientID != nil
37
+ # end
38
+ #
39
+ #
40
+ # def test_client_delete
41
+ # response = Campaigning::Client.delete("50a1893ea0a02fc94f2ee9563766e539")
42
+ # puts response.inspect
43
+ # end
44
+ #
45
+ # def test_client_delete_itself
46
+ # client = Campaigning::Client.find_by_name("Orange Company 7")
47
+ # client.delete
48
+ # end
49
+ #
50
+ # def test_client_segments
51
+ # client = Campaigning::Client.find_by_name("Client One Company")
52
+ # assert client.segments.length > 0
53
+ # puts client.segments.inspect
54
+ # end
55
+ #
56
+ #
57
+ # def test_find_client_by_name
58
+ # client = Campaigning::Client.find_by_name("Client One Company")
59
+ # assert client != nil && client.name == "Client One Company"
60
+ # end
61
+ #
62
+ #
63
+ # def test_get_client_campaigns
64
+ # client = Campaigning::Client.find_by_name("Client One Company")
65
+ # puts client.campaigns.inspect
66
+ # end
67
+ #
68
+ # def test_get_client_details
69
+ # client = Campaigning::Client.find_by_name("Client Two ")
70
+ # puts client.details.inspect
71
+ # end
72
+ #
73
+ # def test_get_client_suppression_list
74
+ # client = Campaigning::Client.find_by_name("Client Two ")
75
+ # puts client.suppression_list
76
+ # end
77
+ #
78
+ # def test_client_update_access_and_billing
79
+ # client = Campaigning::Client.find_by_name("Client One Company")
80
+ # response = client.update_access_and_billing(
81
+ # :access_level => 5 ,
82
+ # :username => "client_one",
83
+ # :password => "1234560",
84
+ # :billing_type => "UserPaysOnClientsBehalf",
85
+ # :currency => "USD",
86
+ # :delivery_fee => 6.5,
87
+ # :cost_per_recipient => 1.5 ,
88
+ # :design_and_spam_test_fee => 5
89
+ # )
90
+ # assert response.code == 0
91
+ # end
92
+ #
93
+ # def test_client_update_basics
94
+ # client = Campaigning::Client.find_by_name("Client Two ")
95
+ # response = client.update_basics(
96
+ # :company_name => "My new Company",
97
+ # :contact_name => "Mr. Gordon Newman",
98
+ # :email_address => "gordon-newman@test.com",
99
+ # :country => "Ireland",
100
+ # :time_zone => @cm.time_zones[1]
101
+ # )
102
+ # assert response.code == 0
103
+ # end
104
+ #
105
+ # def test_client_find_list_by_name
106
+ # client = Campaigning::Client.find_by_name("Client One Company")
107
+ # list = client.find_list_by_name "My Friends"
108
+ # puts list.inspect
109
+ # assert list.nil? == false
110
+ # end
70
111
 
112
+
71
113
  #
114
+ # def test_user_get_time_zones
115
+ # time_zones = @cm.time_zones
116
+ # assert !time_zones.nil?
117
+ # end
118
+ #
119
+ #
120
+ # def test_system_date
121
+ # sys_date = @cm.system_date
122
+ # assert !sys_date.nil?
123
+ # puts sys_date
124
+ # end
125
+
126
+
72
127
  # def test_campaign_create
73
- # camp = Campaigning::Campaign.new
74
- # response = camp.create(
75
- # :clientID => "730acd1e8d27d56bdb87e88685613d72",
76
- # :campaignName => "NEEEEW CELOMAR",
77
- # :campaignSubject => "My new Campaign Subj",
78
- # :fromName => "Mr. Gordon",
79
- # :fromEmail => "gordon@user.com",
80
- # :replyTo => "no-reply@user.com",
81
- # :htmlUrl => "http://www.uol.com.br",
82
- # :textUrl => "http://www.uol.com.br",
83
- # :subscriberListIDs => ["df11fb1f67bb0ca23fd3e88575464144"],
84
- # :listSegments => []
128
+ # client = Campaigning::Client.find_by_name("Client One Company")
129
+ # response = Campaigning::Campaign.create(
130
+ # :clientID => client.clientID,
131
+ # :campaignName => "Campaign by myself RUBY TO DELETE - CODEEEEE",
132
+ # :campaignSubject => "Campaign by myself - OK - CODEEEEE",
133
+ # :fromName => "Mr. Gordon2",
134
+ # :fromEmail => "gordon2@test.com",
135
+ # :replyTo => "no-reply@test.com",
136
+ # :htmlUrl => "http://www.campaignmonitor.com/api/method/campaign-create/",
137
+ # :textUrl => "http://www.google.com.br",
138
+ # :subscriberListIDs => ["ac52b645c048888a44c87b5f1ecf6b7d"],
139
+ # :listSegments => client.segments
85
140
  # )
86
141
  # puts response.inspect
87
142
  # end
143
+ #
144
+ #
145
+ # def test_campaign_bounces
146
+ # client = Campaigning::Client.find_by_name("Client One Company")
147
+ # puts client.campaigns[1].bounces.inspect
148
+ # end
88
149
  #
150
+ # def test_campaign_lists
151
+ # client = Campaigning::Client.find_by_name("Client One Company")
152
+ # puts client.campaigns[2].lists.inspect
153
+ # end
154
+ #
155
+ # def test_campaign_opens
156
+ # client = Campaigning::Client.find_by_name("Client One Company")
157
+ # puts client.campaigns[0].opens
158
+ # end
159
+
160
+ # def test_campaign_find_campaigns_by_subject
161
+ # client = Campaigning::Client.find_by_name("Client One Company")
162
+ # campaigns = client.find_campaigns_by_subject("Campaign to BOUNCE")
163
+ # assert campaign.length > 0
164
+ # end
165
+
166
+ # def test_campaign_find_campaigns_by_subject_unique
167
+ # client = Campaigning::Client.find_by_name("Client One Company")
168
+ # campaign = client.find_campaigns_by_subject("Campaign to BOUNCE")
169
+ # puts campaign.inspect
170
+ # #assert campaign > 0
171
+ # end
172
+ #
173
+ # def test_campaign_subscriber_clicks
174
+ # client = Campaigning::Client.find_by_name("Client One Company")
175
+ # puts client.campaigns[0].subscriber_clicks
176
+ # end
177
+ #
178
+ #
179
+ # def test_campaign_summary
180
+ # client = Campaigning::Client.find_by_name("Client One Company")
181
+ # puts client.campaigns[1].summary
182
+ # end
183
+ #
184
+ # def test_campaign_unsubscribes
185
+ # client = Campaigning::Client.find_by_name("Client One Company")
186
+ # puts client.campaigns[0].unsubscribes
187
+ # end
188
+ #
189
+ # def test_campaign_send
190
+ # client = Campaigning::Client.find_by_name("Client One Company")
191
+ # response = Campaigning::Campaign.create(
192
+ # :clientID => client.clientID,
193
+ # :campaignName => "Campaign by myself RUBY NEW CREATED",
194
+ # :campaignSubject => "Campaign by myself - OK",
195
+ # :fromName => "Mr. Gordon2",
196
+ # :fromEmail => "gordon2@test.com",
197
+ # :replyTo => "no-reply@test.com",
198
+ # :htmlUrl => "http://www.campaignmonitor.com/api/method/campaign-create/",
199
+ # :textUrl => "http://www.google.com",
200
+ # :subscriberListIDs => ["ac52b645c048888a44c87b5f1ecf6b7d"],
201
+ # :listSegments => client.segments
202
+ # )
203
+ #
204
+ # puts client.campaigns[0].send(
205
+ # :confirmation_email => "userhdhd@test.com",
206
+ # :send_date => "2009-04-30 11:55:01" # Date format YYYY-MM-DD HH:MM:SS.
207
+ # )
208
+ # end
209
+ #
210
+ # def test_subscriber_add
211
+ # subscriber = Campaigning::Subscriber.new("robertf@test.com", "Robert Franklin")
212
+ # response = subscriber.add("ac52b645c048888a44c87b5f1ecf6b7d")
213
+ # assert response.code == 0
214
+ # end
215
+ #
216
+ # def test_subscriber_add_and_resubscribe
217
+ # subscriber = Campaigning::Subscriber.new("norag@test.com", "Nora Green")
218
+ # response = subscriber.add_and_resubscribe("ac52b645c048888a44c87b5f1ecf6b7d")
219
+ # assert response.code == 0
220
+ # end
221
+ #
222
+ #
223
+ # def test_subscriber_add_and_resubscribe_with_custom_fields
224
+ # subscriber = Campaigning::Subscriber.new("user_custon@test.com", "Mr. Custon")
225
+ # response = subscriber.add_and_resubscribe_with_custom_fields("ac52b645c048888a44c87b5f1ecf6b7d", :CityName => "Dublin", :SponsorName => "Some Sponsor")
226
+ # assert response.code == 0
227
+ # end
228
+ #
229
+ # def test_subscriber_add_with_custom_fields
230
+ # subscriber = Campaigning::Subscriber.new("user_custon2@test.com", "Mr. Custon")
231
+ # response = subscriber.add_with_custom_fields("ac52b645c048888a44c87b5f1ecf6b7d", :CityName => "London", :SponsorName => "Some Sponsor from London")
232
+ # assert response.code == 0
233
+ # end
234
+ #
235
+ # def test_subscriber_unsubscribe
236
+ # subscriber = Campaigning::Subscriber.new("user_to_test@test.com") # TODO: Change to get the Subscriber, not to CREATE a new one
237
+ # response = subscriber.unsubscribe("ac52b645c048888a44c87b5f1ecf6b7d")
238
+ # puts response.inspect
239
+ # assert response.code == 0
240
+ # end
241
+ #
242
+ # def test_subscriber_actives
243
+ # subscriber_list = Campaigning::Subscriber.active_subscribers("ac52b645c048888a44c87b5f1ecf6b7d", DateTime.new(y=2009,m=5,d=01, h=01,min=00,s=00))
244
+ # puts subscriber_list.inspect
245
+ # assert subscriber_list.length > 0
246
+ # end
247
+ #
248
+ # def test_subscriber_is_subscribed
249
+ # subscriber = Campaigning::Subscriber.new("user_to_test@test.com") # TODO: Change to get the Subscriber, not to CREATE a new one
250
+ # response = subscriber.is_subscribed?("ac52b645c048888a44c87b5f1ecf6b7d")
251
+ # puts response.inspect
252
+ # assert response == false
253
+ # end
254
+ #
255
+ def test_subscriber_get_single_subscriber
256
+ subscriber = Campaigning::Subscriber.get_single_subscriber("ac52b645c048888a44c87b5f1ecf6b7d", "user_custon2@test.com")
257
+ puts subscriber.inspect
258
+ assert subscriber.name != nil
259
+ end
260
+ #
261
+ # def test_subscriber_get_unsubscribed
262
+ # subscriber_list = Campaigning::Subscriber.get_unsubscribed("ac52b645c048888a44c87b5f1ecf6b7d", DateTime.new(y=2009,m=4,d=01, h=01,min=00,s=00))
263
+ # puts subscriber_list.inspect
264
+ # assert subscriber_list.length > 0
265
+ # end
266
+ #
267
+ #
268
+ # def test_list_create
269
+ # client = Campaigning::Client.find_by_name("Client One Company")
270
+ # list = Campaigning::List.create(
271
+ # :client_id => client.clientID,
272
+ # :title => "My new list creater by ruby list.create",
273
+ # :unsubscribe_page => "",
274
+ # :comfirm_opt_in => false,
275
+ # :confirmation_success_page => ""
276
+ # )
277
+ # assert list.listID != nil
278
+ # end
279
+ #
280
+ # def test_list_create_custom_field
281
+ # client = Campaigning::Client.find_by_name("Client One Company")
282
+ # list = client.find_list_by_name "My Friends"
283
+ # result = list.create_custom_field(
284
+ # :field_name => "Country" ,
285
+ # :data_type => "MultiSelectOne",
286
+ # :options => %w[Brazil Ireland England]
287
+ # )
288
+ # assert result.code == 0
289
+ # end
290
+ #
291
+ # def test_list_delete
292
+ # result = Campaigning::List.delete("916797045feddc92df10a4722f819771")
293
+ # puts result.inspect
294
+ # end
295
+ #
296
+ # def test_list_delete_custom_field
297
+ # client = Campaigning::Client.find_by_name("Client One Company")
298
+ # list = client.find_list_by_name "My Friends"
299
+ # result = list.delete_custom_field("Country")
300
+ # assert result.code == 0
301
+ # end
302
+ #
303
+ # def test_list_custom_fields
304
+ # client = Campaigning::Client.find_by_name("Client One Company")
305
+ # list = client.find_list_by_name "My Friends"
306
+ # result = list.custom_fields
307
+ # puts result.inspect
308
+ # end
309
+ #
310
+ # def test_list_details
311
+ # client = Campaigning::Client.find_by_name("Client One Company")
312
+ # list = client.find_list_by_name "My Friends"
313
+ # result = list.details
314
+ # puts result.inspect
315
+ # end
316
+ #
317
+ # def test_list_update
318
+ # client = Campaigning::Client.find_by_name("Client One Company")
319
+ # list = client.find_list_by_name "My Friends"
320
+ # result = list.update(
321
+ # :title => "NEW TITLE : My new list created by ruby list.create",
322
+ # :unsubscribe_page => "",
323
+ # :comfirm_opt_in => false,
324
+ # :confirmation_success_page => ""
325
+ # )
326
+ # assert result.code == 0
327
+ # end
89
328
 
90
329
 
91
330
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gnumarcelo-campaigning
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Menezes
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-24 00:00:00 -07:00
12
+ date: 2009-05-02 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -35,14 +35,18 @@ files:
35
35
  - LICENSE
36
36
  - README.rdoc
37
37
  - Rakefile
38
+ - TODO.txt
38
39
  - VERSION.yml
39
40
  - lib/campaigning.rb
40
41
  - lib/campaigning/campaigning.rb
42
+ - lib/campaigning/helpers/helpers.rb
41
43
  - lib/campaigning/soap/default.rb
42
44
  - lib/campaigning/soap/defaultDriver.rb
43
45
  - lib/campaigning/soap/defaultMappingRegistry.rb
44
46
  - lib/campaigning/types/campaign.rb
45
47
  - lib/campaigning/types/client.rb
48
+ - lib/campaigning/types/list.rb
49
+ - lib/campaigning/types/subscriber.rb
46
50
  - test/campaigning_test.rb
47
51
  - test/test_helper.rb
48
52
  has_rdoc: true