ficonabses 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +10 -4
- data/lib/ficonabses/addons.rb +9 -0
- data/lib/ficonabses/base.rb +21 -3
- data/test/test_bulk.rb +20 -0
- data/test/test_localhost.rb +1 -1
- data/test/testcampaignnew.rb +35 -0
- data/test/testcampaignnewremote.rb +24 -0
- metadata +6 -3
data/README.rdoc
CHANGED
@@ -5,13 +5,13 @@
|
|
5
5
|
== REASONABLY PRODUCTION READY:
|
6
6
|
== DESCRIPTION:
|
7
7
|
|
8
|
-
A simple way to send
|
8
|
+
A simple way to send transactional notifications from your application using amazon ses, sms and apple push notifications. Register at admin.ses.sg.estormtech.com[http:admin.ses.sg.estormtech.com] to create your account. Templates can be emails, sms, or Apple Push Notifications. APNs require more configuration so please contact estormtech (info@estormtech.com) directly to implement this functionality but the same code will send either in your application.
|
9
9
|
|
10
10
|
== FEATURES/PROBLEMS:
|
11
11
|
|
12
|
-
*
|
12
|
+
* Templates for the contents of the email can be configured at admin.ses.sg.estormtech.com[http:admin.ses.sg.estormtech.com].
|
13
13
|
|
14
|
-
* You can send spontaneous emails directly in your code. Or more elegantly you can set up a template on the system and send it with contents inserted in the parameters of the call. That way you can change the template (eg have a different design for Halloween or Eid or Christmas) while not touching your production code.
|
14
|
+
* You can send spontaneous emails, sms, APNs directly in your code. Or more elegantly you can set up a template on the system and send it with contents inserted in the parameters of the call. That way you can change the template (eg have a different design for Halloween or Eid or Christmas) while not touching your production code.
|
15
15
|
|
16
16
|
== SYNOPSIS HTML EMAIL:
|
17
17
|
|
@@ -55,7 +55,7 @@ A simple way to send emails from your application using amazon ses. Register at
|
|
55
55
|
* res =FiconabSES::Addons.send_exception_direct(@account,@passwd,@destination,exception)
|
56
56
|
|
57
57
|
== CAMPAIGN FLOWS
|
58
|
-
* This allows you structure a sequence of emails/customer interaction based on parameters. (eg you could email the customer something and send them an apple push notification at the same time)
|
58
|
+
* This allows you structure a sequence of emails/customer interaction based on parameters. (eg you could email the customer something and send them an apple push notification at the same time) (CAVEAT - as destination can be modified during the campaign flow we insert automatically destination into the options hash array. This should have no impact on your code. You can for example, change the destination to another parameter in the campaign flow). The campaign flows can include time delays between sending emails or sms. (Eg week1 welcome to the system, week2, did you know that etc.)
|
59
59
|
|
60
60
|
* Exactly the same calling sequence as for templates.
|
61
61
|
f=FiconabSES::Base.new
|
@@ -64,6 +64,12 @@ A simple way to send emails from your application using amazon ses. Register at
|
|
64
64
|
f.set_credentials(@account,@passwd)
|
65
65
|
res =@f.send_campaign_flow(@destination,'testcampaign',options)
|
66
66
|
|
67
|
+
== BULK DATA
|
68
|
+
* Send a bulk data file for processing the same template
|
69
|
+
* Similar to templates:
|
70
|
+
bulkdata={'xmllist' => "<destinations><destination address='scott.sproule@gmail.com' sendtime='12:00'></destination><destination address='scott.sproule@estormtech.com' sendtime='12:00'></destination></destinations>", "template"=>"expiring_trial"}
|
71
|
+
res= FiconabSES::Addons.send_bulk(@f,bulkdata)
|
72
|
+
|
67
73
|
|
68
74
|
|
69
75
|
==BINARY FILES
|
data/lib/ficonabses/addons.rb
CHANGED
@@ -5,6 +5,15 @@ module FiconabSES
|
|
5
5
|
f.set_credentials(account,password)
|
6
6
|
FiconabSES::Addons.send_ruby_exception(f,exception,destination,nil)
|
7
7
|
end
|
8
|
+
def self.send_bulk_direct(account,password,bulkdata)
|
9
|
+
f=FiconabSES::Base.new
|
10
|
+
f.set_credentials(account,password)
|
11
|
+
FiconabSES::Addons.send_bulk(f,bulkdata)
|
12
|
+
end
|
13
|
+
def self.send_bulk(ficonab_obj,bulkdata)
|
14
|
+
puts "BULK DATA is #{bulkdata}"
|
15
|
+
res =ficonab_obj.send_bulk(bulkdata)
|
16
|
+
end
|
8
17
|
def self.readfile(filename)
|
9
18
|
csvfile=File.open(filename,'r')
|
10
19
|
rawfile= FasterCSV.parse(csvfile.read, { :headers => true})
|
data/lib/ficonabses/base.rb
CHANGED
@@ -71,7 +71,13 @@ module FiconabSES
|
|
71
71
|
end
|
72
72
|
@clnt
|
73
73
|
end
|
74
|
-
def
|
74
|
+
def client_action(postflag,postdata)
|
75
|
+
puts "FLAG: #{postflag} DATA: #{postdata}"
|
76
|
+
result=self.clnt.get_content(self.uri,self.extheader) if !postflag
|
77
|
+
result = self.clnt.post_content(self.uri, postdata,{'Content-Type' => 'application/x-www-form-urlencoded'}) if postflag
|
78
|
+
result
|
79
|
+
end
|
80
|
+
def perform(url,postflag=false,postdata={})
|
75
81
|
@uri=URI.parse(url)
|
76
82
|
# puts "url is #{url}"
|
77
83
|
raise 'credentials not set' if @account==nil
|
@@ -80,7 +86,8 @@ module FiconabSES
|
|
80
86
|
# Don't take longer than 60 seconds -- incase there is a problem with our server continue
|
81
87
|
@clnt=self.build_client
|
82
88
|
Timeout::timeout(60) do
|
83
|
-
|
89
|
+
# original res=self.clnt.get_content(self.uri,self.extheader)
|
90
|
+
res=self.client_action(postflag,postdata)
|
84
91
|
end
|
85
92
|
rescue Timeout::Error,HTTPClient::BadResponseError
|
86
93
|
|
@@ -89,7 +96,8 @@ module FiconabSES
|
|
89
96
|
puts "BAD RESPONSE or Timeout - retrying once #{self.uri} after five seconds"
|
90
97
|
sleep(5) # take a break to see if it is too busy
|
91
98
|
Timeout::timeout(25) do
|
92
|
-
|
99
|
+
# original res=self.clnt.get_content(self.uri,self.extheader)
|
100
|
+
res=self.client_action(postflag,postdata)
|
93
101
|
puts "RETRY: second chance res is #{res}"
|
94
102
|
end
|
95
103
|
# bad response - try it again?
|
@@ -109,6 +117,11 @@ module FiconabSES
|
|
109
117
|
url="#{self.action_url('ficonabsendemail',destination)}&subject=#{URI.encode(subject)}&text=#{URI.encode(contents)}"
|
110
118
|
url
|
111
119
|
end
|
120
|
+
def bulk_url
|
121
|
+
url="http://#{@@host}/ficonabbulkmanager?"
|
122
|
+
puts "BULK URL: #{url}"
|
123
|
+
url
|
124
|
+
end
|
112
125
|
def global_blacklist_url(destination,username)
|
113
126
|
url="#{self.action_url('ficonabaction',destination)}&type=globalunsubscribe&user=#{URI.encode(username)}"
|
114
127
|
url
|
@@ -139,6 +152,11 @@ module FiconabSES
|
|
139
152
|
perform(url)
|
140
153
|
# res
|
141
154
|
end
|
155
|
+
def send_bulk(bulkdata)
|
156
|
+
url=self.bulk_url
|
157
|
+
perform(url,true,bulkdata)
|
158
|
+
# res
|
159
|
+
end
|
142
160
|
def send_template(destination,templatename)
|
143
161
|
url=self.template_url(destination,templatename)
|
144
162
|
# puts "url is: #{url}"
|
data/test/test_bulk.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestFiconabses < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@f=FiconabSES::Base.new
|
7
|
+
@f.set_credentials('scott','scott123')
|
8
|
+
# @f.set_debug
|
9
|
+
@destination='scott.sproule@gmail.com'
|
10
|
+
@tsipid ='7923044488'
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_bulk
|
14
|
+
# bulkdata="xmllist=<destinations><destination address='scott.sproule@gmail.com' sendtime='12:00'></destination><destination address='scott.sproule@estormtech.com' sendtime='12:00'></destination></destinations>&template=expiring_trial"
|
15
|
+
bulkdata={'xmllist' => "<destinations><destination address='scott.sproule@gmail.com' sendtime='12:00'></destination><destination address='scott.sproule@estormtech.com' sendtime='12:00'></destination></destinations>", "template"=>"expiring_trial"}
|
16
|
+
res= FiconabSES::Addons.send_bulk(@f,bulkdata)
|
17
|
+
puts "RES is #{res}"
|
18
|
+
assert res.include? '200'
|
19
|
+
end
|
20
|
+
end
|
data/test/test_localhost.rb
CHANGED
@@ -65,7 +65,7 @@ class TestFiconabses < Test::Unit::TestCase
|
|
65
65
|
options={}
|
66
66
|
options['hello']='TESTING'
|
67
67
|
options['bcinfo']='+6590683565'
|
68
|
-
res =@f.send_campaign_flow(@destination,'
|
68
|
+
res =@f.send_campaign_flow(@destination,'testthreeminutes',options) #no text portion
|
69
69
|
puts "RES is: #{res}"
|
70
70
|
assert res.include? '200'
|
71
71
|
assert false==(res.include? 'Error')
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestFiconabses < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@f=FiconabSES::Base.new
|
7
|
+
@f.set_credentials('scott','scott123')
|
8
|
+
@f.set_debug
|
9
|
+
@destination='scott.sproule@gmail.com'
|
10
|
+
@tsipid ='7923044488'
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_local_campaign_flownew
|
14
|
+
options={}
|
15
|
+
options['hello']='TESTING'
|
16
|
+
options['bcinfo']='+6590683565'
|
17
|
+
res =@f.send_campaign_flow(@destination,'testthreeminutes',options) #no text portion
|
18
|
+
puts "RES is: #{res}"
|
19
|
+
assert res.include? '200'
|
20
|
+
assert false==(res.include? 'Error')
|
21
|
+
|
22
|
+
end
|
23
|
+
def test_local_sendtime_tempate
|
24
|
+
options={'sendtime' => "18:00"}
|
25
|
+
options['hello']='TESTING'
|
26
|
+
options['bcinfo']='+6590683565'
|
27
|
+
res =@f.send_template_params(@destination,'expiring_trial',options) #no text portion
|
28
|
+
puts "RES is: #{res}"
|
29
|
+
assert res.include? '200'
|
30
|
+
assert false==(res.include? 'Error')
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
|
3
|
+
class TestFiconabses < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@f=FiconabSES::Base.new
|
7
|
+
@f.set_credentials('scott','scott123')
|
8
|
+
@destination='scott.sproule@gmail.com'
|
9
|
+
@tsipid ='7923044488'
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_local_campaign_flownew
|
13
|
+
options={}
|
14
|
+
options['hello']='TESTING'
|
15
|
+
options['bcinfo']='+6590683565'
|
16
|
+
res =@f.send_campaign_flow(@destination,'testthreeminutes',options) #no text portion
|
17
|
+
puts "RES is: #{res}"
|
18
|
+
assert res.include? '200'
|
19
|
+
assert false==(res.include? 'Error')
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 1
|
9
|
+
version: 0.4.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Scott Sproule
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-06
|
17
|
+
date: 2012-07-06 00:00:00 +08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- lib/ficonabses/base.rb
|
35
35
|
- lib/ficonabses/support.rb
|
36
36
|
- lib/ficonabses.rb
|
37
|
+
- test/test_bulk.rb
|
37
38
|
- test/test_ficonabses.rb
|
38
39
|
- test/test_hashparams.rb
|
39
40
|
- test/test_helper.rb
|
@@ -43,6 +44,8 @@ files:
|
|
43
44
|
- test/test_smartroam.rb
|
44
45
|
- test/test_smartroam2.rb
|
45
46
|
- test/test_templates.rb
|
47
|
+
- test/testcampaignnew.rb
|
48
|
+
- test/testcampaignnewremote.rb
|
46
49
|
- bin/ficonabses_blacklist.rb
|
47
50
|
- bin/ficonabses_campaign_flow_test.rb
|
48
51
|
- bin/ficonabses_csv.rb
|