resend 0.6.0 → 0.7.1
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/request.rb +1 -1
- data/lib/resend/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99e6b60b99100d90655d9544b23dfef503a65f0338a6d6b1ec54ad13098abe52
|
4
|
+
data.tar.gz: bec45636b1b7d8f33eb7c050ccd6e2725439a641a3993ad05d776151a6f9bd04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdf59fc2f14340d126eac50991966eaad5e3a5ac53e10bd6c758ee4182577718c4963f7ddb5bb22fefdf15c6f27dfbfea5b2d369b5cc7c645159455d5be67017
|
7
|
+
data.tar.gz: fcbfcc7612b770408686ce1bfee03c477894953a355d671d3e8f3d1897a5322857efba037c927552ac41d1c2115f91071c1085bbf53e13eea264d1986c5c6b54
|
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/request.rb
CHANGED
@@ -21,7 +21,7 @@ module Resend
|
|
21
21
|
@headers = {
|
22
22
|
"Content-Type" => "application/json",
|
23
23
|
"Accept" => "application/json",
|
24
|
-
"User-Agent" => "ruby:#{Resend::VERSION}",
|
24
|
+
"User-Agent" => "resend-ruby:#{Resend::VERSION}",
|
25
25
|
"Authorization" => "Bearer #{Resend.api_key}"
|
26
26
|
}
|
27
27
|
end
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derich Pacheco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
|
-
rubygems_version: 3.
|
77
|
+
rubygems_version: 3.3.7
|
78
78
|
signing_key:
|
79
79
|
specification_version: 4
|
80
80
|
summary: The Ruby and Rails SDK for resend.com
|