resend 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/resend/mailer.rb +18 -2
- data/lib/resend/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 546dd4f52e3f16e399e3d42b6fc5512628ad67249ba9e5a521f97ce428d80682
|
4
|
+
data.tar.gz: 1b291656cdbc4456dddf0aa3444e2ef4b80aef9a1429640a38073395cce99e75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4849accfa344de0ee7db136a06e64ff3111aa73111e68a14ca708c9c5f43af73023a8921d55a436a2a0dfeb2f831dc2572fca01d59014c51adf288c378987e1
|
7
|
+
data.tar.gz: 39dfdac4232712f57d6e884318edc09155bf0bdc67110d49b22de0f88e20d4c2475ca98c91b68a0b2e505b7391884d774dcd75dafb074a3a0c17d113f1edda4f
|
data/lib/resend/mailer.rb
CHANGED
@@ -5,11 +5,14 @@ require "resend"
|
|
5
5
|
module Resend
|
6
6
|
# Mailer class used by railtie
|
7
7
|
class Mailer
|
8
|
-
attr_accessor :config
|
8
|
+
attr_accessor :config, :settings
|
9
9
|
|
10
10
|
def initialize(config)
|
11
11
|
@config = config
|
12
|
-
raise Resend::Error.new("Make sure your
|
12
|
+
raise Resend::Error.new("Make sure your API Key is set", @config) unless Resend.api_key
|
13
|
+
|
14
|
+
# avoids NilError exception
|
15
|
+
@settings = { return_response: true }
|
13
16
|
end
|
14
17
|
|
15
18
|
def deliver!(mail)
|
@@ -19,6 +22,7 @@ module Resend
|
|
19
22
|
resp
|
20
23
|
end
|
21
24
|
|
25
|
+
# Builds the payload for sending
|
22
26
|
def build_resend_params(mail)
|
23
27
|
params = {
|
24
28
|
from: get_from(mail.from),
|
@@ -26,11 +30,20 @@ module Resend
|
|
26
30
|
subject: mail.subject
|
27
31
|
}
|
28
32
|
params.merge!(get_addons(mail))
|
33
|
+
params.merge!(get_headers(mail))
|
29
34
|
params[:attachments] = get_attachments(mail) if mail.attachments.present?
|
30
35
|
params.merge!(get_contents(mail))
|
31
36
|
params
|
32
37
|
end
|
33
38
|
|
39
|
+
# Add custom headers fields
|
40
|
+
def get_headers(mail)
|
41
|
+
params = {}
|
42
|
+
params[:headers] = mail[:headers].unparsed_value if mail[:headers].present?
|
43
|
+
params
|
44
|
+
end
|
45
|
+
|
46
|
+
# Add cc, bcc, reply_to fields
|
34
47
|
def get_addons(mail)
|
35
48
|
params = {}
|
36
49
|
params[:cc] = mail.cc if mail.cc.present?
|
@@ -39,6 +52,7 @@ module Resend
|
|
39
52
|
params
|
40
53
|
end
|
41
54
|
|
55
|
+
# Gets the body of the email
|
42
56
|
def get_contents(mail)
|
43
57
|
params = {}
|
44
58
|
case mail.mime_type
|
@@ -53,12 +67,14 @@ module Resend
|
|
53
67
|
params
|
54
68
|
end
|
55
69
|
|
70
|
+
# Gets the `from` field
|
56
71
|
def get_from(input)
|
57
72
|
return input.first if input.is_a? Array
|
58
73
|
|
59
74
|
input
|
60
75
|
end
|
61
76
|
|
77
|
+
# Handle attachments when present
|
62
78
|
def get_attachments(mail)
|
63
79
|
attachments = []
|
64
80
|
mail.attachments.each do |part|
|
data/lib/resend/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derich Pacheco
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description:
|
41
|
+
description:
|
42
42
|
email: carlosderich@gmail.com
|
43
43
|
executables: []
|
44
44
|
extensions: []
|
@@ -59,7 +59,7 @@ homepage: https://github.com/resendlabs/resend-ruby
|
|
59
59
|
licenses:
|
60
60
|
- MIT
|
61
61
|
metadata: {}
|
62
|
-
post_install_message:
|
62
|
+
post_install_message:
|
63
63
|
rdoc_options: []
|
64
64
|
require_paths:
|
65
65
|
- lib
|
@@ -74,8 +74,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
|
-
rubygems_version: 3.
|
78
|
-
signing_key:
|
77
|
+
rubygems_version: 3.3.7
|
78
|
+
signing_key:
|
79
79
|
specification_version: 4
|
80
80
|
summary: The Ruby and Rails SDK for resend.com
|
81
81
|
test_files: []
|