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
5 changes: 5 additions & 0 deletions lib/resend/automations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ def remove(automation_id = "")
Resend::Request.new("automations/#{automation_id}", {}, "delete").perform
end

# https://resend.com/docs/api-reference/automations/duplicate-automation
def duplicate(automation_id = "")
Resend::Request.new("automations/#{automation_id}/duplicate", {}, "post").perform
end

# https://resend.com/docs/api-reference/automations/stop-automation
def stop(automation_id = "")
Resend::Request.new("automations/#{automation_id}/stop", {}, "post").perform
Expand Down
20 changes: 20 additions & 0 deletions spec/automations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,26 @@
end
end

describe "duplicate" do
it "should duplicate an automation" do
resp = { object: "automation", id: "e169aa45-1ecf-4183-9955-b1499d5701d3" }
allow_any_instance_of(Resend::Request).to receive(:perform).and_return(resp)
result = Resend::Automations.duplicate(automation_id)
expect(result[:object]).to eql("automation")
expect(result[:id]).to eql("e169aa45-1ecf-4183-9955-b1499d5701d3")
end

it "should use POST /automations/:id/duplicate" do
req = double("req", perform: { id: automation_id })
expect(Resend::Request).to receive(:new).once do |path, _body, verb|
expect(path).to eql("automations/#{automation_id}/duplicate")
expect(verb).to eql("post")
req
end
Resend::Automations.duplicate(automation_id)
end
end

describe "stop" do
it "should stop an automation" do
resp = { object: "automation", id: automation_id, status: "disabled" }
Expand Down