alphamail 1.0.5.pre → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -0,0 +1,10 @@
1
+ Copyright (c) 2012, Comfirm AB
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
+
6
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+ * Neither the name of the Comfirm AB nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9
+
10
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.rdoc CHANGED
@@ -5,7 +5,7 @@
5
5
  This gem is the official client library for sending transactional emails with the cloud service AlphaMail.
6
6
  To use this service you need an account. You can sign up for an free account on our website (http://www.comfirm.se).
7
7
 
8
- This is not an service for sending SPAM, news letter or bulk emails of any kind. This is for transactional emails exclusive. Read more about transactional emails on http://www.comfirm.se.
8
+ This is not a service for sending SPAM, news letter or bulk emails of any kind. This is for transactional emails exclusive. Read more about transactional emails on http://www.comfirm.se.
9
9
 
10
10
  == Installation
11
11
 
@@ -101,9 +101,7 @@ Jack Engqvist Johansson <mailto:jack.johansson@comfirm.se>
101
101
 
102
102
  == License
103
103
 
104
- Ruby License, see the COPYING file included in the source distribution. The
105
- Ruby License includes the GNU General Public License (GPL), Version 2, so see
106
- the file GPL as well.
104
+ BSD 3-clause, see the LICENSE file included in the source distribution.
107
105
 
108
106
  == Download
109
107
 
data/lib/alphamail.rb CHANGED
@@ -1,4 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
+ # Copyright (c) 2012, Comfirm AB
3
+ # All rights reserved.
4
+
5
+ # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
+
7
+ # * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8
+ # * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+ # * Neither the name of the Comfirm AB nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+
11
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12
+
2
13
  require 'rubygems'
3
14
  require 'uri'
4
15
  require 'net/http'
@@ -10,7 +21,7 @@ module AlphaMail
10
21
  attr_accessor :name
11
22
  attr_accessor :email
12
23
 
13
- def initialize(name = "Undefined", email = "")
24
+ def initialize(name = '', email = '')
14
25
  @name = name
15
26
  @email = email
16
27
  end
@@ -51,17 +62,18 @@ module AlphaMail
51
62
  end
52
63
  end
53
64
 
65
+ # Response class
54
66
  class Result
55
67
  attr_accessor :error_code
56
68
  attr_accessor :message
57
69
 
58
- def initialize(error_code = 0, message = '')
70
+ def initialize(error_code = -1, message = 'Unknow error')
59
71
  @error_code = error_code
60
72
  @message = message
61
73
  end
62
74
  end
63
75
 
64
- # Alpha-mail email service
76
+ # AlphaMail email service
65
77
  class EmailService
66
78
  def initialize(service_url, api_token)
67
79
  @service_url = service_url + '/email/queue'
@@ -88,7 +100,7 @@ module AlphaMail
88
100
  am_res = JSON.parse(res.body)
89
101
  return Result.new(am_res['error_code'], am_res['message'])
90
102
  end
91
- return Result.new(-1, 'Unknown error')
103
+ return Result.new
92
104
  end
93
105
  end
94
106
  end
@@ -1,6 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright (c) 2012, Comfirm AB
3
+ # All rights reserved.
4
+
5
+ # Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
+
7
+ # * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8
+ # * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
+ # * Neither the name of the Comfirm AB nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+
11
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12
+
1
13
  require 'rubygems'
2
14
  require 'alphamail'
3
15
 
16
+ # In this demo we are going to send name and password to a newly registered member.
17
+ # The easiest way is to create a class with the data we want to send to AlphaMail.
18
+ # AlphaMail will then run your template along with the received object (myMember).
19
+
20
+ # The class for the new member, could also be a customer, order, cart, forgotten password etc.
4
21
  class NewMember
5
22
  attr_accessor :name
6
23
  attr_accessor :password
@@ -20,37 +37,50 @@ class NewMember
20
37
  end
21
38
 
22
39
  # Demo 1 --------------------------------------------------
40
+ # Lets send an email!
41
+ # ---------------------------------------------------------
23
42
 
24
43
  # The email content (in this case, member info)
25
44
  myMember = NewMember.new('Ruby Diamond Ruben', 'my3Passw0rd89')
26
45
 
27
- # The payload
46
+ # The payload, our new member along with some other things
28
47
  myPayload = AlphaMail::MessagePayload.new
29
48
 
30
49
  # Set payload fields
31
- myPayload.project_id = 139
32
- myPayload.receiver_id = 1
33
- myPayload.sender.name = 'Jack Sender'
34
- myPayload.sender.email = 'jack@example.com'
35
- myPayload.receiver.name = 'John Doe'
36
- myPayload.receiver.email = 'john.doe@example.com'
37
- myPayload.body = myMember
50
+ myPayload.project_id = 139 # Project ID
51
+ myPayload.receiver_id = 1 # Receiver ID
52
+ myPayload.sender.name = 'Jack Sender' # Sender name
53
+ myPayload.sender.email = 'jack@example.com' # Sender email
54
+ myPayload.receiver.name = 'John Doe' # Receiver name
55
+ myPayload.receiver.email = 'john.doe@example.com' # Receiver email
38
56
 
57
+ # Set the body (our new member)
58
+ myPayload.body = myMember # The content of out email, our new member
59
+
60
+ # Create and setup a new email service
61
+ # Replace YOUR-TOKEN-HERE with your own token. You can create tokens in Dashboard
39
62
  myService = AlphaMail::EmailService.new 'http://api.am1.comfirm.se/v1', 'YOUR-TOKEN-HERE'
63
+
64
+ # Now, the fun part, sending it!
40
65
  am_res = myService.queue(myPayload)
41
- puts "#{am_res.error_code} #{am_res.message}"
42
66
 
67
+ # Your result will be stored in an AlphaMail::Result object
68
+ puts "#{am_res.error_code} #{am_res.message}"
43
69
 
44
- # Demo 2 ---------------------
45
70
 
46
- # The payload
47
- am_res = myService.queue(AlphaMail::MessagePayload.new(
71
+ # Demo 2 --------------------------------------------------
72
+ # Shorthand: All the code above can be written in a shorter way.
73
+ # ---------------------------------------------------------
74
+ service_url = 'http://api.am1.comfirm.se/v1'
75
+ myToken = 'YOUR-TOKEN-HERE'
76
+ am_res = AlphaMail::EmailService.new(service_url, myToken).queue(AlphaMail::MessagePayload.new(
48
77
  139, # Project ID
49
- 2, # Sender ID
78
+ 2, # Receiver ID
50
79
  AlphaMail::Contact.new('Jack Sender', 'jack@example.com'), # Sender
51
80
  AlphaMail::Contact.new('John Doe', 'john.doe@example.com'), # Receiver
52
- NewMember.new('John Doe', 'wh4tswhAt') # Body object
81
+ NewMember.new('newmember', 'p4sSw0rd') # Body object
53
82
  ))
83
+ # Print
54
84
  puts "#{am_res.error_code} #{am_res.message}"
55
85
 
56
86
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alphamail
3
3
  version: !ruby/object:Gem::Version
4
- hash: 961915968
5
- prerelease: true
4
+ hash: 29
5
+ prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
9
  - 5
10
- - pre
11
- version: 1.0.5.pre
10
+ version: 1.0.5
12
11
  platform: ruby
13
12
  authors:
14
13
  - Jack Engqvist Johansson
@@ -36,7 +35,7 @@ dependencies:
36
35
  version: 1.6.3
37
36
  type: :runtime
38
37
  version_requirements: *id001
39
- description: The official gem for sending transactional emails via Comfirm's AlphaMail service
38
+ description: The official gem for sending transactional emails via Comfirm's cloud service AlphaMail
40
39
  email:
41
40
  - jack.johansson@comfirm.se
42
41
  executables: []
@@ -47,15 +46,15 @@ extra_rdoc_files: []
47
46
 
48
47
  files:
49
48
  - lib/alphamail.rb
50
- - Rakefile
51
49
  - LICENSE
50
+ - Rakefile
52
51
  - CHANGELOG
53
52
  - README.rdoc
54
53
  - spec/alphamail_test.rb
55
54
  has_rdoc: true
56
55
  homepage: http://www.comfirm.se
57
56
  licenses:
58
- - MIT
57
+ - BSD 3-clause
59
58
  post_install_message: Thanks for using AlphaMail. Visit http://www.comfirm.se for help, articles and news about transactional emails.
60
59
  rdoc_options: []
61
60
 
@@ -88,6 +87,6 @@ rubyforge_project:
88
87
  rubygems_version: 1.3.7
89
88
  signing_key:
90
89
  specification_version: 3
91
- summary: Send transactional emails via AlphaMail
90
+ summary: Send transactional emails via the AlphaMail cloud service
92
91
  test_files: []
93
92