courrier 0.5.1 → 0.6.0

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
2
  SHA256:
3
- metadata.gz: 7b53b10ca70de7f78cc85b10132ef28629ab062421e0d8ba0c7179b69e45d98d
4
- data.tar.gz: 95aecbc0697a720292f9bf3e98e32a5a50637c73367b121fdd5549c6dfbe8f9a
3
+ metadata.gz: b2da5fe5fc7bb657449ed12d90c8443d6fa692339f9974fcbda7c4c726964ad8
4
+ data.tar.gz: ad4fc570a0bdb7cb1bce3c214a21e550a725212e0f900e5d31fe1345d5c7b221
5
5
  SHA512:
6
- metadata.gz: 42d52645c4ee70b04ec3005c699555f17ab3f93da25096d9c240126b6765e4f00197dafba99f0eaeec873df5577bbb828e9d177877d16c7611f6a2087cfc990f
7
- data.tar.gz: 03e8724821bc2452e4f838564f7e12ea3654658a20c4eb5c4c2d1b782f7f53e66972a6b88e48490c23ab652e1a8f8df710573028ac88b7c186876462bc36916e
6
+ metadata.gz: 7170f0e34c59ceee7b88c41865da67f558357058651a9508578adb5b0fec0d5da78bea1672aed8b24335128822784c1e5b23478804fb1a08273efece5129ae3f
7
+ data.tar.gz: 89de9523761715879b487d62ca63576eb9783647a0e2d8baba5ef268b36c91d359d96c33386b06a3cd686af8e747cf548eaf74ea9654efde22030a52eaac5fe4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- courrier (0.5.1)
4
+ courrier (0.6.0)
5
5
  launchy (>= 3.1, < 4)
6
6
  nokogiri (>= 1.18, < 2)
7
7
 
data/README.md CHANGED
@@ -161,6 +161,7 @@ Courrier supports these transactional email providers:
161
161
  - [Postmark](https://postmarkapp.com)
162
162
  - [SendGrid](https://sendgrid.com)
163
163
  - [SparkPost](https://sparkpost.com)
164
+ - [Userlist](https://userlist.com)
164
165
 
165
166
  ⚠️ Some providers still need manual verification of their implementation. If you're using one of these providers, please help verify the implementation by sharing your experience in [this GitHub issue](https://github.com/Rails-Designer/courrier/issues/4). 🙏
166
167
 
@@ -10,6 +10,7 @@ require "courrier/email/providers/postmark"
10
10
  require "courrier/email/providers/preview"
11
11
  require "courrier/email/providers/sendgrid"
12
12
  require "courrier/email/providers/sparkpost"
13
+ require "courrier/email/providers/userlist"
13
14
 
14
15
  module Courrier
15
16
  class Email
@@ -43,7 +44,8 @@ module Courrier
43
44
  postmark: Courrier::Email::Providers::Postmark,
44
45
  preview: Courrier::Email::Providers::Preview,
45
46
  sendgrid: Courrier::Email::Providers::Sendgrid,
46
- sparkpost: Courrier::Email::Providers::Sparkpost
47
+ sparkpost: Courrier::Email::Providers::Sparkpost,
48
+ userlist: Courrier::Email::Providers::Userlist
47
49
  }.freeze
48
50
 
49
51
  def configuration_missing_in_production?
@@ -29,7 +29,11 @@ module Courrier
29
29
 
30
30
  def content_type = "multipart/form-data"
31
31
 
32
- def authentication_for(request) = request.basic_auth("api", @api_key)
32
+ def headers
33
+ {
34
+ "Authorization" => "Basic #{Base64.strict_encode64("api:#{@api_key}")}"
35
+ }
36
+ end
33
37
  end
34
38
  end
35
39
  end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Courrier
4
+ class Email
5
+ module Providers
6
+ class Userlist < Base
7
+ ENDPOINT_URL = "https://push.userlist.com/messages"
8
+
9
+ def body
10
+ {
11
+ "from" => @options.from,
12
+ "to" => @options.to,
13
+ "subject" => @options.subject,
14
+ "body" => body_document
15
+ }.compact.merge(provider_options)
16
+ end
17
+
18
+ private
19
+
20
+ def headers
21
+ {
22
+ "Authorization" => "Push #{@api_key}"
23
+ }
24
+ end
25
+
26
+ def body_document
27
+ if @options.html && @options.text
28
+ multipart_document
29
+ elsif @options.html
30
+ html_document
31
+ elsif @options.text
32
+ text_document
33
+ end
34
+ end
35
+
36
+ def text_document
37
+ {
38
+ "type" => "text",
39
+ "content" => @options.text
40
+ }
41
+ end
42
+
43
+ def html_document
44
+ {
45
+ "type" => "html",
46
+ "content" => @options.html
47
+ }
48
+ end
49
+
50
+ def multipart_document
51
+ {
52
+ "type" => "multipart",
53
+ "content" => [
54
+ html_document,
55
+ text_document
56
+ ]
57
+ }
58
+ end
59
+
60
+ def provider_options
61
+ {"theme" => nil}.merge(@provider_options)
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -79,7 +79,7 @@ module Courrier
79
79
  provider: @provider,
80
80
  api_key: @api_key,
81
81
  options: @options,
82
- provider_options: Courrier.configuration&.providers&.[](@provider.to_s.downcase.to_sym)&.to_h
82
+ provider_options: Courrier.configuration&.providers&.[](@provider.to_s.downcase.to_sym)
83
83
  ).deliver
84
84
  end
85
85
  alias_method :deliver_now, :deliver
@@ -1,3 +1,3 @@
1
1
  module Courrier
2
- VERSION = "0.5.1"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: courrier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rails Designer
@@ -86,6 +86,7 @@ files:
86
86
  - lib/courrier/email/providers/preview/default.html.erb
87
87
  - lib/courrier/email/providers/sendgrid.rb
88
88
  - lib/courrier/email/providers/sparkpost.rb
89
+ - lib/courrier/email/providers/userlist.rb
89
90
  - lib/courrier/email/request.rb
90
91
  - lib/courrier/email/result.rb
91
92
  - lib/courrier/email/transformer.rb