resend 0.7.1 → 0.8.0

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: 9d47b8d94ca889992ecef9e04d771fc16674236acc93c07d3dcd849bc5d5b2fe
4
+ data.tar.gz: 637a2eedb36475746c7c8494ae657ee78ab567be7d2864e3b63c97bbdb5d797c
5
5
  SHA512:
6
- metadata.gz: fdf59fc2f14340d126eac50991966eaad5e3a5ac53e10bd6c758ee4182577718c4963f7ddb5bb22fefdf15c6f27dfbfea5b2d369b5cc7c645159455d5be67017
7
- data.tar.gz: fcbfcc7612b770408686ce1bfee03c477894953a355d671d3e8f3d1897a5322857efba037c927552ac41d1c2115f91071c1085bbf53e13eea264d1986c5c6b54
6
+ metadata.gz: 3307b328674d55b133822f6837662615d88c8f4f5b6ae5c4d3467ba0fc1538d5dcf26873dd8584128ff2a1e6ef908d9bf5dec3e0e2534988f8dcc2bba13f75ce
7
+ data.tar.gz: 4215c88a8db32f51cf076c56e0a69c1f1b9313b242425c039c16a8e30a7e78ac5f7dcd2369f5c41919976c65403557fba126d81348a9192f7a449b5b9ee9fa09
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "resend/request"
4
+
5
+ module Resend
6
+ # Module responsible for wrapping Batch email sending API
7
+ module Batch
8
+ class << self
9
+ # https://resend.com/docs/api-reference/emails/send-batch-emails
10
+ def send(params = [])
11
+ path = "emails/batch"
12
+ Resend::Request.new(path, params, "post").perform
13
+ end
14
+ end
15
+ end
16
+ end
data/lib/resend/client.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require "resend/api_keys"
4
4
  require "resend/domains"
5
5
  require "resend/emails"
6
+ require "resend/batch"
6
7
  require "httparty"
7
8
 
8
9
  module Resend
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.8.0"
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.8.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-25 00:00:00.000000000 Z
11
+ date: 2023-10-20 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: []
@@ -47,6 +47,7 @@ files:
47
47
  - README.md
48
48
  - lib/resend.rb
49
49
  - lib/resend/api_keys.rb
50
+ - lib/resend/batch.rb
50
51
  - lib/resend/client.rb
51
52
  - lib/resend/domains.rb
52
53
  - lib/resend/emails.rb
@@ -59,7 +60,7 @@ homepage: https://github.com/resendlabs/resend-ruby
59
60
  licenses:
60
61
  - MIT
61
62
  metadata: {}
62
- post_install_message:
63
+ post_install_message:
63
64
  rdoc_options: []
64
65
  require_paths:
65
66
  - lib
@@ -75,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
76
  version: '0'
76
77
  requirements: []
77
78
  rubygems_version: 3.3.7
78
- signing_key:
79
+ signing_key:
79
80
  specification_version: 4
80
81
  summary: The Ruby and Rails SDK for resend.com
81
82
  test_files: []