responsys 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/responsys.rb +24 -5
- data/responsys.gemspec +1 -1
- metadata +2 -2
data/lib/responsys.rb
CHANGED
@@ -2,9 +2,12 @@ require 'metal/defaultDriver.rb'
|
|
2
2
|
require 'metal/defaultMappingRegistry.rb'
|
3
3
|
|
4
4
|
class Responsys
|
5
|
-
TIMEOUT =
|
5
|
+
TIMEOUT = 180
|
6
6
|
MAX_MEMBERS = 200
|
7
7
|
|
8
|
+
class TooManyMembersError < StandardError
|
9
|
+
end
|
10
|
+
|
8
11
|
class ResponsysTimeoutError < StandardError
|
9
12
|
end
|
10
13
|
|
@@ -12,16 +15,30 @@ class Responsys
|
|
12
15
|
end
|
13
16
|
|
14
17
|
attr_reader :session_id
|
18
|
+
attr_reader :timeout_threshold
|
15
19
|
|
16
20
|
# Creates a client object to connect to Responsys via SOAP API
|
17
21
|
#
|
18
22
|
# <username> - The login username
|
19
23
|
# <password> - The login password
|
20
|
-
|
24
|
+
# <options>
|
25
|
+
# timeout_threshold - number of seconds (default 180)
|
26
|
+
def initialize(username, password, options)
|
21
27
|
@username = username
|
22
28
|
@password = password
|
23
29
|
@client = ResponsysWS.new
|
24
30
|
@keep_alive = false
|
31
|
+
|
32
|
+
self.timeout_threshold = options[:timeout_threshold] || TIMEOUT
|
33
|
+
end
|
34
|
+
|
35
|
+
def timeout_threshold=(secs)
|
36
|
+
# Sets the timeout on the internal responsys http client.
|
37
|
+
@client.options['protocol.http.connect_timeout'] = secs
|
38
|
+
@client.options['protocol.http.send_timeout'] = secs
|
39
|
+
@client.options['protocol.http.receive_timeout'] = secs
|
40
|
+
|
41
|
+
@timeout_threshold = secs
|
25
42
|
end
|
26
43
|
|
27
44
|
def login
|
@@ -29,7 +46,7 @@ class Responsys
|
|
29
46
|
login_request = Login.new
|
30
47
|
login_request.username = @username
|
31
48
|
login_request.password = @password
|
32
|
-
response = @client.login
|
49
|
+
response = @client.login(login_request)
|
33
50
|
@session_id = response.result.sessionId
|
34
51
|
assign_session
|
35
52
|
end
|
@@ -43,7 +60,7 @@ class Responsys
|
|
43
60
|
def logout
|
44
61
|
begin
|
45
62
|
logout_request = Logout.new
|
46
|
-
@client.logout
|
63
|
+
@client.logout(logout_request)
|
47
64
|
ensure
|
48
65
|
@session_id = nil
|
49
66
|
end
|
@@ -61,6 +78,8 @@ class Responsys
|
|
61
78
|
# options: {}
|
62
79
|
# }
|
63
80
|
def send_email(campaign_name, recipients)
|
81
|
+
raise TooManyMembersError if recipients.size > MAX_MEMBERS
|
82
|
+
|
64
83
|
trigger_campaign_message = TriggerCampaignMessage.new
|
65
84
|
interact_object = InteractObject.new
|
66
85
|
interact_object.folderName = 'ignored'
|
@@ -94,7 +113,7 @@ class Responsys
|
|
94
113
|
end
|
95
114
|
|
96
115
|
def with_timeout
|
97
|
-
Timeout::timeout(
|
116
|
+
Timeout::timeout(timeout_threshold, ResponsysTimeoutError) do
|
98
117
|
yield
|
99
118
|
end
|
100
119
|
end
|
data/responsys.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: responsys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mumboe-soap4r
|