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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 154948a83edaf33d2c541d663519984ce81c88de1dfdce855d6a57b495841e19
4
- data.tar.gz: 77ff14940114642d5099134f4c9ea7eb6a504f9c2f088f208b3492df0238d481
3
+ metadata.gz: 99e6b60b99100d90655d9544b23dfef503a65f0338a6d6b1ec54ad13098abe52
4
+ data.tar.gz: bec45636b1b7d8f33eb7c050ccd6e2725439a641a3993ad05d776151a6f9bd04
5
5
  SHA512:
6
- metadata.gz: 1e4b18829fce8858425ed271eb6608e72ee00e66391d2530e868503389c66e05acb4f65d92f0ca0454abb01c40e2d58742907d628d230bc47d37f0da863290cf
7
- data.tar.gz: ddc74f6a84b63ffc26914d1230b697d04759cea952c14d3e7ec6a8743267850532303eb8260fa7db19e215bc8253b1dfa93f57a8e693e4d8121953721e8e7734
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 api is set", @config) unless Resend.api_key
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|
@@ -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.6.0"
4
+ VERSION = "0.7.1"
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.6.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-05 00:00:00.000000000 Z
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.0.3.1
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