sparkpost_rails 1.5.1 → 1.5.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 015fa7afb9a70eb6824e6c4e47aec113a68568f9
4
- data.tar.gz: ae5404032e43c09d87dd3100f7805fde98229ea9
2
+ SHA256:
3
+ metadata.gz: 67a3f701f32e2c75b34266b2846de7e15151eebdd7fe23ad49323f9237a8ba46
4
+ data.tar.gz: 4a9c1fec858684a5055ba2b661272e3985925dabda6ff63119638997a214def1
5
5
  SHA512:
6
- metadata.gz: 9968e5f84bb4a8102318d5b50db0a48149e94cc07d790b49621bed94e8a8743583141845f925bd23b0cb362a6da96f64649aa20723353bc25776f8df369ab9c2
7
- data.tar.gz: 9af79997ac4a3f524092fba3c7256ab71def60513a191eed57147504c52517b54653aed5835d4f06ee0335020760afac817fdb9e7b7f86786a3080b530bcf095
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.sandbox = true # default: false
42
- c.track_opens = true # default: false
43
- c.track_clicks = true # default: false
44
- c.return_path = 'BOUNCE-EMAIL@YOUR-DOMAIN.COM' # default: nil
45
- c.campaign_id = 'YOUR-CAMPAIGN' # default: nil
46
- c.transactional = true # default: false
47
- c.ip_pool = "MY-POOL" # default: nil
48
- c.inline_css = true # default: false
49
- c.html_content_only = true # default: false
50
- c.subaccount = "123" # default: nil
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 reponds with an error condition, SparkPostRails will raise a `SparkPostRails::DeliveryException`, which will include all the message data returned by the 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, multilple CC, multiple BCC, ReplyTo address, file attachments, inline images, multi-part (HTML and plaintext) messages - all utilizing the standard `ActionMailer` methodologies.
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 specifiy 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`:
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: "My Campaign",
100
+ campaign_id: 'My Campaign',
99
101
  transactional: true,
100
- ip_pool = "SPECIAL_POOL",
101
- api_key = "MESSAGE_SPECIFIC_API_KEY"
102
- subaccount = "123"
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 overriden on a specific email by setting that field on the mail message itself:
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 approprite headers through to the API. Note, per the SparkPost API documentation
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
 
@@ -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
- url = "https://api.sparkpost.com/api/v1/transmissions"
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
 
@@ -1,4 +1,4 @@
1
1
  module SparkPostRails
2
- VERSION = "1.5.1"
2
+ VERSION = "1.5.2"
3
3
  end
4
4
 
@@ -15,7 +15,8 @@ describe SparkPostRails::DeliveryMethod do
15
15
  end
16
16
 
17
17
  it "raises exception on error" do
18
- stub_request(:any, "https://api.sparkpost.com/api/v1/transmissions").
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
@@ -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, "https://api.sparkpost.com/api/v1/transmissions").
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 text: data[:text_part]}
75
- format.html {render text: data[:html_part]}
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 text: data[:text_part]}
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.1
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: 2018-04-17 00:00:00.000000000 Z
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: '5.3'
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: '5.3'
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
- rubyforge_project:
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