ficonabses 0.2.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -57,6 +57,10 @@ A simple way to send emails from your application using amazon ses. Register at
57
57
  == CAMPAIGN FLOWS
58
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)
59
59
 
60
+ ==BINARY FILES
61
+ * ficonabses_template_test.rb - Send a template to a destination. Type 'ficonabses_template_test.rb --help' in a terminal on your cmpueter for more information
62
+ * fionabses_csv.rb - Send the contents of csv file to the system. The file should be in destination,templatename,param1,params2 format with headers.
63
+
60
64
 
61
65
  == REQUIREMENTS:
62
66
 
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/ruby
2
+ usage=<<EOF_USAGE
3
+
4
+ # == Synopsis
5
+ # read a csv file and send through FiconabSES
6
+ # == Usage
7
+ # ficonabses_csv.rb -u username -p password -f csvfile.name
8
+ # csv file needs to be in the format (including headers) with destination, template, asmanyparameters as needed separated by commas
9
+ # == Author
10
+ # Scott Sproule --- Ficonab.com (scott.sproule@ficonab.com)
11
+ # == Example
12
+ # ficonabses_csv.rb -u xxxx -p yyyy -f yyy.csv
13
+ # == Copyright
14
+ # Copyright (c) 2011 Ficonab Pte. Ltd.
15
+ # See license for license details
16
+ EOF_USAGE
17
+ require 'yaml'
18
+ require 'rubygems'
19
+ require 'uri'
20
+ gem 'ficonabses'
21
+ gem 'fastercsv'
22
+ require 'fastercsv'
23
+ require 'ficonabses'
24
+ require 'optparse'
25
+ #require 'java' if RUBY_PLATFORM =~ /java/
26
+ # start the processing
27
+ def send_row(ficonab,row)
28
+ row['destination'].strip!
29
+ row['template'].strip!
30
+ sleep(1)
31
+ res =ficonab.send_template_params(row['destination'],row['template'],row) if row['row']!=''
32
+
33
+ end
34
+
35
+ def readfile(filename)
36
+ csvfile=File.open(filename,'r')
37
+ rawfile= FasterCSV.parse(csvfile.read, { :headers => true})
38
+ rawfile
39
+ end
40
+ arg_hash=FiconabSES::Options.parse_options(ARGV)
41
+ FiconabSES::Options.show_usage_exit(usage) if arg_hash[:help]==true
42
+
43
+ require 'pp'
44
+ options=arg_hash
45
+ puts "[#{Time.now}] START"
46
+ @f=FiconabSES::Base.new
47
+ @f.set_credentials(options[:username],options[:password])
48
+ @f.set_debug if options[:debug] # if debug sends to localhost
49
+ count=0
50
+ #send_template(options[:template],'7923044488','scott.sproule@gmail.com',count+=1)
51
+ rows=readfile(options[:filename])
52
+ rows.each {|row|
53
+ #puts "row is: #{row}"
54
+ begin
55
+ hash={}
56
+ hash=hash.merge row
57
+ res=send_row(@f,hash)
58
+ puts "COUNT: #{count} result: #{res} row: #{hash} "
59
+ count+=1
60
+
61
+ rescue Exception => e
62
+ puts "Found count: #{count} error #{e.inspect}"
63
+ end
64
+ }
65
+
66
+
67
+ # puts "response is list is #{list.to_yaml} #{finallist.to_yaml}"
68
+ puts "[#{Time.now}] FINISHED: sending: #{count}"
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/ruby
2
+ usage=<<EOF_USAGE
3
+
4
+ # == Synopsis
5
+ # send a template using FiconabSES
6
+ # == Usage
7
+ # ficonabses_template_test.rb -u username -p password -d destination -t template_name
8
+ # == Author
9
+ # Scott Sproule --- Ficonab.com (scott.sproule@ficonab.com)
10
+ # == Example
11
+ # ficonabses_template_test.rb -u xxxx -p yyyy -t testtestmplate -d xxxxe@estormtech.com
12
+ # == Copyright
13
+ # Copyright (c) 2011 Ficonab Pte. Ltd.
14
+ # See license for license details
15
+ EOF_USAGE
16
+ require 'yaml'
17
+ require 'rubygems'
18
+ require 'uri'
19
+ gem 'ficonabses'
20
+ gem 'fastercsv'
21
+ require 'fastercsv'
22
+ require 'ficonabses'
23
+ require 'optparse'
24
+ #require 'java' if RUBY_PLATFORM =~ /java/
25
+ # start the processing
26
+ arg_hash=FiconabSES::Options.parse_options(ARGV)
27
+ FiconabSES::Options.show_usage_exit(usage) if arg_hash[:help]==true
28
+ require 'pp'
29
+ options=arg_hash
30
+ puts "[#{Time.now}] START"
31
+ @f=FiconabSES::Base.new
32
+ @f.set_credentials(options[:username],options[:password])
33
+ @f.set_debug if options[:debug] # if debug sends to localhost
34
+ res =@f.send_template_params(options[:destination],options[:template],{})
35
+
36
+ # puts "response is list is #{list.to_yaml} #{finallist.to_yaml}"
37
+ puts "[#{Time.now}] FINISHED: result is: #{res}"
@@ -0,0 +1,47 @@
1
+ require 'optparse'
2
+
3
+
4
+ module FiconabSES
5
+ class Options
6
+ def self.parse_options(params)
7
+ opts = OptionParser.new
8
+ # puts "argv are #{params}"
9
+ temp_hash = {}
10
+ opts.on("-u","--username VAL", String) {|val| temp_hash[:username] = val
11
+ puts "# username is #{val}" }
12
+
13
+ # opts.on("-h","--host VAL", String) {|val| temp_hash[:host] = val
14
+ # puts "# host is #{val}" }
15
+ opts.on("-d","--destination VAL", String) {|val| temp_hash[:destination] = val
16
+ puts "# email is #{temp_hash[:destination]}" }
17
+ opts.on("-p","--password VAL", String) {|val| temp_hash[:password] = val
18
+ puts "# password is #{temp_hash[:password]}" }
19
+
20
+ opts.on("-f","--filename VAL", String) {|val| temp_hash[:filename] = val
21
+ puts "# filename is #{temp_hash[:filename]}" }
22
+ # opts.on("-s","--start VAL", Integer) {|val| temp_hash[:start] = val
23
+ # puts "# start mapping is #{temp_hash[:start]}" }
24
+ opts.on("-D","--debug", "turn on debug") { |val| temp_hash[:debug ] = true }
25
+
26
+ opts.on("-t","--template VAL", String) { |val| temp_hash[:template] = val
27
+ puts "# tsipid key #{temp_hash[:template]}" }
28
+
29
+
30
+ opts.on_tail("-H","--help", "get help message") { |val| temp_hash[:help ] = true
31
+ puts opts }
32
+
33
+ opts.parse(params)
34
+ # puts " in HTTP #{hostname} port #{port} url: #{url}"
35
+
36
+ return temp_hash
37
+
38
+ end # parse options
39
+ def self.show_usage_exit(usage)
40
+ # usage=usage.gsub(/^\s*#/,'')
41
+ puts usage
42
+ exit
43
+ end
44
+ end #class
45
+ # help build xml commands from messages
46
+
47
+ end #module
@@ -10,7 +10,7 @@ class TestFiconabses < Test::Unit::TestCase
10
10
  end
