resend 0.17.1 → 0.18.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: 6a332acce7880b6cbf53de706ef39df76d4823b588b1577a6642105ca00f3649
4
- data.tar.gz: 5fdc46d025cb2377502e6f9a5a9a4ba605f279616f36dc7e537bb79d6f0c0413
3
+ metadata.gz: 81c1365c2d9349d09a02ef4794693b7af091032572096308d9f0fd26b49f4cc0
4
+ data.tar.gz: 665e7731c7fc7e8a2dde7c2d9dac410411f98aa3875cb3fa7ba4482b1fa8ff9c
5
5
  SHA512:
6
- metadata.gz: 1b3bbdc8c899628541a77cecb10d679afe0ca31f18bb80ad8eabedfbcdf3d7851153515387084cd003e54500fc7fa1b07f6f50a9c8a9eb9bd0d122df2199d73d
7
- data.tar.gz: 123206e9012019d7d1274b97daeb83f5f093234ae6f0b44f6f888ed89a17d2b03d8dce234b0b811ae9e8fb6568ef1f0712d0ccc3385278a929fa09b53974916e
6
+ metadata.gz: ba0ff3dfdabfc35154b7c54a259eae9e2f34a053f327c940bcc13844995aa56d1a654605656f5a56b6732f543a238b207522636932e4fb4a707933065925740b
7
+ data.tar.gz: fc8240192183768510aff96e175c5c1fd329dfe23d5b6623b7e89529e1fafe6c6d2726335b34d81d13e275b2c6bcd38b27d0a65a98f891c808b6cede2bf0c0ec
@@ -19,6 +19,10 @@ module Resend
19
19
  Resend::Request.new(path, {}, "get").perform
20
20
  end
21
21
 
22
+ #
23
+ # List contacts in an audience
24
+ #
25
+ # @param audience_id [String] the audience id
22
26
  # https://resend.com/docs/api-reference/contacts/list-contacts
23
27
  def list(audience_id)
24
28
  path = "audiences/#{audience_id}/contacts"
@@ -37,9 +41,15 @@ module Resend
37
41
  Resend::Request.new(path, {}, "delete").perform
38
42
  end
39
43
 
44
+ #
45
+ # Update a contact
46
+ #
47
+ # @param params [Hash] the contact params
40
48
  # https://resend.com/docs/api-reference/contacts/update-contact
41
49
  def update(params)
42
- path = "audiences/#{params[:audience_id]}/contacts/#{params[:id]}"
50
+ raise ArgumentError, "id or email is required" if params[:id].nil? && params[:email].nil?
51
+
52
+ path = "audiences/#{params[:audience_id]}/contacts/#{params[:id] || params[:email]}"
43
53
  Resend::Request.new(path, params, "patch").perform
44
54
  end
45
55
  end
data/lib/resend/mailer.rb CHANGED
@@ -92,6 +92,11 @@ module Resend
92
92
  params
93
93
  end
94
94
 
95
+ # Remove nils from header values
96
+ def cleanup_headers(headers)
97
+ headers.delete_if { |_k, v| v.nil? }
98
+ end
99
+
95
100
  # Gets the values of the headers that are set through the `#mail` method
96
101
  #
97
102
  # @param Mail mail Rails Mail object
@@ -101,6 +106,7 @@ module Resend
101
106
  mail[:headers].unparsed_value.each do |k, v|
102
107
  params[k.to_s] = v
103
108
  end
109
+ cleanup_headers(params)
104
110
  params
105
111
  end
106
112
 
@@ -113,8 +119,7 @@ module Resend
113
119
  unignored_headers(mail).each do |h|
114
120
  params[h.name.to_s] = h.unparsed_value
115
121
  end
116
- # remove nil header values
117
- params.delete_if { |_k, v| v.nil? }
122
+ cleanup_headers(params)
118
123
  params
119
124
  end
120
125
 
@@ -35,6 +35,7 @@ module Resend
35
35
  }
36
36
 
37
37
  options[:body] = @body.to_json unless @body.empty?
38
+
38
39
  resp = HTTParty.send(@verb.to_sym, "#{BASE_URL}#{@path}", options)
39
40
 
40
41
  check_json!(resp)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Resend
4
- VERSION = "0.17.1"
4
+ VERSION = "0.18.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.17.1
4
+ version: 0.18.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-01-08 00:00:00.000000000 Z
11
+ date: 2025-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty