messagebus_ruby_api 3.0.6 → 3.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -190,10 +190,11 @@ module MessagebusApi
190
190
  time.strftime("%Y-%m-%dT%H:%M:%SZ")
191
191
  end
192
192
 
193
- #used by ActionMailer
194
- def deliver!(message)
195
- #minimum required headers
193
+ def deliver(message)
194
+ deliver!(message)
195
+ end
196
196
 
197
+ def deliver!(message)
197
198
  if message.to.first.nil? ||message.subject.nil? || message.from.first.nil? then
198
199
  raise "Messagebus API error=Missing required header: :toEmail => #{message.to.first} :subject => #{message.subject} :fromEmail => #{message.from.first}"
199
200
  end
@@ -210,16 +211,21 @@ module MessagebusApi
210
211
  raise "Messagebus API error=From Address is invalid :toEmail => #{message.to.first} :subject => #{message.subject} :fromEmail => #{message.from.first}"
211
212
  end
212
213
 
214
+ custom_headers = {}
215
+
216
+ custom_headers["envelope-sender"] = message.return_path if !message.return_path.nil?
217
+ custom_headers["bcc"] = message.bcc[0] if !message.bcc.nil?
218
+
219
+ message.header.fields.each do |f|
220
+ custom_headers[f.name] = f.value if f.name =~ /x-.*/i
221
+ end
222
+
213
223
  msg = {
214
224
  :toEmail => message.to.first,
215
225
  :subject => message.subject,
216
226
  :fromEmail => from_email,
217
- :fromName => from_name
218
- }
219
-
220
- message.header.fields.delete_if { |k|
221
- ( k.name.casecmp('bcc') == 0 ||
222
- k.name.casecmp('cc') == 0 )
227
+ :fromName => from_name,
228
+ :customHeaders => custom_headers
223
229
  }
224
230
 
225
231
  msg[:plaintextBody] = ( message.body ) ? "#{message.body}" : "No plaintext version was supplied."
@@ -13,7 +13,7 @@
13
13
  # under the License.
14
14
 
15
15
  module MessagebusApi
16
- VERSION = "3.0.6"
16
+ VERSION = "3.0.7"
17
17
 
18
18
  class Info
19
19
  @@ClientVersion = MessagebusApi::VERSION
@@ -468,11 +468,14 @@ describe MessagebusApi::Messagebus do
468
468
  message_body = JSON.parse(FakeWeb.last_request.body)
469
469
  message_body["messages"][0]["fromName"].should == ""
470
470
  message_body["messages"][0]["fromEmail"].should == to_email
471
+ message_body["messages"][0]["customHeaders"].should == {"envelope-sender"=>"bounce@bounce.example.com"}
471
472
  end
472
473
 
473
474
  it "works with from with nice name in address" do
474
475
  to_email = "Joe Mail <hello_joe@example.com>"
475
- message = MessageBusActionMailerTest.new_message(to_email)
476
+ bcc = "goodbye@example.com"
477
+ x_headers = {"x-header-a" => "header1", "x-tracking" => "1234"}
478
+ message = MessageBusActionMailerTest.new_message(to_email, bcc, x_headers)
476
479
 
477
480
  FakeWeb.register_uri(:post, "https://api.messagebus.com/api/v3/emails/send", :body => json_valid_send)
478
481
  client.deliver!(message)
@@ -480,6 +483,9 @@ describe MessagebusApi::Messagebus do
480
483
  message_body = JSON.parse(FakeWeb.last_request.body)
481
484
  message_body["messages"][0]["fromName"].should == "Joe Mail"
482
485
  message_body["messages"][0]["fromEmail"].should == "hello_joe@example.com"
486
+ message_body["messages"][0]["customHeaders"]["bcc"].should == "goodbye@example.com"
487
+ message_body["messages"][0]["customHeaders"]["x-header-a"].should == "header1"
488
+ message_body["messages"][0]["customHeaders"]["x-tracking"].should == "1234"
483
489
  end
484
490
  end
485
491
 
@@ -128,14 +128,24 @@ JAVASCRIPT
128
128
  json
129
129
  end
130
130
 
131
+
132
+
131
133
  ActionMailer::Base.add_delivery_method :messagebus, MessagebusApi::Messagebus, @api_key
134
+ ActionMailer::Base.delivery_method = :messagebus
135
+
132
136
  class MessageBusActionMailerTest < ActionMailer::Base
133
137
  default :to => "someone@example.com",
134
138
  :from => "no-reply@messagebus.com",
135
139
  :body => "This is a test",
136
- :subject => "Unit Test"
140
+ :subject => "Unit Test",
141
+ :return_path => "bounce@bounce.example.com"
142
+
143
+ def new_message(from_email, bcc = "", x_headers = {})
144
+ x_headers.each do |key, value|
145
+ headers[key] = value
146
+ end
137
147
 
138
- def new_message(from_email)
148
+ mail(:bcc => bcc) if bcc != ""
139
149
  mail(:from => from_email)
140
150
  end
141
151
  end
metadata CHANGED
@@ -1,34 +1,44 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: messagebus_ruby_api
3
- version: !ruby/object:Gem::Version
4
- version: 3.0.6
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 3
7
+ - 0
8
+ - 7
9
+ version: 3.0.7
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Message Bus dev team
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2012-08-23 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
16
+
17
+ date: 2013-01-30 00:00:00 -08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: multipart-post
16
- requirement: &70268165864740 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
22
  prerelease: false
24
- version_requirements: *70268165864740
25
- description: ! 'Allows you to use the Message Bus API '
26
- email:
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
32
+ description: "Allows you to use the Message Bus API "
33
+ email:
27
34
  - messagebus@googlegroups.com
28
35
  executables: []
36
+
29
37
  extensions: []
38
+
30
39
  extra_rdoc_files: []
31
- files:
40
+
41
+ files:
32
42
  - lib/messagebus_ruby_api/errors.rb
33
43
  - lib/messagebus_ruby_api/messagebus.rb
34
44
  - lib/messagebus_ruby_api/version.rb
@@ -41,32 +51,37 @@ files:
41
51
  - Gemfile
42
52
  - Rakefile
43
53
  - .rvmrc
44
- homepage: ''
45
- licenses:
54
+ has_rdoc: true
55
+ homepage: ""
56
+ licenses:
46
57
  - APACHE2
47
58
  post_install_message:
48
59
  rdoc_options: []
49
- require_paths:
60
+
61
+ require_paths:
50
62
  - lib
51
- required_ruby_version: !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ! '>='
55
- - !ruby/object:Gem::Version
56
- version: '0'
57
- required_rubygems_version: !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ! '>='
61
- - !ruby/object:Gem::Version
62
- version: '0'
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ segments:
68
+ - 0
69
+ version: "0"
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ segments:
75
+ - 0
76
+ version: "0"
63
77
  requirements: []
78
+
64
79
  rubyforge_project: messagebus_ruby_api
65
- rubygems_version: 1.8.10
80
+ rubygems_version: 1.3.6
66
81
  signing_key:
67
82
  specification_version: 3
68
83
  summary: Send email through the Message Bus service
69
- test_files:
84
+ test_files:
70
85
  - spec/messagebus_ruby_api/cacert.pem
71
86
  - spec/messagebus_ruby_api/messagebus_spec.rb
72
87
  - spec/spec_core_extensions.rb