resend 0.13.0 → 0.15.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 +14 -0
- data/lib/resend/request.rb +15 -0
- data/lib/resend/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5654ce4fd9c6c9a097803ad5a55c064d5d21bb2c9fa3dddcbe7a334914fba8c3
|
4
|
+
data.tar.gz: 729b8b8acf1a8dd6c016ce8cc5f509a39bfd8806cbfc11f044e0dd732a011088
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36611a0d85ebc0938e0edb0df7e3bd9c9e69fb9ed87e1c0d3f19a4512f6305447b7169ac61ad7ce30cd710003d28c0a099bd7901b892f2cb1446f8a7910c4ed4
|
7
|
+
data.tar.gz: 3ec1ae9d87ae9250a8e2eb0463878fca57013d1857ee8aee4fcab208fc7fa2e84c24cb02cc82bd5585b419c3174a24493af20dac27ceef99c7f3229545377dcd
|
data/lib/resend/mailer.rb
CHANGED
@@ -44,6 +44,7 @@ module Resend
|
|
44
44
|
}
|
45
45
|
params.merge!(get_addons(mail))
|
46
46
|
params.merge!(get_headers(mail))
|
47
|
+
params.merge!(get_tags(mail))
|
47
48
|
params[:attachments] = get_attachments(mail) if mail.attachments.present?
|
48
49
|
params.merge!(get_contents(mail))
|
49
50
|
params
|
@@ -62,6 +63,19 @@ module Resend
|
|
62
63
|
params
|
63
64
|
end
|
64
65
|
|
66
|
+
#
|
67
|
+
# Add tags fields
|
68
|
+
#
|
69
|
+
# @param Mail mail Rails Mail object
|
70
|
+
#
|
71
|
+
# @return Hash hash with tags param
|
72
|
+
#
|
73
|
+
def get_tags(mail)
|
74
|
+
params = {}
|
75
|
+
params[:tags] = mail[:tags].unparsed_value if mail[:tags].present?
|
76
|
+
params
|
77
|
+
end
|
78
|
+
|
65
79
|
#
|
66
80
|
# Add cc, bcc, reply_to fields
|
67
81
|
#
|
data/lib/resend/request.rb
CHANGED
@@ -34,6 +34,9 @@ module Resend
|
|
34
34
|
|
35
35
|
options[:body] = @body.to_json unless @body.empty?
|
36
36
|
resp = HTTParty.send(@verb.to_sym, "#{BASE_URL}#{@path}", options)
|
37
|
+
|
38
|
+
check_json!(resp)
|
39
|
+
|
37
40
|
resp.transform_keys!(&:to_sym) unless resp.body.empty?
|
38
41
|
handle_error!(resp) if resp[:statusCode] && (resp[:statusCode] != 200 || resp[:statusCode] != 201)
|
39
42
|
resp
|
@@ -45,5 +48,17 @@ module Resend
|
|
45
48
|
error = Resend::Error::ERRORS[code]
|
46
49
|
raise(error.new(body, code)) if error
|
47
50
|
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def check_json!(resp)
|
55
|
+
if resp.body.is_a?(Hash)
|
56
|
+
JSON.parse(resp.body.to_json)
|
57
|
+
else
|
58
|
+
JSON.parse(resp.body)
|
59
|
+
end
|
60
|
+
rescue JSON::ParserError, TypeError
|
61
|
+
raise Resend::Error::InternalServerError.new("Resend API returned an unexpected response", nil)
|
62
|
+
end
|
48
63
|
end
|
49
64
|
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.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derich Pacheco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|