MxmConnect 1

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/README ADDED
@@ -0,0 +1,6 @@
1
+ This gem is used to connect to MxM service.
2
+
3
+ Documentation is available on http://dev.m--x--m.net
4
+
5
+ Version 1
6
+ Author nico@m--x--m.net
@@ -0,0 +1,146 @@
1
+ require 'xsd/qname'
2
+ require 'date'
3
+ require 'rubygems'
4
+ gem 'ruby-hmac'
5
+ require 'hmac-sha2'
6
+
7
+
8
+ # {http://mxmaster.net/campaign/0.1}Authentication
9
+ # user - SOAP::SOAPString
10
+ # timestamp - SOAP::SOAPDateTime
11
+ # signature - SOAP::SOAPString
12
+ class Authentication
13
+ attr_accessor :user
14
+ attr_accessor :timestamp
15
+ attr_accessor :signature
16
+
17
+ def initialize(user, password)
18
+ @user = user
19
+ @password= password
20
+ t = Time.now
21
+ t = t.utc
22
+ @timestamp = t.xmlschema
23
+ makeSignature()
24
+ end
25
+
26
+ def makeSignature()
27
+ sign = ::HMAC::SHA256.new()
28
+ sign.set_key(@password)
29
+ sign.update("http://mxmaster.net/campaign/0.1#doCampaign" + @user + @timestamp)
30
+ @signature = sign.hexdigest()
31
+ end
32
+ end
33
+
34
+ # {http://mxmaster.net/campaign/0.1}CampaignParameters
35
+ # tag - ArrayTag
36
+ # mailfrom - SOAP::SOAPString
37
+ # mailfrom_friendly - SOAP::SOAPString
38
+ # replyto - SOAP::SOAPString
39
+ # replyto_filtered - SOAP::SOAPBoolean
40
+ class CampaignParameters
41
+ attr_accessor :tag
42
+ attr_accessor :mailfrom
43
+ attr_accessor :mailfrom_friendly
44
+ attr_accessor :replyto
45
+ attr_accessor :replyto_filtered
46
+
47
+ def initialize(tag = nil, mailfrom = nil, mailfrom_friendly = nil, replyto = nil, replyto_filtered = nil)
48
+ @tag = tag
49
+ @mailfrom = mailfrom
50
+ @mailfrom_friendly = mailfrom_friendly
51
+ @replyto = replyto
52
+ @replyto_filtered = replyto_filtered
53
+ end
54
+ end
55
+
56
+ # {http://mxmaster.net/campaign/0.1}Content
57
+ # subject - SOAP::SOAPString
58
+ # html - SOAP::SOAPString
59
+ # text - SOAP::SOAPString
60
+ class Content
61
+ attr_accessor :subject
62
+ attr_accessor :html
63
+ attr_accessor :text
64
+
65
+ def initialize(subject = nil, html = nil, text = nil)
66
+ @subject = subject
67
+ @html = html
68
+ @text = text
69
+ end
70
+ end
71
+
72
+ # {http://mxmaster.net/campaign/0.1}Subscribers
73
+ # descriptor - Email
74
+ # database - ArrayEmail
75
+ class Subscribers
76
+ attr_accessor :descriptor
77
+ attr_accessor :database
78
+
79
+ def initialize(descriptor = nil, database = nil)
80
+ @descriptor = descriptor
81
+ @database = database
82
+ end
83
+ end
84
+
85
+ # {http://mxmaster.net/campaign/0.1}Email
86
+ # email - SOAP::SOAPString
87
+ # field1 - SOAP::SOAPString
88
+ # field2 - SOAP::SOAPString
89
+ # field3 - SOAP::SOAPString
90
+ # field4 - SOAP::SOAPString
91
+ # field5 - SOAP::SOAPString
92
+ # field6 - SOAP::SOAPString
93
+ # field7 - SOAP::SOAPString
94
+ # field8 - SOAP::SOAPString
95
+ # field9 - SOAP::SOAPString
96
+ # field10 - SOAP::SOAPString
97
+ # field11 - SOAP::SOAPString
98
+ # field12 - SOAP::SOAPString
99
+ # field13 - SOAP::SOAPString
100
+ # field14 - SOAP::SOAPString
101
+ # field15 - SOAP::SOAPString
102
+ class Email
103
+ attr_accessor :email
104
+ attr_accessor :field1
105
+ attr_accessor :field2
106
+ attr_accessor :field3
107
+ attr_accessor :field4
108
+ attr_accessor :field5
109
+ attr_accessor :field6
110
+ attr_accessor :field7
111
+ attr_accessor :field8
112
+ attr_accessor :field9
113
+ attr_accessor :field10
114
+ attr_accessor :field11
115
+ attr_accessor :field12
116
+ attr_accessor :field13
117
+ attr_accessor :field14
118
+ attr_accessor :field15
119
+
120
+ def initialize(email = '', field1 = '', field2 = '', field3 = '', field4 = '', field5 = '', field6 = '', field7 = '', field8 = '', field9 = '', field10 = '', field11 = '', field12 = '', field13 = '', field14 = '', field15 = '')
121
+ @email = email
122
+ @field1 = field1
123
+ @field2 = field2
124
+ @field3 = field3
125
+ @field4 = field4
126
+ @field5 = field5
127
+ @field6 = field6
128
+ @field7 = field7
129
+ @field8 = field8
130
+ @field9 = field9
131
+ @field10 = field10
132
+ @field11 = field11
133
+ @field12 = field12
134
+ @field13 = field13
135
+ @field14 = field14
136
+ @field15 = field15
137
+ end
138
+ end
139
+
140
+ # {http://mxmaster.net/campaign/0.1}ArrayEmail
141
+ class ArrayEmail < ::Array
142
+ end
143
+
144
+ # {http://mxmaster.net/campaign/0.1}ArrayTag
145
+ class ArrayTag < ::Array
146
+ end
@@ -0,0 +1,101 @@
1
+ require 'default.rb'
2
+ require 'defaultMappingRegistry.rb'
3
+ require 'soap/rpc/driver'
4
+
5
+ class WSDL01ForMxMasterPortType < ::SOAP::RPC::Driver
6
+ DefaultEndpointUrl = "http://mail.messaging-master.com/api_2.php"
7
+ NsC_01 = "http://mxmaster.net/campaign/0.1"
8
+
9
+ Methods = [
10
+ [ XSD::QName.new(NsC_01, "sendCampaign"),
11
+ "http://mxmaster.net/campaign/0.1#doCampaign",
12
+ "sendCampaign",
13
+ [ ["in", "authentication", ["Authentication", "http://mxmaster.net/campaign/0.1", "Authentication"]],
14
+ ["in", "subscribers", ["ArrayEmail", "http://mxmaster.net/campaign/0.1", "ArrayEmail"]],
15
+ ["in", "parameters", ["CampaignParameters", "http://mxmaster.net/campaign/0.1", "CampaignParameters"]],
16
+ ["in", "content", ["Content", "http://mxmaster.net/campaign/0.1", "Content"]],
17
+ ["retval", "return", ["::SOAP::SOAPBoolean"]] ],
18
+ { :request_style => :rpc, :request_use => :literal,
19
+ :response_style => :rpc, :response_use => :literal,
20
+ :faults => {} }
21
+ ],
22
+ [ XSD::QName.new(NsC_01, "createTag"),
23
+ "http://mxmaster.net/campaign/0.1#doCampaign",
24
+ "createTag",
25
+ [ ["in", "authentication", ["Authentication", "http://mxmaster.net/campaign/0.1", "Authentication"]],
26
+ ["in", "tag", ["::SOAP::SOAPString"]],
27
+ ["retval", "return", ["::SOAP::SOAPBoolean"]] ],
28
+ { :request_style => :rpc, :request_use => :literal,
29
+ :response_style => :rpc, :response_use => :literal,
30
+ :faults => {} }
31
+ ],
32
+ [ XSD::QName.new(NsC_01, "deleteTag"),
33
+ "http://mxmaster.net/campaign/0.1#doCampaign",
34
+ "deleteTag",
35
+ [ ["in", "authentication", ["Authentication", "http://mxmaster.net/campaign/0.1", "Authentication"]],
36
+ ["in", "tag", ["::SOAP::SOAPString"]],
37
+ ["retval", "return", ["::SOAP::SOAPBoolean"]] ],
38
+ { :request_style => :rpc, :request_use => :literal,
39
+ :response_style => :rpc, :response_use => :literal,
40
+ :faults => {} }
41
+ ],
42
+ [ XSD::QName.new(NsC_01, "listAllTags"),
43
+ "http://mxmaster.net/campaign/0.1#doCampaign",
44
+ "listAllTags",
45
+ [ ["in", "authentication", ["Authentication", "http://mxmaster.net/campaign/0.1", "Authentication"]],
46
+ ["retval", "return", ["ArrayTag", "http://mxmaster.net/campaign/0.1", "ArrayTag"]] ],
47
+ { :request_style => :rpc, :request_use => :literal,
48
+ :response_style => :rpc, :response_use => :literal,
49
+ :faults => {} }
50
+ ],
51
+ [ XSD::QName.new(NsC_01, "isTag"),
52
+ "http://mxmaster.net/campaign/0.1#doCampaign",
53
+ "isTag",
54
+ [ ["in", "authentication", ["Authentication", "http://mxmaster.net/campaign/0.1", "Authentication"]],
55
+ ["in", "tag", ["::SOAP::SOAPString"]],
56
+ ["retval", "return", ["::SOAP::SOAPBoolean"]] ],
57
+ { :request_style => :rpc, :request_use => :literal,
58
+ :response_style => :rpc, :response_use => :literal,
59
+ :faults => {} }
60
+ ],
61
+ [ XSD::QName.new(NsC_01, "getTag"),
62
+ "http://mxmaster.net/campaign/0.1#doCampaign",
63
+ "getTag",
64
+ [ ["in", "authentication", ["Authentication", "http://mxmaster.net/campaign/0.1", "Authentication"]],
65
+ ["in", "tag", ["::SOAP::SOAPString"]],
66
+ ["retval", "return", ["::SOAP::SOAPString"]] ],
67
+ { :request_style => :rpc, :request_use => :literal,
68
+ :response_style => :rpc, :response_use => :literal,
69
+ :faults => {} }
70
+ ]
71
+ ]
72
+
73
+ def initialize(endpoint_url = nil)
74
+ endpoint_url ||= DefaultEndpointUrl
75
+ super(endpoint_url, nil)
76
+ self.mapping_registry = DefaultMappingRegistry::EncodedRegistry
77
+ self.literal_mapping_registry = DefaultMappingRegistry::LiteralRegistry
78
+ init_methods
79
+ end
80
+
81
+ private
82
+
83
+ def init_methods
84
+ Methods.each do |definitions|
85
+ opt = definitions.last
86
+ if opt[:request_style] == :document
87
+ add_document_operation(*definitions)
88
+ else
89
+ add_rpc_operation(*definitions)
90
+ qname = definitions[0]
91
+ name = definitions[2]
92
+ if qname.name != name and qname.name.capitalize == name.capitalize
93
+ ::SOAP::Mapping.define_singleton_method(self, qname.name) do |*arg|
94
+ __send__(name, *arg)
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
101
+
@@ -0,0 +1,170 @@
1
+ require 'default.rb'
2
+ require 'rubygems'
3
+ gem 'soap4r'
4
+ require 'soap/mapping'
5
+
6
+ module DefaultMappingRegistry
7
+ EncodedRegistry = ::SOAP::Mapping::EncodedRegistry.new
8
+ LiteralRegistry = ::SOAP::Mapping::LiteralRegistry.new
9
+ NsC_01 = "http://mxmaster.net/campaign/0.1"
10
+
11
+ EncodedRegistry.register(
12
+ :class => Authentication,
13
+ :schema_type => XSD::QName.new(NsC_01, "Authentication"),
14
+ :schema_element => [
15
+ ["user", ["SOAP::SOAPString", XSD::QName.new(nil, "user")]],
16
+ ["timestamp", ["SOAP::SOAPDateTime", XSD::QName.new(nil, "timestamp")]],
17
+ ["signature", ["SOAP::SOAPString", XSD::QName.new(nil, "signature")]]
18
+ ]
19
+ )
20
+
21
+ EncodedRegistry.register(
22
+ :class => CampaignParameters,
23
+ :schema_type => XSD::QName.new(NsC_01, "CampaignParameters"),
24
+ :schema_element => [
25
+ ["tag", ["ArrayTag", XSD::QName.new(nil, "tag")]],
26
+ ["mailfrom", ["SOAP::SOAPString", XSD::QName.new(nil, "mailfrom")]],
27
+ ["mailfrom_friendly", ["SOAP::SOAPString", XSD::QName.new(nil, "mailfrom_friendly")]],
28
+ ["replyto", ["SOAP::SOAPString", XSD::QName.new(nil, "replyto")]],
29
+ ["replyto_filtered", ["SOAP::SOAPBoolean", XSD::QName.new(nil, "replyto_filtered")]]
30
+ ]
31
+ )
32
+
33
+ EncodedRegistry.register(
34
+ :class => Content,
35
+ :schema_type => XSD::QName.new(NsC_01, "Content"),
36
+ :schema_element => [
37
+ ["subject", ["SOAP::SOAPString", XSD::QName.new(nil, "subject")]],
38
+ ["html", ["SOAP::SOAPString", XSD::QName.new(nil, "html")]],
39
+ ["text", ["SOAP::SOAPString", XSD::QName.new(nil, "text")]]
40
+ ]
41
+ )
42
+
43
+ EncodedRegistry.register(
44
+ :class => Subscribers,
45
+ :schema_type => XSD::QName.new(NsC_01, "Subscribers"),
46
+ :schema_element => [
47
+ ["descriptor", ["Email", XSD::QName.new(nil, "descriptor")]],
48
+ ["database", ["ArrayEmail", XSD::QName.new(nil, "database")]]
49
+ ]
50
+ )
51
+
52
+ EncodedRegistry.register(
53
+ :class => Email,
54
+ :schema_type => XSD::QName.new(NsC_01, "Email"),
55
+ :schema_element => [
56
+ ["email", ["SOAP::SOAPString", XSD::QName.new(nil, "email")]],
57
+ ["field1", ["SOAP::SOAPString", XSD::QName.new(nil, "field1")]],
58
+ ["field2", ["SOAP::SOAPString", XSD::QName.new(nil, "field2")]],
59
+ ["field3", ["SOAP::SOAPString", XSD::QName.new(nil, "field3")]],
60
+ ["field4", ["SOAP::SOAPString", XSD::QName.new(nil, "field4")]],
61
+ ["field5", ["SOAP::SOAPString", XSD::QName.new(nil, "field5")]],
62
+ ["field6", ["SOAP::SOAPString", XSD::QName.new(nil, "field6")]],
63
+ ["field7", ["SOAP::SOAPString", XSD::QName.new(nil, "field7")]],
64
+ ["field8", ["SOAP::SOAPString", XSD::QName.new(nil, "field8")]],
65
+ ["field9", ["SOAP::SOAPString", XSD::QName.new(nil, "field9")]],
66
+ ["field10", ["SOAP::SOAPString", XSD::QName.new(nil, "field10")]],
67
+ ["field11", ["SOAP::SOAPString", XSD::QName.new(nil, "field11")]],
68
+ ["field12", ["SOAP::SOAPString", XSD::QName.new(nil, "field12")]],
69
+ ["field13", ["SOAP::SOAPString", XSD::QName.new(nil, "field13")]],
70
+ ["field14", ["SOAP::SOAPString", XSD::QName.new(nil, "field14")]],
71
+ ["field15", ["SOAP::SOAPString", XSD::QName.new(nil, "field15")]]
72
+ ]
73
+ )
74
+
75
+ EncodedRegistry.register(
76
+ :class => ArrayEmail,
77
+ :schema_type => XSD::QName.new(NsC_01, "ArrayEmail"),
78
+ :schema_element => [
79
+ ["email", ["Email[]", XSD::QName.new(nil, "Email")], [1, nil]]
80
+ ]
81
+ )
82
+
83
+ EncodedRegistry.register(
84
+ :class => ArrayTag,
85
+ :schema_type => XSD::QName.new(NsC_01, "ArrayTag"),
86
+ :schema_element => [
87
+ ["tag", ["SOAP::SOAPString[]", XSD::QName.new(nil, "Tag")], [1, nil]]
88
+ ]
89
+ )
90
+
91
+ LiteralRegistry.register(
92
+ :class => Authentication,
93
+ :schema_type => XSD::QName.new(NsC_01, "Authentication"),
94
+ :schema_element => [
95
+ ["user", ["SOAP::SOAPString", XSD::QName.new(nil, "user")]],
96
+ ["timestamp", ["SOAP::SOAPDateTime", XSD::QName.new(nil, "timestamp")]],
97
+ ["signature", ["SOAP::SOAPString", XSD::QName.new(nil, "signature")]]
98
+ ]
99
+ )
100
+
101
+ LiteralRegistry.register(
102
+ :class => CampaignParameters,
103
+ :schema_type => XSD::QName.new(NsC_01, "CampaignParameters"),
104
+ :schema_element => [
105
+ ["tag", ["ArrayTag", XSD::QName.new(nil, "tag")]],
106
+ ["mailfrom", ["SOAP::SOAPString", XSD::QName.new(nil, "mailfrom")]],
107
+ ["mailfrom_friendly", ["SOAP::SOAPString", XSD::QName.new(nil, "mailfrom_friendly")]],
108
+ ["replyto", ["SOAP::SOAPString", XSD::QName.new(nil, "replyto")]],
109
+ ["replyto_filtered", ["SOAP::SOAPBoolean", XSD::QName.new(nil, "replyto_filtered")]]
110
+ ]
111
+ )
112
+
113
+ LiteralRegistry.register(
114
+ :class => Content,
115
+ :schema_type => XSD::QName.new(NsC_01, "Content"),
116
+ :schema_element => [
117
+ ["subject", ["SOAP::SOAPString", XSD::QName.new(nil, "subject")]],
118
+ ["html", ["SOAP::SOAPString", XSD::QName.new(nil, "html")]],
119
+ ["text", ["SOAP::SOAPString", XSD::QName.new(nil, "text")]]
120
+ ]
121
+ )
122
+
123
+ LiteralRegistry.register(
124
+ :class => Subscribers,
125
+ :schema_type => XSD::QName.new(NsC_01, "Subscribers"),
126
+ :schema_element => [
127
+ ["descriptor", ["Email", XSD::QName.new(nil, "descriptor")]],
128
+ ["database", ["ArrayEmail", XSD::QName.new(nil, "database")]]
129
+ ]
130
+ )
131
+
132
+ LiteralRegistry.register(
133
+ :class => Email,
134
+ :schema_type => XSD::QName.new(NsC_01, "Email"),
135
+ :schema_element => [
136
+ ["email", ["SOAP::SOAPString", XSD::QName.new(nil, "email")]],
137
+ ["field1", ["SOAP::SOAPString", XSD::QName.new(nil, "field1")]],
138
+ ["field2", ["SOAP::SOAPString", XSD::QName.new(nil, "field2")]],
139
+ ["field3", ["SOAP::SOAPString", XSD::QName.new(nil, "field3")]],
140
+ ["field4", ["SOAP::SOAPString", XSD::QName.new(nil, "field4")]],
141
+ ["field5", ["SOAP::SOAPString", XSD::QName.new(nil, "field5")]],
142
+ ["field6", ["SOAP::SOAPString", XSD::QName.new(nil, "field6")]],
143
+ ["field7", ["SOAP::SOAPString", XSD::QName.new(nil, "field7")]],
144
+ ["field8", ["SOAP::SOAPString", XSD::QName.new(nil, "field8")]],
145
+ ["field9", ["SOAP::SOAPString", XSD::QName.new(nil, "field9")]],
146
+ ["field10", ["SOAP::SOAPString", XSD::QName.new(nil, "field10")]],
147
+ ["field11", ["SOAP::SOAPString", XSD::QName.new(nil, "field11")]],
148
+ ["field12", ["SOAP::SOAPString", XSD::QName.new(nil, "field12")]],
149
+ ["field13", ["SOAP::SOAPString", XSD::QName.new(nil, "field13")]],
150
+ ["field14", ["SOAP::SOAPString", XSD::QName.new(nil, "field14")]],
151
+ ["field15", ["SOAP::SOAPString", XSD::QName.new(nil, "field15")]]
152
+ ]
153
+ )
154
+
155
+ LiteralRegistry.register(
156
+ :class => ArrayEmail,
157
+ :schema_type => XSD::QName.new(NsC_01, "ArrayEmail"),
158
+ :schema_element => [
159
+ ["email", ["Email[]", XSD::QName.new(nil, "Email")], [1, nil]]
160
+ ]
161
+ )
162
+
163
+ LiteralRegistry.register(
164
+ :class => ArrayTag,
165
+ :schema_type => XSD::QName.new(NsC_01, "ArrayTag"),
166
+ :schema_element => [
167
+ ["tag", ["SOAP::SOAPString[]", XSD::QName.new(nil, "Tag")], [1, nil]]
168
+ ]
169
+ )
170
+ end
@@ -0,0 +1,257 @@
1
+ #!/usr/bin/env ruby
2
+ require 'defaultDriver.rb'
3
+
4
+ # run ruby with -d to see SOAP wiredumps.
5
+
6
+
7
+ # SYNOPSIS
8
+ # This class encapsulates all exception; when you have it there is a
9
+ # problem in your code probably.
10
+ class MxmException < Exception
11
+ end
12
+
13
+ # SYNOPSIS
14
+ # This class is the stub to connect to MxM
15
+ class MxmConnect
16
+
17
+ private
18
+
19
+ def connect(host)
20
+ @idx_host = 0
21
+ fqdn = @@Prefix + host + @@Postfix
22
+ @stub = WSDL01ForMxMasterPortType.new(fqdn)
23
+ end
24
+
25
+ def reconnect()
26
+ if @idx_host > (@@Hosts.length - 1):
27
+ raise MxmException
28
+ end
29
+ @idx_host = @idx_host + 1
30
+ fqdn = @@Prefix + @@Hosts[@idx_host] + @@Postfix
31
+ @stub = WSDL01ForMxMasterPortType.new(fqdn)
32
+ end
33
+
34
+ @@Default_host = 'mail'
35
+ @@Hosts = ['mail','mail6', 'mail7']
36
+ @@Fast_host = 'mail7'
37
+ @@Prefix = 'http://'
38
+ @@Postfix = '.messaging-master.com/api_2.php'
39
+
40
+ public
41
+ def initialize(user = nil, password = nil)
42
+ @idx_host = 0
43
+ @user = user
44
+ @password = password
45
+ @auth = Authentication.new(@user, @password)
46
+ connect(@@Default_host)
47
+ @stub.wiredump_dev = STDERR if $DEBUG
48
+ end
49
+
50
+ # SYNOPSIS
51
+ # This setter set the fast delivery on or off. true for on, false for off.
52
+ # Fast delivery is reserved for fast and critical emails such as subscription
53
+ # confirmation.
54
+ # setFastDelivery(bool)
55
+ #
56
+ # ARGS
57
+ # bool true for on, false for off
58
+ def setFastDelivery(bool)
59
+ if bool
60
+ connect(@@Fast_host)
61
+ else
62
+ connect(@@Default_host)
63
+ end
64
+ end
65
+
66
+
67
+
68
+
69
+ # SYNOPSIS
70
+ # createTag(tag) creates a tag in the reporting system. Idempotent. If already there, will do nothing.
71
+ #
72
+ # ARGS
73
+ # tag String (ascii only and < 40 chars) the name of the new tag
74
+ #
75
+ # RETURNS
76
+ # v_return Boolean - true if success, false otherwise
77
+ #
78
+ def createTag(tag = nil)
79
+ if tag == nil or tag.length > 40 or tag.strip.length == 0
80
+ raise MxmException, 'invalid tag'
81
+ end
82
+ flag = true
83
+ while flag
84
+ begin
85
+ res = @stub.createTag(@auth, tag)
86
+ flag = false
87
+ return res
88
+
89
+ rescue SOAP::FaultError
90
+ raise MxmException
91
+ rescue Errno::ECONNREFUSED, SOAP::HTTPStreamError, SocketError
92
+ if flag
93
+ reconnect()
94
+ else
95
+ raise MxmException
96
+ end
97
+ end
98
+ end
99
+ end
100
+
101
+
102
+ # SYNOPSIS
103
+ # deleteTag(tag) deletes the tag
104
+ #
105
+ # ARGS
106
+ # tag String, name of the tag to be deleted.
107
+ #
108
+ # RETURNS
109
+ # v_return Boolean - true if success, false if failure
110
+ #
111
+ def deleteTag(tag = nil)
112
+ if tag == nil or tag.length > 40 or tag.strip.length == 0
113
+ raise MxmException, 'invalid tag'
114
+ end
115
+ flag = true
116
+ while flag
117
+ begin
118
+ res = @stub.deleteTag(@auth, tag)
119
+ flag = false
120
+ return res
121
+ rescue SOAP::FaultError
122
+ raise MxmException
123
+ rescue Errno::ECONNREFUSED, SOAP::HTTPStreamError, SocketError
124
+ if flag
125
+ reconnect()
126
+ else
127
+ raise MxmException
128
+ end
129
+ end
130
+ end
131
+ end
132
+
133
+
134
+ # SYNOPSIS
135
+ # listAllTags() lists all the tag for your user
136
+ #
137
+ # RETURNS
138
+ # v_return An array of string containing all your tags
139
+ #
140
+ def listAllTags
141
+ flag = true
142
+ while flag
143
+ begin
144
+ res = @stub.listAllTags(@auth)
145
+ flag = false
146
+ return res
147
+ rescue SOAP::FaultError
148
+ raise MxmException
149
+ rescue Errno::ECONNREFUSED, SOAP::HTTPStreamError, SocketError
150
+ if flag
151
+ reconnect()
152
+ else
153
+ raise MxmException
154
+ end
155
+ end
156
+ end
157
+ end
158
+
159
+
160
+ # SYNOPSIS
161
+ # getTag(tag) returns the content of a tag.
162
+ #
163
+ # ARGS
164
+ # tag String - name of the tag to be returned
165
+ #
166
+ # RETURNS
167
+ # v_return a String containing an XML document with the content of the tag
168
+ #
169
+ def getTag(tag)
170
+ if tag == nil or tag.length > 40 or tag.strip.length == 0
171
+ raise MxmException, 'invalid tag'
172
+ end
173
+ flag = true
174
+ while flag
175
+ begin
176
+ res = @stub.getTag(@auth, tag)
177
+ flag = false
178
+ return res
179
+ rescue SOAP::FaultError
180
+ raise MxmException
181
+ rescue Errno::ECONNREFUSED, SOAP::HTTPStreamError, SocketError
182
+ if flag
183
+ reconnect()
184
+ else
185
+ raise MxmException
186
+ end
187
+ end
188
+ end
189
+ end
190
+
191
+
192
+
193
+ # SYNOPSIS
194
+ # isTag(tag) tells you whether tag exists or not (deprecated. No usage.)
195
+ #
196
+ # ARGS
197
+ # tag String - the tag to query
198
+ #
199
+ # RETURNS
200
+ # v_return Boolean - {http://www.w3.org/2001/XMLSchema}boolean
201
+ def isTag(tag)
202
+ puts 'oooo'
203
+ if tag == nil or tag.length > 40 or tag.strip.length == 0
204
+ raise MxmException, 'invalid tag'
205
+ end
206
+ flag = true
207
+ while flag
208
+ begin
209
+ res = @stub.isTag(@auth, tag)
210
+ flag = false
211
+ return res
212
+ rescue SOAP::FaultError
213
+ raise MxmException
214
+ rescue Errno::ECONNREFUSED, SOAP::HTTPStreamError, SocketError
215
+ if flag
216
+ reconnect()
217
+ else
218
+ raise MxmException
219
+ end
220
+ end
221
+ end
222
+ end
223
+
224
+ # SYNOPSIS
225
+ # sendCampaign(subscribers, parameters, content)
226
+ #
227
+ # ARGS
228
+ # subscribers ArrayEmail - List of your subscribers
229
+ # parameters CampaignParameters - the parameter of the delivery
230
+ # content Content - the content of the email
231
+ #
232
+ # RETURNS
233
+ # v_return Boolean - true if success false otherwise
234
+ #
235
+ def sendCampaign(subscribers, parameters, content)
236
+ flag = true
237
+ while flag
238
+ begin
239
+ res = @stub.sendCampaign(@auth, subscribers, parameters, content)
240
+ flag = false
241
+ return res
242
+ rescue SOAP::FaultError
243
+ raise MxmException
244
+ rescue Errno::ECONNREFUSED, SOAP::HTTPStreamError, SocketError
245
+ if flag
246
+ reconnect()
247
+ else
248
+ raise MxmException
249
+ end
250
+ end
251
+ end
252
+ end
253
+ end
254
+
255
+
256
+
257
+
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: MxmConnect
3
+ version: !ruby/object:Gem::Version
4
+ version: "1"
5
+ platform: ruby
6
+ authors:
7
+ - Nicolas Toper
8
+ autorequire: mxmconnect
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-26 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: ruby-hmac
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.3.0
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: httpclient
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 2.1.3.1
32
+ version:
33
+ - !ruby/object:Gem::Dependency
34
+ name: soap4r
35
+ version_requirement:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.5.8
41
+ version:
42
+ description:
43
+ email: nico@m--x--m.net
44
+ executables: []
45
+
46
+ extensions: []
47
+
48
+ extra_rdoc_files:
49
+ - README
50
+ files:
51
+ - lib/default.rb
52
+ - lib/defaultDriver.rb
53
+ - lib/defaultMappingRegistry.rb
54
+ - lib/mxmconnect.rb
55
+ - README
56
+ has_rdoc: true
57
+ homepage: http://www.m--x--m.net
58
+ post_install_message:
59
+ rdoc_options: []
60
+
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ version:
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
75
+ requirements: []
76
+
77
+ rubyforge_project:
78
+ rubygems_version: 1.0.1
79
+ signing_key:
80
+ specification_version: 2
81
+ summary: This is a stub used to connect easily to MxM mail delivery service
82
+ test_files: []
83
+