gnumarcelo-campaigning 0.2.0 → 0.5.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/VERSION.yml +2 -2
- data/lib/campaigning/campaigning.rb +22 -34
- data/lib/campaigning/soap/default.rb +29 -23
- data/lib/campaigning/soap/defaultDriver.rb +4 -0
- data/lib/campaigning/soap/defaultMappingRegistry.rb +192 -188
- data/lib/campaigning/types/campaign.rb +56 -0
- data/lib/campaigning/types/client.rb +64 -9
- data/test/campaigning_test.rb +66 -6
- metadata +4 -4
- data/lib/campaigning/apiClient.rb +0 -1927
@@ -0,0 +1,56 @@
|
|
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
|
+
module Campaigning
|
4
|
+
|
5
|
+
class Campaign
|
6
|
+
attr_accessor :campaignID
|
7
|
+
attr_accessor :subject
|
8
|
+
attr_accessor :sentDate
|
9
|
+
attr_accessor :totalRecipients
|
10
|
+
|
11
|
+
def initialize(campaignID = nil, subject = nil, sentDate = nil, totalRecipients = nil)
|
12
|
+
@campaignID = campaignID
|
13
|
+
@subject = subject
|
14
|
+
@sentDate = sentDate
|
15
|
+
@totalRecipients = totalRecipients
|
16
|
+
@cm = Connection.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def create(params)
|
20
|
+
response = @cm.soap.createCampaign(
|
21
|
+
:apiKey => CAMPAIGN_MONITOR_API_KEY,
|
22
|
+
:clientID => params[:clientID],
|
23
|
+
:campaignName => params[:campaignName],
|
24
|
+
:campaignSubject => params[:campaignSubject],
|
25
|
+
:fromName => params[:fromName],
|
26
|
+
:fromEmail => params[:fromEmail],
|
27
|
+
:replyTo => params[:replyTo],
|
28
|
+
:htmlUrl => params[:htmlUrl],
|
29
|
+
:textUrl => params[:textUrl],
|
30
|
+
:subscriberListIDs => params[:subscriberListIDs],
|
31
|
+
:listSegments => params[:listSegments]
|
32
|
+
)
|
33
|
+
|
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
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
@@ -1,19 +1,74 @@
|
|
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
|
-
|
3
|
+
module Campaigning
|
4
|
+
|
5
|
+
class Client
|
4
6
|
attr_accessor :clientID
|
5
|
-
attr_accessor :name
|
7
|
+
attr_accessor :name
|
6
8
|
|
7
9
|
def initialize(clientID = nil, name = nil)
|
8
|
-
@cm =
|
9
|
-
|
10
|
-
|
10
|
+
@cm = Connection.new
|
11
|
+
@clientID = clientID
|
12
|
+
@name = name
|
11
13
|
end
|
12
14
|
|
13
|
-
|
15
|
+
|
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
|
29
|
+
|
30
|
+
|
14
31
|
def lists
|
15
|
-
response = @cm.soap.getClientLists(:apiKey => CAMPAIGN_MONITOR_API_KEY, :clientID =>
|
16
|
-
response.client_GetListsResult
|
32
|
+
response = @cm.soap.getClientLists(:apiKey => CAMPAIGN_MONITOR_API_KEY, :clientID => @clientID)
|
33
|
+
Connection.handle_request response.client_GetListsResult # TODO: handle the request
|
17
34
|
end
|
18
35
|
|
19
|
-
|
36
|
+
|
37
|
+
# TODO: Refactor this method and increase performance?
|
38
|
+
# TODO: Tha campaign monitor permit two users with the same name, what to do?
|
39
|
+
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 }
|
43
|
+
Client.new(client_found.clientID, client_found.name) if client_found
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def self.create(params)
|
48
|
+
response = Connection.new.soap.createClient(:apiKey => CAMPAIGN_MONITOR_API_KEY,
|
49
|
+
:companyName => params[:company_name],
|
50
|
+
:contactName => params[:contact_name],
|
51
|
+
:emailAddress => params[:email_address],
|
52
|
+
:country => params[:country],
|
53
|
+
:timezone => params[:time_zone]
|
54
|
+
)
|
55
|
+
new_client_id = Connection.handle_request response.client_CreateResult # TODO: handle the request
|
56
|
+
Client.new(new_client_id)
|
57
|
+
end
|
58
|
+
|
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
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
def segments
|
67
|
+
response = @cm.soap.getClientSegments(:apiKey => CAMPAIGN_MONITOR_API_KEY, :clientID => @clientID )
|
68
|
+
Connection.handle_request response.client_GetSegmentsResult
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
data/test/campaigning_test.rb
CHANGED
@@ -3,29 +3,89 @@ require 'test_helper'
|
|
3
3
|
# Replace this API key with your own (http://www.campaignmonitor.com/api/)
|
4
4
|
CAMPAIGN_MONITOR_API_KEY = '54cae7f3aa1f35cb3bb5bc41756d8b7f'
|
5
5
|
CLIENT_ID = 'd7acfd4cd2ffffc2d86b8903d18a1276'
|
6
|
+
CLIENT_TWO_ID = '730acd1e8d27d56bdb87e88685613d72'
|
6
7
|
|
7
8
|
class CampaigningTest < Test::Unit::TestCase
|
8
9
|
|
9
10
|
def setup
|
10
|
-
@cm =
|
11
|
+
@cm = Connection.new
|
11
12
|
end
|
12
|
-
|
13
|
+
|
14
|
+
|
13
15
|
def test_clients
|
14
16
|
clients = @cm.clients
|
15
|
-
puts clients[0].methods
|
16
17
|
assert clients.length > 0
|
17
18
|
clients.each{ |c| puts c.clientID + " - " + c.name }
|
18
19
|
end
|
19
|
-
|
20
|
+
|
21
|
+
|
20
22
|
def test_client_lists
|
21
|
-
client = Client.new(CLIENT_ID)
|
23
|
+
client = Campaigning::Client.new(CLIENT_ID)
|
22
24
|
assert client.lists.length > 0
|
23
25
|
end
|
24
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
|
+
|
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
|
+
|
25
64
|
def test_system_date
|
26
65
|
sys_date = @cm.system_date
|
27
66
|
assert !sys_date.nil?
|
28
67
|
puts sys_date
|
29
|
-
end
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
#
|
72
|
+
# 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 => []
|
85
|
+
# )
|
86
|
+
# puts response.inspect
|
87
|
+
# end
|
88
|
+
#
|
89
|
+
|
30
90
|
|
31
91
|
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.
|
4
|
+
version: 0.5.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-
|
12
|
+
date: 2009-04-24 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -37,11 +37,11 @@ files:
|
|
37
37
|
- Rakefile
|
38
38
|
- VERSION.yml
|
39
39
|
- lib/campaigning.rb
|
40
|
-
- lib/campaigning/apiClient.rb
|
41
40
|
- lib/campaigning/campaigning.rb
|
42
41
|
- lib/campaigning/soap/default.rb
|
43
42
|
- lib/campaigning/soap/defaultDriver.rb
|
44
43
|
- lib/campaigning/soap/defaultMappingRegistry.rb
|
44
|
+
- lib/campaigning/types/campaign.rb
|
45
45
|
- lib/campaigning/types/client.rb
|
46
46
|
- test/campaigning_test.rb
|
47
47
|
- test/test_helper.rb
|
@@ -69,7 +69,7 @@ requirements: []
|
|
69
69
|
rubyforge_project:
|
70
70
|
rubygems_version: 1.2.0
|
71
71
|
signing_key:
|
72
|
-
specification_version:
|
72
|
+
specification_version: 3
|
73
73
|
summary: TODO
|
74
74
|
test_files:
|
75
75
|
- test/campaigning_test.rb
|