resend 0.7.1 → 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: 99e6b60b99100d90655d9544b23dfef503a65f0338a6d6b1ec54ad13098abe52
4
- data.tar.gz: bec45636b1b7d8f33eb7c050ccd6e2725439a641a3993ad05d776151a6f9bd04
3
+ metadata.gz: be26542af1fd2713f0b004a3e4a5fc347b798b7442d73807e4d7b1d84e1bef96
4
+ data.tar.gz: d4452a29cdc20076b6d9ecb4edfd000d55907e259208b38e9b8c1da7ff18f2e6
5
5
  SHA512:
6
- metadata.gz: fdf59fc2f14340d126eac50991966eaad5e3a5ac53e10bd6c758ee4182577718c4963f7ddb5bb22fefdf15c6f27dfbfea5b2d369b5cc7c645159455d5be67017
7
- data.tar.gz: fcbfcc7612b770408686ce1bfee03c477894953a355d671d3e8f3d1897a5322857efba037c927552ac41d1c2115f91071c1085bbf53e13eea264d1986c5c6b54
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|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Resend
4
- VERSION = "0.7.1"
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.1
4
+ version: 0.7.2
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-25 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
@@ -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
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  version: '0'
76
76
  requirements: []
77
77
  rubygems_version: 3.3.7
78
- signing_key:
78
+ signing_key:
79
79
  specification_version: 4
80
80
  summary: The Ruby and Rails SDK for resend.com
81
81
  test_files: []