Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
resend (1.15.0)
resend (1.16.0)
base64
httparty (>= 0.22.0)

Expand Down
7 changes: 7 additions & 0 deletions lib/resend/broadcasts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ def cancel(broadcast_id = "")
Resend::Request.new(path, {}, "post").perform
end

# https://resend.com/docs/api-reference/broadcasts/duplicate-broadcast
# @note Creates a new draft with the same content as the source, named after it with " (copy)" appended.
def duplicate(broadcast_id = "")
path = "broadcasts/#{broadcast_id}/duplicate"
Resend::Request.new(path, {}, "post").perform
end

# https://resend.com/docs/api-reference/broadcasts/delete-broadcast
def remove(broadcast_id = "")
path = "broadcasts/#{broadcast_id}"
Expand Down
2 changes: 1 addition & 1 deletion lib/resend/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Resend
VERSION = "1.15.0"
VERSION = "1.16.0"
end
17 changes: 17 additions & 0 deletions spec/broadcasts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,23 @@
end
end

describe "duplicate" do
it "should duplicate broadcast" do
Comment thread
gabrielmfern marked this conversation as resolved.
resp = {
"object": "broadcast",
"id": "e169aa45-1ecf-4183-9955-b1499d5701d3"
}
expect(Resend::Request).to receive(:new).once do |path, _body, verb|
expect(path).to eql("broadcasts/559ac32e-9ef5-46fb-82a1-b76b840c0f7b/duplicate")
expect(verb).to eql("post")
double("req", perform: resp)
end
result = Resend::Broadcasts.duplicate("559ac32e-9ef5-46fb-82a1-b76b840c0f7b")
expect(result[:id]).to eql("e169aa45-1ecf-4183-9955-b1499d5701d3")
expect(result[:object]).to eql("broadcast")
end
end

describe "remove" do
it "should remove broadcast" do
allow_any_instance_of(Resend::Request).to receive(:perform).and_return("")
Expand Down