sparkpost_rails 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +25 -23
- data/lib/sparkpost_rails.rb +3 -0
- data/lib/sparkpost_rails/delivery_method.rb +1 -2
- data/lib/sparkpost_rails/version.rb +1 -1
- data/spec/response_spec.rb +2 -1
- data/spec/spec_helper.rb +5 -5
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 67a3f701f32e2c75b34266b2846de7e15151eebdd7fe23ad49323f9237a8ba46
|
4
|
+
data.tar.gz: 4a9c1fec858684a5055ba2b661272e3985925dabda6ff63119638997a214def1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b4678a4cd017e81efc21585dae73d4e19c9f8e512cebbbcf9ac1695ba0801fff4468ff1373680903e44c05ba111b3014c9b85edb654b4800e2b6dfed7bb02c2
|
7
|
+
data.tar.gz: 1a72fb5be4f05ca8575b654677207b0d298bc423c63f6bc4cd58dddcc7ab2c3d5117110314074b873f08c3bfd09c250097a2fedcbdbc1d5c14827728f12ac913
|
data/README.md
CHANGED
@@ -38,16 +38,17 @@ You can establish values for a number of SparkPost settings in the initializer.
|
|
38
38
|
|
39
39
|
```ruby
|
40
40
|
SparkPostRails.configure do |c|
|
41
|
-
c.
|
42
|
-
c.
|
43
|
-
c.
|
44
|
-
c.
|
45
|
-
c.
|
46
|
-
c.
|
47
|
-
c.
|
48
|
-
c.
|
49
|
-
c.
|
50
|
-
c.
|
41
|
+
c.api_endpoint = "https://api.eu.sparkpost.com/api/" # default: "https://api.sparkpost.com/api/"
|
42
|
+
c.sandbox = true # default: false
|
43
|
+
c.track_opens = true # default: false
|
44
|
+
c.track_clicks = true # default: false
|
45
|
+
c.return_path = 'BOUNCE-EMAIL@YOUR-DOMAIN.COM' # default: nil
|
46
|
+
c.campaign_id = 'YOUR-CAMPAIGN' # default: nil
|
47
|
+
c.transactional = true # default: false
|
48
|
+
c.ip_pool = "MY-POOL" # default: nil
|
49
|
+
c.inline_css = true # default: false
|
50
|
+
c.html_content_only = true # default: false
|
51
|
+
c.subaccount = "123" # default: nil
|
51
52
|
end
|
52
53
|
```
|
53
54
|
|
@@ -63,15 +64,15 @@ Example:
|
|
63
64
|
|
64
65
|
```ruby
|
65
66
|
{
|
66
|
-
"total_rejected_recipients" => 0,
|
67
|
-
"total_accepted_recipients" => 1,
|
67
|
+
"total_rejected_recipients" => 0,
|
68
|
+
"total_accepted_recipients" => 1,
|
68
69
|
"id" => "00000000000000"
|
69
70
|
}
|
70
71
|
```
|
71
72
|
|
72
|
-
If the SparkPost API
|
73
|
+
If the SparkPost API responds with an error condition, SparkPostRails will raise a `SparkPostRails::DeliveryException`, which will include all the message data returned by the API.
|
73
74
|
|
74
|
-
SparkPostRails will support multiple recipients,
|
75
|
+
SparkPostRails will support multiple recipients, multiple CC, multiple BCC, ReplyTo address, file attachments, inline images, multi-part (HTML and plaintext) messages - all utilizing the standard `ActionMailer` methodologies.
|
75
76
|
|
76
77
|
Handling Errors
|
77
78
|
---------------
|
@@ -82,6 +83,7 @@ If you are using `ActiveJob` and wish to do something special when the SparkPost
|
|
82
83
|
```ruby
|
83
84
|
ActionMailer::DeliveryJob.rescue_from(SparkPostRails::DeliveryException) do |exception|
|
84
85
|
# do something special with the error
|
86
|
+
# do something special with the error
|
85
87
|
end
|
86
88
|
```
|
87
89
|
|
@@ -89,23 +91,23 @@ SparkPost-Specific Features
|
|
89
91
|
---------------------------
|
90
92
|
|
91
93
|
### Configuration Settings
|
92
|
-
You can
|
94
|
+
You can specify values for any or all of the configuration settings listed above on an individual message. Simply add a hash of these values to the mail message in a field named `sparkpost_data`:
|
93
95
|
|
94
96
|
```ruby
|
95
|
-
data = {
|
97
|
+
data = {
|
96
98
|
track_opens: true,
|
97
99
|
track_clicks: false,
|
98
|
-
campaign_id:
|
100
|
+
campaign_id: 'My Campaign',
|
99
101
|
transactional: true,
|
100
|
-
ip_pool
|
101
|
-
api_key
|
102
|
-
subaccount
|
102
|
+
ip_pool: 'SPECIAL_POOL',
|
103
|
+
api_key: 'MESSAGE_SPECIFIC_API_KEY',
|
104
|
+
subaccount: '123'
|
103
105
|
}
|
104
106
|
|
105
107
|
mail(to: to_email, subject: "Test", body: "test", sparkpost_data: data)
|
106
108
|
```
|
107
109
|
|
108
|
-
Additionally, `return_path` can be
|
110
|
+
Additionally, `return_path` can be overridden on a specific email by setting that field on the mail message itself:
|
109
111
|
|
110
112
|
```ruby
|
111
113
|
mail(to: to_email, subject: "Test", body: "test", return_path: "bounces@example.com")
|
@@ -124,7 +126,7 @@ mail(to: to_email, subject: "Test", body: "test", sparkpost_data: data)
|
|
124
126
|
To schedule the generation of messages for a future date and time, specify a start time in the `date` parameter of the mail. The `date` must be in the future and less than 1 year from today. If `date` is in the past or too far in the future, no date will be passed, and no delivery schedule will be set.
|
125
127
|
|
126
128
|
```ruby
|
127
|
-
start_time = DateTime.now + 4.hours
|
129
|
+
start_time = DateTime.now + 4.hours
|
128
130
|
|
129
131
|
mail(to: to_email, subject: "Test", body: "test", date: start_time)
|
130
132
|
```
|
@@ -218,7 +220,7 @@ end
|
|
218
220
|
**NOTE**: All inline-content that may exist in your mail message will be ignored, as the SparkPost API does not accept that data when a template id is supplied. This includes `Subject`, `From`, `ReplyTo`, Attachments, and Inline Images.
|
219
221
|
|
220
222
|
###Other Mail Headers
|
221
|
-
If you need to identify custom mail headers for your messages, use the `ActionMailer` `header[]` method. The gem will pass all
|
223
|
+
If you need to identify custom mail headers for your messages, use the `ActionMailer` `header[]` method. The gem will pass all appropriate headers through to the API. Note, per the SparkPost API documentation
|
222
224
|
|
223
225
|
> Headers such as 'Content-Type' and 'Content-Transfer-Encoding' are not allowed here as they are auto-generated upon construction of the email.
|
224
226
|
|
data/lib/sparkpost_rails.rb
CHANGED
@@ -19,6 +19,7 @@ module SparkPostRails
|
|
19
19
|
|
20
20
|
class Configuration
|
21
21
|
attr_accessor :api_key
|
22
|
+
attr_accessor :api_endpoint
|
22
23
|
attr_accessor :sandbox
|
23
24
|
|
24
25
|
attr_accessor :track_opens
|
@@ -45,6 +46,8 @@ module SparkPostRails
|
|
45
46
|
@api_key = ""
|
46
47
|
end
|
47
48
|
|
49
|
+
@api_endpoint = "https://api.sparkpost.com/api/"
|
50
|
+
|
48
51
|
@sandbox = false
|
49
52
|
|
50
53
|
@track_opens = false
|
@@ -377,9 +377,8 @@ module SparkPostRails
|
|
377
377
|
end
|
378
378
|
|
379
379
|
def post_to_api
|
380
|
-
|
380
|
+
uri = URI.join(SparkPostRails.configuration.api_endpoint, 'v1/transmissions')
|
381
381
|
|
382
|
-
uri = URI.parse(url)
|
383
382
|
http = Net::HTTP.new(uri.host, uri.port)
|
384
383
|
http.use_ssl = true
|
385
384
|
|
data/spec/response_spec.rb
CHANGED
@@ -15,7 +15,8 @@ describe SparkPostRails::DeliveryMethod do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "raises exception on error" do
|
18
|
-
|
18
|
+
uri = URI.join(SparkPostRails.configuration.api_endpoint, 'v1/transmissions')
|
19
|
+
stub_request(:any, uri.to_s).
|
19
20
|
to_return(body: "{\"errors\":[{\"message\":\"required field is missing\",\"description\":\"recipients or list_id required\",\"code\":\"1400\"}]}", status: 403)
|
20
21
|
|
21
22
|
test_email = Mailer.test_email
|
data/spec/spec_helper.rb
CHANGED
@@ -17,8 +17,8 @@ RSpec.configure do |config|
|
|
17
17
|
c.api_key = "TESTKEY1234"
|
18
18
|
end
|
19
19
|
end
|
20
|
-
|
21
|
-
stub_request(:any,
|
20
|
+
uri = URI.join(SparkPostRails.configuration.api_endpoint, 'v1/transmissions')
|
21
|
+
stub_request(:any, uri.to_s).
|
22
22
|
to_return(body: "{\"results\":{\"total_rejected_recipients\":0,\"total_accepted_recipients\":1,\"id\":\"00000000000000000\"}}", status: 200)
|
23
23
|
end
|
24
24
|
|
@@ -71,14 +71,14 @@ class Mailer < ActionMailer::Base
|
|
71
71
|
if data.has_key?(:html_part)
|
72
72
|
|
73
73
|
mail(data) do |format|
|
74
|
-
format.text {render
|
75
|
-
format.html {render
|
74
|
+
format.text {render plain: data[:text_part]}
|
75
|
+
format.html {render plain: data[:html_part]}
|
76
76
|
end
|
77
77
|
|
78
78
|
else
|
79
79
|
|
80
80
|
mail(data) do |format|
|
81
|
-
format.text {render
|
81
|
+
format.text {render plain: data[:text_part]}
|
82
82
|
end
|
83
83
|
|
84
84
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sparkpost_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Kimball
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-10-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
version: '4.0'
|
21
21
|
- - "<"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: '
|
23
|
+
version: '6.1'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
version: '4.0'
|
31
31
|
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '6.1'
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: rspec
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,8 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
|
-
|
128
|
-
rubygems_version: 2.2.2
|
127
|
+
rubygems_version: 3.0.1
|
129
128
|
signing_key:
|
130
129
|
specification_version: 4
|
131
130
|
summary: SparkPost for Rails
|