11
11
 
12
12
  def test_smartroam_account_info
13
- res =@f.send_template_params(@destination,'account_info_chattime',{'mgm_link'=>'testing'}) #no text portion
13
+ res =@f.send_template_params(@destination,'account_info_chattime_us',{'mgm_link'=>'testing'}) #no text portion
14
14
  puts "RES is: #{res}"
15
15
  assert res.include? '200'
16
16
  assert false==(res.include? 'Error')
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 2
9
- version: 0.2.2
8
+ - 4
9
+ version: 0.2.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Scott Sproule
@@ -14,14 +14,15 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2012-02-16 00:00:00 +08:00
17
+ date: 2012-02-18 00:00:00 +08:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
21
21
  description: Simple way to send emails from your application.
22
22
  email: scott.sproule@estormtech.com
23
- executables: []
24
-
23
+ executables:
24
+ - ficonabses_template_test.rb
25
+ - ficonabses_csv.rb
25
26
  extensions: []
26
27
 
27
28
  extra_rdoc_files: []
@@ -29,6 +30,7 @@ extra_rdoc_files: []
29
30
  files:
30
31
  - lib/ficonabses/addons.rb
31
32
  - lib/ficonabses/base.rb
33
+ - lib/ficonabses/support.rb
32
34
  - lib/ficonabses.rb
33
35
  - test/test_ficonabses.rb
34
36
  - test/test_hashparams.rb
@@ -39,6 +41,7 @@ files:
39
41
  - test/test_smartroam.rb
40
42
  - test/test_smartroam2.rb
41
43
  - test/test_templates.rb
44
+ - bin/ficonabses_csv.rb
42
45
  - bin/ficonabses_template_test.rb
43
46
  - History.txt
44
47
  - Manifest.txt