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
data/VERSION.yml
CHANGED
@@ -1,65 +1,53 @@
|
|
1
1
|
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
|
+
require File.expand_path(File.dirname(__FILE__)) + '/types/campaign.rb'
|
4
5
|
|
5
|
-
class
|
6
|
+
class Connection
|
6
7
|
DefaultEndpointUrl = "http://api.createsend.com/api/api.asmx"
|
7
|
-
attr_reader :api_key
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# TODO: Consider change this to use something like "mattr_accessor" getter/setter methods at the class or module level.
|
12
|
-
@@soap = ::ApiSoap.new(DefaultEndpointUrl)
|
13
|
-
def soap
|
14
|
-
@@soap
|
15
|
-
end
|
16
|
-
|
17
|
-
# Replace this API key with your own (http://www.campaignmonitor.com/api/)
|
8
|
+
attr_reader :api_key
|
9
|
+
attr_reader :soap
|
10
|
+
|
11
|
+
|
18
12
|
def initialize(api_key=CAMPAIGN_MONITOR_API_KEY)
|
19
13
|
@api_key = api_key
|
20
|
-
|
14
|
+
@soap = Campaigning::ApiSoap.new(DefaultEndpointUrl)
|
15
|
+
end
|
21
16
|
|
22
17
|
|
23
|
-
# Return a list of Clients
|
24
|
-
#
|
25
|
-
# Given an apiKey this method return a list of Clients for that user(apiKey).
|
26
|
-
#
|
27
|
-
# sample:
|
28
|
-
#
|
29
|
-
# cm = Campaigning.new(:apiKey => "54cae7f3aa1f35cb3bb5bc41756d8b7f")
|
30
|
-
# clients = cm.clients
|
31
|
-
# clients.each{ |c| puts c.clientID + " - " + c.name }
|
32
18
|
def clients
|
33
|
-
response =
|
34
|
-
handle_request response.user_GetClientsResult
|
19
|
+
response = soap.getClients(:apiKey => @api_key)
|
20
|
+
Connection.handle_request response.user_GetClientsResult
|
35
21
|
end
|
36
22
|
|
37
23
|
|
38
24
|
def system_date
|
39
|
-
handle_request
|
25
|
+
Connection.handle_request soap.getSystemDate(:apiKey => @api_key).user_GetSystemDateResult
|
40
26
|
end
|
41
27
|
|
42
|
-
|
43
|
-
|
44
|
-
|
28
|
+
def time_zones
|
29
|
+
Connection.handle_request soap.getTimezones(:apiKey => @api_key).user_GetTimezonesResult
|
30
|
+
end
|
31
|
+
|
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)
|
45
35
|
raise response.code.to_s + " - " + response.message
|
46
36
|
end
|
47
37
|
response
|
48
38
|
end
|
39
|
+
|
49
40
|
|
50
|
-
|
51
|
-
##
|
52
|
-
# Sets the wiredump device the drivers.
|
53
41
|
def setup_debug_mode(dev)
|
54
42
|
if dev == true
|
55
43
|
dev = STDERR
|
56
44
|
end
|
57
|
-
|
45
|
+
soap.wiredump_dev = dev
|
58
46
|
end
|
59
47
|
|
60
48
|
|
61
49
|
def endpoint_url(url)
|
62
|
-
|
50
|
+
soap.endpoint_url = url
|
63
51
|
end
|
64
52
|
|
65
|
-
end
|
53
|
+
end
|
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'xsd/qname'
|
2
2
|
|
3
|
+
module Campaigning
|
4
|
+
|
5
|
+
|
3
6
|
# {http://api.createsend.com/api/}ArrayOfSubscriberCustomField
|
4
7
|
class ArrayOfSubscriberCustomField < ::Array
|
5
8
|
end
|
@@ -113,7 +116,7 @@ end
|
|
113
116
|
# {http://api.createsend.com/api/}SubscriberClick
|
114
117
|
# emailAddress - SOAP::SOAPString
|
115
118
|
# listID - SOAP::SOAPString
|
116
|
-
# clickedLinks - ArrayOfSubscriberClickedLink
|
119
|
+
# clickedLinks - Campaigning::ArrayOfSubscriberClickedLink
|
117
120
|
class SubscriberClick
|
118
121
|
attr_accessor :emailAddress
|
119
122
|
attr_accessor :listID
|
@@ -144,8 +147,8 @@ class SubscriberClickedLink
|
|
144
147
|
end
|
145
148
|
|
146
149
|
# {http://api.createsend.com/api/}ClientDetail
|
147
|
-
# basicDetails - ClientBasicDetails
|
148
|
-
# accessAndBilling - ClientAccessAndBilling
|
150
|
+
# basicDetails - Campaigning::ClientBasicDetails
|
151
|
+
# accessAndBilling - Campaigning::ClientAccessAndBilling
|
149
152
|
class ClientDetail
|
150
153
|
attr_accessor :basicDetails
|
151
154
|
attr_accessor :accessAndBilling
|
@@ -247,8 +250,8 @@ end
|
|
247
250
|
# {http://api.createsend.com/api/}ListCustomField
|
248
251
|
# fieldName - SOAP::SOAPString
|
249
252
|
# key - SOAP::SOAPString
|
250
|
-
# dataType - SubscriberFieldDataType
|
251
|
-
# fieldOptions - ArrayOfString
|
253
|
+
# dataType - Campaigning::SubscriberFieldDataType
|
254
|
+
# fieldOptions - Campaigning::ArrayOfString
|
252
255
|
class ListCustomField
|
253
256
|
attr_accessor :fieldName
|
254
257
|
attr_accessor :key
|
@@ -294,7 +297,7 @@ end
|
|
294
297
|
# name - SOAP::SOAPString
|
295
298
|
# date - SOAP::SOAPString
|
296
299
|
# state - SOAP::SOAPString
|
297
|
-
# customFields - ArrayOfSubscriberCustomField
|
300
|
+
# customFields - Campaigning::ArrayOfSubscriberCustomField
|
298
301
|
class Subscriber
|
299
302
|
attr_accessor :emailAddress
|
300
303
|
attr_accessor :name
|
@@ -360,7 +363,7 @@ end
|
|
360
363
|
# listID - SOAP::SOAPString
|
361
364
|
# email - SOAP::SOAPString
|
362
365
|
# name - SOAP::SOAPString
|
363
|
-
# customFields - ArrayOfSubscriberCustomField
|
366
|
+
# customFields - Campaigning::ArrayOfSubscriberCustomField
|
364
367
|
class SubscriberAddWithCustomFields
|
365
368
|
attr_accessor :apiKey
|
366
369
|
attr_accessor :listID
|
@@ -378,7 +381,7 @@ class SubscriberAddWithCustomFields
|
|
378
381
|
end
|
379
382
|
|
380
383
|
# {http://api.createsend.com/api/}Subscriber.AddWithCustomFieldsResponse
|
381
|
-
# subscriber_AddWithCustomFieldsResult - Result
|
384
|
+
# subscriber_AddWithCustomFieldsResult - Campaigning::Result
|
382
385
|
class SubscriberAddWithCustomFieldsResponse
|
383
386
|
attr_accessor :subscriber_AddWithCustomFieldsResult
|
384
387
|
|
@@ -392,7 +395,7 @@ end
|
|
392
395
|
# listID - SOAP::SOAPString
|
393
396
|
# email - SOAP::SOAPString
|
394
397
|
# name - SOAP::SOAPString
|
395
|
-
# customFields - ArrayOfSubscriberCustomField
|
398
|
+
# customFields - Campaigning::ArrayOfSubscriberCustomField
|
396
399
|
class SubscriberAddAndResubscribeWithCustomFields
|
397
400
|
attr_accessor :apiKey
|
398
401
|
attr_accessor :listID
|
@@ -410,7 +413,7 @@ class SubscriberAddAndResubscribeWithCustomFields
|
|
410
413
|
end
|
411
414
|
|
412
415
|
# {http://api.createsend.com/api/}Subscriber.AddAndResubscribeWithCustomFieldsResponse
|
413
|
-
# subscriber_AddAndResubscribeWithCustomFieldsResult - Result
|
416
|
+
# subscriber_AddAndResubscribeWithCustomFieldsResult - Campaigning::Result
|
414
417
|
class SubscriberAddAndResubscribeWithCustomFieldsResponse
|
415
418
|
attr_accessor :subscriber_AddAndResubscribeWithCustomFieldsResult
|
416
419
|
|
@@ -439,7 +442,7 @@ class SubscriberAdd
|
|
439
442
|
end
|
440
443
|
|
441
444
|
# {http://api.createsend.com/api/}Subscriber.AddResponse
|
442
|
-
# subscriber_AddResult - Result
|
445
|
+
# subscriber_AddResult - Campaigning::Result
|
443
446
|
class SubscriberAddResponse
|
444
447
|
attr_accessor :subscriber_AddResult
|
445
448
|
|
@@ -468,7 +471,7 @@ class SubscriberAddAndResubscribe
|
|
468
471
|
end
|
469
472
|
|
470
473
|
# {http://api.createsend.com/api/}Subscriber.AddAndResubscribeResponse
|
471
|
-
# subscriber_AddAndResubscribeResult - Result
|
474
|
+
# subscriber_AddAndResubscribeResult - Campaigning::Result
|
472
475
|
class SubscriberAddAndResubscribeResponse
|
473
476
|
attr_accessor :subscriber_AddAndResubscribeResult
|
474
477
|
|
@@ -494,7 +497,7 @@ class SubscriberUnsubscribe_
|
|
494
497
|
end
|
495
498
|
|
496
499
|
# {http://api.createsend.com/api/}Subscriber.UnsubscribeResponse
|
497
|
-
# subscriber_UnsubscribeResult - Result
|
500
|
+
# subscriber_UnsubscribeResult - Campaigning::Result
|
498
501
|
class SubscriberUnsubscribeResponse
|
499
502
|
attr_accessor :subscriber_UnsubscribeResult
|
500
503
|
|
@@ -694,7 +697,7 @@ class ListUpdate
|
|
694
697
|
end
|
695
698
|
|
696
699
|
# {http://api.createsend.com/api/}List.UpdateResponse
|
697
|
-
# list_UpdateResult - Result
|
700
|
+
# list_UpdateResult - Campaigning::Result
|
698
701
|
class ListUpdateResponse
|
699
702
|
attr_accessor :list_UpdateResult
|
700
703
|
|
@@ -740,7 +743,7 @@ class ListDelete
|
|
740
743
|
end
|
741
744
|
|
742
745
|
# {http://api.createsend.com/api/}List.DeleteResponse
|
743
|
-
# list_DeleteResult - Result
|
746
|
+
# list_DeleteResult - Campaigning::Result
|
744
747
|
class ListDeleteResponse
|
745
748
|
attr_accessor :list_DeleteResult
|
746
749
|
|
@@ -789,7 +792,7 @@ class ListDeleteCustomField
|
|
789
792
|
end
|
790
793
|
|
791
794
|
# {http://api.createsend.com/api/}List.DeleteCustomFieldResponse
|
792
|
-
# list_DeleteCustomFieldResult - Result
|
795
|
+
# list_DeleteCustomFieldResult - Campaigning::Result
|
793
796
|
class ListDeleteCustomFieldResponse
|
794
797
|
attr_accessor :list_DeleteCustomFieldResult
|
795
798
|
|
@@ -802,7 +805,7 @@ end
|
|
802
805
|
# apiKey - SOAP::SOAPString
|
803
806
|
# listID - SOAP::SOAPString
|
804
807
|
# fieldName - SOAP::SOAPString
|
805
|
-
# dataType - SubscriberFieldDataType
|
808
|
+
# dataType - Campaigning::SubscriberFieldDataType
|
806
809
|
# options - SOAP::SOAPString
|
807
810
|
class ListCreateCustomField
|
808
811
|
attr_accessor :apiKey
|
@@ -821,7 +824,7 @@ class ListCreateCustomField
|
|
821
824
|
end
|
822
825
|
|
823
826
|
# {http://api.createsend.com/api/}List.CreateCustomFieldResponse
|
824
|
-
# list_CreateCustomFieldResult - Result
|
827
|
+
# list_CreateCustomFieldResult - Campaigning::Result
|
825
828
|
class ListCreateCustomFieldResponse
|
826
829
|
attr_accessor :list_CreateCustomFieldResult
|
827
830
|
|
@@ -1033,7 +1036,7 @@ class ClientUpdateAccessAndBilling
|
|
1033
1036
|
end
|
1034
1037
|
|
1035
1038
|
# {http://api.createsend.com/api/}Client.UpdateAccessAndBillingResponse
|
1036
|
-
# client_UpdateAccessAndBillingResult - Result
|
1039
|
+
# client_UpdateAccessAndBillingResult - Campaigning::Result
|
1037
1040
|
class ClientUpdateAccessAndBillingResponse
|
1038
1041
|
attr_accessor :client_UpdateAccessAndBillingResult
|
1039
1042
|
|
@@ -1079,7 +1082,7 @@ class ClientDelete
|
|
1079
1082
|
end
|
1080
1083
|
|
1081
1084
|
# {http://api.createsend.com/api/}Client.DeleteResponse
|
1082
|
-
# client_DeleteResult - Result
|
1085
|
+
# client_DeleteResult - Campaigning::Result
|
1083
1086
|
class ClientDeleteResponse
|
1084
1087
|
attr_accessor :client_DeleteResult
|
1085
1088
|
|
@@ -1316,8 +1319,8 @@ end
|
|
1316
1319
|
# replyTo - SOAP::SOAPString
|
1317
1320
|
# htmlUrl - SOAP::SOAPString
|
1318
1321
|
# textUrl - SOAP::SOAPString
|
1319
|
-
# subscriberListIDs - ArrayOfString
|
1320
|
-
# listSegments - ArrayOfList
|
1322
|
+
# subscriberListIDs - Campaigning::ArrayOfString
|
1323
|
+
# listSegments - Campaigning::ArrayOfList
|
1321
1324
|
class CampaignCreate
|
1322
1325
|
attr_accessor :apiKey
|
1323
1326
|
attr_accessor :clientID
|
@@ -1376,7 +1379,7 @@ class CampaignSend
|
|
1376
1379
|
end
|
1377
1380
|
|
1378
1381
|
# {http://api.createsend.com/api/}Campaign.SendResponse
|
1379
|
-
# campaign_SendResult - Result
|
1382
|
+
# campaign_SendResult - Campaigning::Result
|
1380
1383
|
class CampaignSendResponse
|
1381
1384
|
attr_accessor :campaign_SendResult
|
1382
1385
|
|
@@ -1391,3 +1394,6 @@ class AnyType < ::String
|
|
1391
1394
|
super
|
1392
1395
|
end
|
1393
1396
|
end
|
1397
|
+
|
1398
|
+
|
1399
|
+
end
|
@@ -2,6 +2,8 @@ require File.expand_path(File.dirname(__FILE__)) + '/default.rb'
|
|
2
2
|
require File.expand_path(File.dirname(__FILE__)) + '/defaultMappingRegistry.rb'
|
3
3
|
require 'soap/rpc/driver'
|
4
4
|
|
5
|
+
module Campaigning
|
6
|
+
|
5
7
|
class ApiSoap < ::SOAP::RPC::Driver
|
6
8
|
DefaultEndpointUrl = "http://api.createsend.com/api/api.asmx"
|
7
9
|
|
@@ -343,3 +345,5 @@ end
|
|
343
345
|
|
344
346
|
|
345
347
|
|
348
|
+
|
349
|
+
end
|