mad_mimi_two 0.5.7 → 0.5.8
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/History.txt +7 -0
- data/README.rdoc +4 -0
- data/lib/mad_mimi_two/mad_mimi_mailer.rb +27 -8
- data/test/test_mad_mimi_two.rb +8 -0
- metadata +3 -3
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -102,7 +102,11 @@ send_mimi.rb -e xxxx@ficonab.com -p new_crm -k 'keyvalue' -u xxxx@yyyy.com -s te
|
|
102
102
|
warning: peer certificate won't be verified in this SSL session
|
103
103
|
1282604803 # this is the return value from mad mimi
|
104
104
|
|
105
|
+
== Get promotion list
|
106
|
+
t=MadMimiTwo::MadMimiMessage.new
|
107
|
+
r=t.get_promotions()
|
105
108
|
|
109
|
+
returns a hash of promotions on your account
|
106
110
|
|
107
111
|
== LICENSE:
|
108
112
|
|
@@ -2,6 +2,8 @@ require 'cgi'
|
|
2
2
|
require 'rubygems'
|
3
3
|
gem 'httpclient'
|
4
4
|
require 'httpclient'
|
5
|
+
gem 'nokogiri'
|
6
|
+
require 'nokogiri'
|
5
7
|
class Hash
|
6
8
|
def madmimiurlencode
|
7
9
|
to_a.map do |name_value|
|
@@ -11,21 +13,38 @@ class Hash
|
|
11
13
|
end
|
12
14
|
module MadMimiTwo
|
13
15
|
module MadMimiMailer
|
14
|
-
|
16
|
+
API_URL = 'https://api.madmimi.com/'
|
17
|
+
SINGLE_SEND_URL = "#{API_URL}mailer"
|
15
18
|
|
16
19
|
def self.included(base)
|
17
20
|
base.extend(ClassMethods)
|
18
21
|
end
|
22
|
+
def send_cmd(url)
|
23
|
+
begin
|
24
|
+
client= HTTPClient.new
|
25
|
+
res=client.get_content(url)
|
26
|
+
rescue HTTPClient::BadResponseError
|
27
|
+
res="problem retrieving status"
|
28
|
+
end
|
29
|
+
res
|
30
|
+
end
|
31
|
+
def get_promotions_xml
|
32
|
+
url="#{API_URL}promotions.xml?#{MadMimiTwo::MadMimiMessage.api_settings.madmimiurlencode}"
|
33
|
+
xml_list=send_cmd(url)
|
34
|
+
end
|
35
|
+
def get_promotions
|
36
|
+
xml_list=get_promotions_xml
|
37
|
+
res={}
|
38
|
+
reader = Nokogiri::XML::Reader(xml_list)
|
39
|
+
reader.each do |node|
|
40
|
+
res=res.merge({ node.attribute('name') => node.attribute('name') }) if node.name=='promotion' # eventually will want hash
|
41
|
+
end
|
42
|
+
res
|
43
|
+
end
|
19
44
|
# check the status of a sent email
|
20
45
|
def check_status(msg_id)
|
21
46
|
url = "#{SINGLE_SEND_URL}s/status/#{msg_id}?#{MadMimiTwo::MadMimiMessage.api_settings.madmimiurlencode}"
|
22
|
-
|
23
|
-
client= HTTPClient.new
|
24
|
-
res=client.get_content(url)
|
25
|
-
rescue HTTPClient::BadResponseError
|
26
|
-
res="problem retrieving status"
|
27
|
-
end
|
28
|
-
res
|
47
|
+
send_cmd(url)
|
29
48
|
end
|
30
49
|
|
31
50
|
# Custom Mailer attributes
|
data/test/test_mad_mimi_two.rb
CHANGED
@@ -85,4 +85,12 @@ class TestMadMimiTwo < Test::Unit::TestCase
|
|
85
85
|
assert r=='sent', "message response not correct: #{r}"
|
86
86
|
|
87
87
|
end
|
88
|
+
def test_get_promotions
|
89
|
+
t=MadMimiTwo::MadMimiMessage.new
|
90
|
+
r=t.get_promotions()
|
91
|
+
puts "'r is ' #{r}"
|
92
|
+
assert r.class==Hash, "response is not Hash r is: #{r} #{r.class}"
|
93
|
+
assert r.key?('new_CRM'), "does not include new_CRM #{r}" #this MAY NOT BE IN YOUR promotions list
|
94
|
+
|
95
|
+
end
|
88
96
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mad_mimi_two
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 8
|
10
|
+
version: 0.5.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- scott sproule
|