resend 0.20.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b5349c47ad8289c343894fe33fac76d211ae9978f3b345f96acd872cd7273b8
4
- data.tar.gz: 1428260d051c8ec44f90032de660d274511c51a89078abe748144e8bc7ee5358
3
+ metadata.gz: a211cd93c4479cba4bf63b849bf8e91de3413e9ccf9917c681454fcd7ed832e0
4
+ data.tar.gz: 4e9ba38c842d04fbe3eb7d5987784b54d327ee9b1eaeec8dbfbcebf08110b948
5
5
  SHA512:
6
- metadata.gz: 5930573ba4216644183433e4eeb2eb7b811507594030e251da1f44b33af50758a4009f5c2a390ba326eaccd5e3fbd0dee9a6f5ab5af0604ade24a8ab4bae7554
7
- data.tar.gz: f8bf3707e3126e63d3fed39b78ccdca6cbfc8a04675e24b9c5623982e2f5a77bf08574065dec27a06047f6453f3858ce32357d80bf6c5c2d707167aeb0b571cc
6
+ metadata.gz: 63c27d58c685bd8edd04ce28817bbca66ed468113067c0f43f6b51bdf3add9ebcfeeb1d434bf2150f84d5ae4c7661860f834d7dfe62f7c5146bb75051408ae77
7
+ data.tar.gz: 5c63d4c381f0c53dc04b1c8b933b131e9d0bdf7aaf2a4354a9d1c454d75a2116a35fec481865e8668719d0e1fab875688acb6fa2968f3c09a116aeaf1e6500f3
@@ -10,6 +10,12 @@ module Resend
10
10
  Resend::Request.new(path, params, "post").perform
11
11
  end
12
12
 
13
+ #
14
+ # Retrieves a contact from an audience
15
+ #
16
+ # @param audience_id [String] the audience id
17
+ # @param id [String] either the contact id or contact's email
18
+ #
13
19
  # https://resend.com/docs/api-reference/contacts/get-contact
14
20
  def get(audience_id, id)
15
21
  path = "audiences/#{audience_id}/contacts/#{id}"
data/lib/resend/mailer.rb CHANGED
@@ -15,9 +15,11 @@ module Resend
15
15
  from reply-to to subject mime-version
16
16
  html text
17
17
  content-type tags scheduled_at
18
- headers
18
+ headers options
19
19
  ].freeze
20
20
 
21
+ SUPPORTED_OPTIONS = %w[idempotency_key].freeze
22
+
21
23
  def initialize(config)
22
24
  @config = config
23
25
  raise Resend::Error.new("Make sure your API Key is set", @config) unless Resend.api_key
@@ -35,7 +37,8 @@ module Resend
35
37
  #
36
38
  def deliver!(mail)
37
39
  params = build_resend_params(mail)
38
- resp = Resend::Emails.send(params)
40
+ options = get_options(mail) if mail[:options].present?
41
+ resp = Resend::Emails.send(params, options: options || {})
39
42
  mail.message_id = resp[:id] if resp[:error].nil?
40
43
  resp
41
44
  end
@@ -92,6 +95,22 @@ module Resend
92
95
  params
93
96
  end
94
97
 
98
+ #
99
+ # Adds additional options fields.
100
+ # Currently supports only :idempotency_key
101
+ #
102
+ # @param Mail mail Rails Mail object
103
+ # @return Hash hash with headers param
104
+ #
105
+ def get_options(mail)
106
+ opts = {}
107
+ if mail[:options].present?
108
+ opts.merge!(mail[:options].unparsed_value)
109
+ opts.delete_if { |k, _v| !SUPPORTED_OPTIONS.include?(k.to_s) }
110
+ end
111
+ opts
112
+ end
113
+
95
114
  # Remove nils from header values
96
115
  def cleanup_headers(headers)
97
116
  headers.delete_if { |_k, v| v.nil? }
@@ -32,7 +32,6 @@ module Resend
32
32
  options = {
33
33
  headers: @headers
34
34
  }
35
-
36
35
  options[:body] = @body.to_json unless @body.empty?
37
36
 
38
37
  resp = HTTParty.send(@verb.to_sym, "#{BASE_URL}#{@path}", options)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Resend
4
- VERSION = "0.20.0"
4
+ VERSION = "0.21.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.20.0
4
+ version: 0.21.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: 2025-04-27 00:00:00.000000000 Z
11
+ date: 2025-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty