resend 1.9.0 → 1.11.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: 0d4fd70fd0f2eab7c555c5448fadede3d5393d8629e8e9edab9a606ee114157d
4
- data.tar.gz: 4f9507e590d7ea64b0d55df9ca840c9b6d8d0895ef0621d07153c3d6c2027a4a
3
+ metadata.gz: 64e11672300db0ff3bdc430fada0fbd8ca115a07d2bfbbd761ea95dacf1e5c80
4
+ data.tar.gz: 02d393546fb4316ae1f9a6da5682e7d7b71aaad6b36a1bf29a84e4ef1996336e
5
5
  SHA512:
6
- metadata.gz: 27ab0c3ba82126ddd1a4bf6c092b25a796c9975eedb20718947e2d2d1c70631f358d969a83701079dca6ae16ee38dd33316b58336ff3b1a4f98bed7d0e0e5648
7
- data.tar.gz: 456c3b77bc440bf672b3d50d9ed922246f9375ee51e4ce9442c5ca68178bf4a922ab2f945bb954b1487259a93c7f39014ad21891584e4a8f33899dc7695f05dc
6
+ metadata.gz: 714868b613882c10b8990bef7a06dcd132e5d29dbda076f84d13f5c69ffe60fed0518d694e67e5a7ce46bc9a4fe84352a418dfc8711020d04a307764bd3130de
7
+ data.tar.gz: 9465a51da2439c78eedaad4bf9ad5e411e6a1068fb5c28d8829c9f8a4fadeab23c7c4da5f3fc40af48b58c457eefe403cb57533ad79c0dbe2f3b0bf4f2837a60
@@ -21,6 +21,12 @@ module Resend
21
21
  path = "api-keys/#{api_key_id}"
22
22
  Resend::Request.new(path, {}, "delete").perform
23
23
  end
24
+
25
+ # https://resend.com/docs/api-reference/api-keys/update-api-key
26
+ def update(params)
27
+ path = "api-keys/#{params[:id]}"
28
+ Resend::Request.new(path, { name: params[:name] }, "patch").perform
29
+ end
24
30
  end
25
31
  end
26
32
  end
@@ -41,6 +41,12 @@ module Resend
41
41
  Resend::Request.new(path, {}, "get").perform
42
42
  end
43
43
 
44
+ # https://resend.com/docs/api-reference/broadcasts/list-broadcast-clicked-links
45
+ def clicked_links(broadcast_id = "", params = {})
46
+ path = Resend::PaginationHelper.build_paginated_path("broadcasts/#{broadcast_id}/clicked-links", params)
47
+ Resend::Request.new(path, {}, "get").perform
48
+ end
49
+
44
50
  def cancel(broadcast_id = "")
45
51
  path = "broadcasts/#{broadcast_id}/cancel"
46
52
  Resend::Request.new(path, {}, "post").perform
@@ -57,6 +63,25 @@ module Resend
57
63
  path = "broadcasts/#{broadcast_id}"
58
64
  Resend::Request.new(path, {}, "get").perform
59
65
  end
66
+
67
+ # https://resend.com/docs/api-reference/broadcasts/list-broadcast-recipients
68
+ # @param broadcast_id [String] the broadcast id
69
+ # @param params [Hash] the parameters
70
+ # @option params [String] :type the recipient event type to filter by (required):
71
+ # sent, delivered, opened, clicked, bounced, complained, unsubscribed, suppressed
72
+ # @option params [String] :email filter recipients by email address (optional)
73
+ # @option params [String] :bounce_type filter bounced recipients by bounce type (optional,
74
+ # only valid when type is bounced): permanent, transient, undetermined
75
+ # @option params [Integer] :limit the maximum number of results to return (optional)
76
+ # @option params [String] :after the cursor for pagination (optional)
77
+ # @option params [String] :before the cursor for pagination (optional)
78
+ def recipients(broadcast_id = "", params = {})
79
+ raise ArgumentError, "type is required" if params[:type].nil?
80
+
81
+ base_path = "broadcasts/#{broadcast_id}/recipients"
82
+ path = Resend::PaginationHelper.build_paginated_path(base_path, params)
83
+ Resend::Request.new(path, {}, "get").perform
84
+ end
60
85
  end
61
86
  end
62
87
  end
data/lib/resend/emails.rb CHANGED
@@ -32,6 +32,17 @@ module Resend
32
32
  Resend::Request.new(path, {}, "post").perform
33
33
  end
34
34
 
35
+ # Create a shareable link for a sent or received email.
36
+ #
37
+ # @param email_id [String] The email id (sent or received).
38
+ # @param params [Hash] Optional parameters
39
+ # @option params [String] :expires_in Human-readable duration (e.g. "10m", "2 hours",
40
+ # "1 day"). Defaults to "48h" and is capped at 48 hours.
41
+ def share(email_id, params = {})
42
+ path = "emails/#{email_id}/share"
43
+ Resend::Request.new(path, params, "post").perform
44
+ end
45
+
35
46
  # List emails with optional pagination.
36
47
  # see more: https://resend.com/docs/api-reference/emails/list-emails
37
48
  #
@@ -50,6 +61,64 @@ module Resend
50
61
 
51
62
  Resend::Request.new(path, query_params, "get").perform
52
63
  end
64
+
65
+ # Retrieve email metrics.
66
+ # see more: https://resend.com/docs/api-reference/emails/metrics
67
+ #
68
+ # @param options [Hash] Optional parameters for filtering and shaping the metrics response
69
+ # @option options [String] :start_date ISO 8601 date/datetime. Defaults to 6 days before :end_date
70
+ # @option options [String] :end_date ISO 8601 date/datetime. Defaults to now
71
+ # @option options [String] :timezone IANA timezone, e.g. "America/New_York". Defaults to "UTC"
72
+ # @option options [String] :granularity Bucket size used when :period is in :dimensions.
73
+ # One of "hourly", "daily", "weekly", "monthly". Defaults to "daily"
74
+ # @option options [Array<String>] :metrics Metrics to include. Defaults to all metrics.
75
+ # @option options [Array<String>] :dimensions Dimensions to break down by: "period", "domain",
76
+ # "email", "broadcast". Defaults to none, which returns totals only.
77
+ # @option options [Array<String>] :domain_id Restrict to these sending domain IDs (max 100)
78
+ # @option options [Array<String>] :email_id Restrict to these email IDs (max 100)
79
+ # @option options [Array<String>] :broadcast_id Restrict to these broadcast IDs (max 100)
80
+ def metrics(options = {})
81
+ path = "emails/metrics"
82
+ validate_metrics_options(options)
83
+ Resend::Request.new(path, build_metrics_query(options), "get").perform
84
+ end
85
+
86
+ private
87
+
88
+ # The `email` and `broadcast` dimensions/filters are mutually exclusive.
89
+ def validate_metrics_options(options)
90
+ dimensions = Array(options[:dimensions])
91
+ has_broadcast = dimensions.include?("broadcast") || !Array(options[:broadcast_id]).empty?
92
+ has_email = dimensions.include?("email") || !Array(options[:email_id]).empty?
93
+
94
+ return unless has_broadcast && has_email
95
+
96
+ raise ArgumentError,
97
+ "`broadcast`/`broadcast_id` cannot be combined with `email`/`email_id`"
98
+ end
99
+
100
+ # Builds the metrics query hash, filtering out nil values and joining
101
+ # list-style params (metrics, dimensions, domain_id, email_id, broadcast_id)
102
+ # into comma-separated strings as expected by the API.
103
+ def build_metrics_query(options)
104
+ query_params = {}
105
+
106
+ %i[start_date end_date timezone granularity].each do |key|
107
+ value = options[key]
108
+ query_params[key] = value unless blank?(value)
109
+ end
110
+
111
+ %i[metrics dimensions domain_id email_id broadcast_id].each do |key|
112
+ values = Array(options[key]).reject { |value| blank?(value) }
113
+ query_params[key] = values.join(",") unless values.empty?
114
+ end
115
+
116
+ query_params
117
+ end
118
+
119
+ def blank?(value)
120
+ value.nil? || value.to_s.empty?
121
+ end
53
122
  end
54
123
  end
55
124
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Resend
4
- VERSION = "1.9.0"
4
+ VERSION = "1.11.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resend
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derich Pacheco
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-08-18 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: base64
@@ -38,7 +37,6 @@ dependencies:
38
37
  - - ">="
39
38
  - !ruby/object:Gem::Version
40
39
  version: 0.22.0
41
- description:
42
40
  email: carlosderich@gmail.com
43
41
  executables: []
44
42
  extensions: []
@@ -85,7 +83,6 @@ homepage: https://github.com/resend/resend-ruby
85
83
  licenses:
86
84
  - MIT
87
85
  metadata: {}
88
- post_install_message:
89
86
  rdoc_options: []
90
87
  require_paths:
91
88
  - lib
@@ -100,8 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
97
  - !ruby/object:Gem::Version
101
98
  version: '0'
102
99
  requirements: []
103
- rubygems_version: 3.0.3.1
104
- signing_key:
100
+ rubygems_version: 4.0.16
105
101
  specification_version: 4
106
102
  summary: The Ruby and Rails SDK for resend.com
107
103
  test_files: []