resend 0.7.0 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 546dd4f52e3f16e399e3d42b6fc5512628ad67249ba9e5a521f97ce428d80682
4
- data.tar.gz: 1b291656cdbc4456dddf0aa3444e2ef4b80aef9a1429640a38073395cce99e75
3
+ metadata.gz: be26542af1fd2713f0b004a3e4a5fc347b798b7442d73807e4d7b1d84e1bef96
4
+ data.tar.gz: d4452a29cdc20076b6d9ecb4edfd000d55907e259208b38e9b8c1da7ff18f2e6
5
5
  SHA512:
6
- metadata.gz: e4849accfa344de0ee7db136a06e64ff3111aa73111e68a14ca708c9c5f43af73023a8921d55a436a2a0dfeb2f831dc2572fca01d59014c51adf288c378987e1
7
- data.tar.gz: 39dfdac4232712f57d6e884318edc09155bf0bdc67110d49b22de0f88e20d4c2475ca98c91b68a0b2e505b7391884d774dcd75dafb074a3a0c17d113f1edda4f
6
+ metadata.gz: 0e2f022d7a709acbdc26eef57f73f41f30d244394d65b0261a1ca353af27038b9ed366b917293dba1018fa24ec6ba2a543ea27303f09e79c37e513fdd06f275c
7
+ data.tar.gz: c3e0c9fc17e4b2afb037baf542561e0871cc6bb3d274757efd452bcfaeb1c7d3eb0086f8759c26bf8deaebafc0196f99b2859f2a17bcc4328e4b4271c6062ac6
data/lib/resend/mailer.rb CHANGED
@@ -15,6 +15,13 @@ module Resend
15
15
  @settings = { return_response: true }
16
16
  end
17
17
 
18
+ #
19
+ # Overwritten deliver! method
20
+ #
21
+ # @param Mail mail
22
+ #
23
+ # @return Object resend response
24
+ #
18
25
  def deliver!(mail)
19
26
  params = build_resend_params(mail)
20
27
  resp = Resend::Emails.send(params)
@@ -22,10 +29,16 @@ module Resend
22
29
  resp
23
30
  end
24
31
 
32
+ #
25
33
  # Builds the payload for sending
34
+ #
35
+ # @param Mail mail rails mail object
36
+ #
37
+ # @return Hash hash with all Resend params
38
+ #
26
39
  def build_resend_params(mail)
27
40
  params = {
28
- from: get_from(mail.from),
41
+ from: get_from(mail),
29
42
  to: mail.to,
30
43
  subject: mail.subject
31
44
  }
@@ -36,14 +49,26 @@ module Resend
36
49
  params
37
50
  end
38
51
 
52
+ #
39
53
  # Add custom headers fields
54
+ #
55
+ # @param Mail mail Rails Mail object
56
+ #
57
+ # @return Hash hash with headers param
58
+ #
40
59
  def get_headers(mail)
41
60
  params = {}
42
61
  params[:headers] = mail[:headers].unparsed_value if mail[:headers].present?
43
62
  params
44
63
  end
45
64
 
65
+ #
46
66
  # Add cc, bcc, reply_to fields
67
+ #
68
+ # @param Mail mail Rails Mail Object
69
+ #
70
+ # @return Hash hash containing cc/bcc/reply_to attrs
71
+ #
47
72
  def get_addons(mail)
48
73
  params = {}
49
74
  params[:cc] = mail.cc if mail.cc.present?
@@ -52,7 +77,13 @@ module Resend
52
77
  params
53
78
  end
54
79
 
80
+ #
55
81
  # Gets the body of the email
82
+ #
83
+ # @param Mail mail Rails Mail Object
84
+ #
85
+ # @return Hash hash containing html/text or both attrs
86
+ #
56
87
  def get_contents(mail)
57
88
  params = {}
58
89
  case mail.mime_type
@@ -67,14 +98,27 @@ module Resend
67
98
  params
68
99
  end
69
100
 
70
- # Gets the `from` field
101
+ #
102
+ # Properly gets the `from` attr
103
+ #
104
+ # @param Mail input object
105
+ #
106
+ # @return String `from` string
107
+ #
71
108
  def get_from(input)
72
- return input.first if input.is_a? Array
109
+ return input.from.first if input[:from].nil?
73
110
 
74
- input
111
+ from = input[:from].formatted
112
+ return from.first if from.is_a? Array
113
+
114
+ from.to_s
75
115
  end
76
116
 
117
+ #
77
118
  # Handle attachments when present
119
+ #
120
+ # @return Array attachments array
121
+ #
78
122
  def get_attachments(mail)
79
123
  attachments = []
80
124
  mail.attachments.each do |part|
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Resend
4
- VERSION = "0.7.0"
4
+ VERSION = "0.7.2"
5
5
  end
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.7.0
4
+ version: 0.7.2
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-22 00:00:00.000000000 Z
11
+ date: 2023-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty