jangosmtp 0.1.2 → 0.1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/jangosmtp.gemspec +2 -2
- data/lib/jangosmtp.rb +14 -13
- data/lib/jangosmtp/version.rb +1 -1
- metadata +7 -7
data/jangosmtp.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |gem|
|
|
7
7
|
gem.description = %q{Library for interfacing with JangoSMTP}
|
8
8
|
gem.summary = %q{Will encapsulate all the necessary api calls into an easy to use gem.}
|
9
9
|
gem.homepage = "https://github.com/jbrennon/jangosmtp"
|
10
|
-
|
11
|
-
gem.add_dependency 'mechanize'
|
10
|
+
|
11
|
+
gem.add_dependency 'mechanize', '~> 2.3'
|
12
12
|
|
13
13
|
gem.files = `git ls-files`.split($\)
|
14
14
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
data/lib/jangosmtp.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'jangosmtp/version'
|
2
|
+
require 'mechanize'
|
2
3
|
|
3
4
|
module Jangosmtp
|
4
|
-
|
5
|
+
|
5
6
|
class << self
|
6
7
|
attr_accessor :username, :password, :max_attempts, :click_tracking, :open_tracking, :auto_generate_plain
|
7
8
|
BASE_URL = 'http://api.jangomail.com/api.asmx/'
|
8
|
-
|
9
|
+
|
9
10
|
def options( hash )
|
10
11
|
@username = hash[:username] if !hash[:username].nil?
|
11
12
|
@password = hash[:password] if !hash[:password].nil?
|
@@ -14,7 +15,7 @@ module Jangosmtp
|
|
14
15
|
@open_tracking = hash[:open_tracking] ||= true
|
15
16
|
@auto_generate_plain = hash[:open_tracking] ||= true
|
16
17
|
end
|
17
|
-
|
18
|
+
|
18
19
|
# Get a group if the group exists, otherwise create a group using a group name and return it's id
|
19
20
|
# group_name: group name that the user wants to get the id for, should only contain alphanumeric ( and spaces )
|
20
21
|
# will be cleaned if an incorrect name is used
|
@@ -27,7 +28,7 @@ module Jangosmtp
|
|
27
28
|
end
|
28
29
|
return existing_group_id
|
29
30
|
end
|
30
|
-
|
31
|
+
|
31
32
|
# Get the id of a requested group
|
32
33
|
# group_name: group name that the user wants to get the id for, should only contain alphanumeric ( and spaces )
|
33
34
|
# will be cleaned if an incorrect name is used
|
@@ -40,7 +41,7 @@ module Jangosmtp
|
|
40
41
|
'Password' => @password,
|
41
42
|
'GroupName' => group_name
|
42
43
|
}
|
43
|
-
|
44
|
+
|
44
45
|
# First we are going to check the existing groups to make sure that the current group doesn't already exist.
|
45
46
|
found_group = false
|
46
47
|
existing_group_id = nil
|
@@ -49,10 +50,10 @@ module Jangosmtp
|
|
49
50
|
existing_group_id = Nokogiri::XML.parse(response.body).xpath("*").first.content.split("\n")[2]
|
50
51
|
found_group = true
|
51
52
|
end
|
52
|
-
|
53
|
+
|
53
54
|
return existing_group_id
|
54
55
|
end
|
55
|
-
|
56
|
+
|
56
57
|
# Create a group and return the successfull value
|
57
58
|
# group_name: group name that the user wants to get the id for, should only contain alphanumeric ( and spaces )
|
58
59
|
# will be cleaned if an incorrect name is used
|
@@ -65,14 +66,14 @@ module Jangosmtp
|
|
65
66
|
'Password' => @password,
|
66
67
|
'GroupName' => group_name
|
67
68
|
}
|
68
|
-
|
69
|
+
|
69
70
|
response = post_with_attempts( 'AddTransactionalGroup', options )
|
70
71
|
if response != false
|
71
72
|
new_group_id = Nokogiri::XML.parse(response.body).xpath("*").first.content.split("\n")[2]
|
72
73
|
end
|
73
74
|
return new_group_id
|
74
75
|
end
|
75
|
-
|
76
|
+
|
76
77
|
# Send an email and get/create a requested group
|
77
78
|
# group_name: group name that the user wants the email to be applied to, should only contain alphanumeric
|
78
79
|
# ( and spaces ) will be cleaned if an incorrect name is used
|
@@ -93,7 +94,7 @@ module Jangosmtp
|
|
93
94
|
return send_email_with_group_id( group_id, subject, to_email, from_email, from_name, html )
|
94
95
|
end
|
95
96
|
end
|
96
|
-
|
97
|
+
|
97
98
|
# Send an email using a pre-existing group
|
98
99
|
# group_id: the id of the group that this email will be applied to
|
99
100
|
# subject: the subject of the email to be sent
|
@@ -116,7 +117,7 @@ module Jangosmtp
|
|
116
117
|
}
|
117
118
|
return post_with_attempts( 'SendTransactionalEmail', options )
|
118
119
|
end
|
119
|
-
|
120
|
+
|
120
121
|
private
|
121
122
|
# Will verify that the username and password exist for each request
|
122
123
|
def check_user_pass
|
@@ -124,7 +125,7 @@ module Jangosmtp
|
|
124
125
|
raise 'Jangosmtp username and password are required'
|
125
126
|
end
|
126
127
|
end
|
127
|
-
|
128
|
+
|
128
129
|
# Will attempt to post to the jangosmtp action requested using the options hash passed in
|
129
130
|
def post_with_attempts( action, options )
|
130
131
|
agent = Mechanize.new
|
@@ -143,7 +144,7 @@ module Jangosmtp
|
|
143
144
|
end
|
144
145
|
return response
|
145
146
|
end
|
146
|
-
|
147
|
+
|
147
148
|
# Get either the Rails logger or the a logger to STDOUT
|
148
149
|
def logger
|
149
150
|
if !Rails.nil?
|
data/lib/jangosmtp/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jangosmtp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.2
|
4
|
+
version: 0.1.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mechanize
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '2.3'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '2.3'
|
30
30
|
description: Library for interfacing with JangoSMTP
|
31
31
|
email:
|
32
32
|
- brennon@fritzandandre.com
|
@@ -62,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
62
|
version: '0'
|
63
63
|
requirements: []
|
64
64
|
rubyforge_project:
|
65
|
-
rubygems_version: 1.8.
|
65
|
+
rubygems_version: 1.8.24
|
66
66
|
signing_key:
|
67
67
|
specification_version: 3
|
68
68
|
summary: Will encapsulate all the necessary api calls into an easy to use gem.
|