-
Notifications
You must be signed in to change notification settings - Fork 9
feat: Impl templates API #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
13 issues found across 4 files
Prompt for AI agents (all 13 issues)
Understand the root cause of the following 13 issues and fix them.
<file name="lib/resend/templates.rb">
<violation number="1" location="lib/resend/templates.rb:20">
The `update` method signature diverges from the established pattern in other API modules like `Domains` and `Emails`. To maintain consistency across the SDK, this method should accept a single `params` hash and derive the `template_id` from it, rather than requiring the ID as a separate argument.</violation>
</file>
<file name="spec/templates_spec.rb">
<violation number="1" location="spec/templates_spec.rb:11">
Rule violated: **No `should` in tests**
Rename the test description to avoid “should”; use direct phrasing like “creates template”.</violation>
<violation number="2" location="spec/templates_spec.rb:26">
Rule violated: **No `should` in tests**
Use a direct, declarative test description instead of phrasing with “should”; for example, “creates template with variables”.</violation>
<violation number="3" location="spec/templates_spec.rb:82">
Rule violated: **No `should` in tests**
Change the description to declarative language, e.g., “retrieves a template by ID”.</violation>
<violation number="4" location="spec/templates_spec.rb:127">
Rule violated: **No `should` in tests**
Rephrase this test description without “should”; use direct wording like “retrieves a template by alias”.</violation>
<violation number="5" location="spec/templates_spec.rb:155">
Rule violated: **No `should` in tests**
Switch to direct phrasing for the test description, such as “updates a template”.</violation>
<violation number="6" location="spec/templates_spec.rb:170">
Rule violated: **No `should` in tests**
Adjust the test name to a declarative statement, for example “updates a template with variables”.</violation>
<violation number="7" location="spec/templates_spec.rb:192">
Rule violated: **No `should` in tests**
Rewrite the test description without “should”; e.g., “updates a template by alias”.</violation>
<violation number="8" location="spec/templates_spec.rb:209">
Rule violated: **No `should` in tests**
Use direct language in the test description—“publishes a template by ID”.</violation>
<violation number="9" location="spec/templates_spec.rb:233">
Rule violated: **No `should` in tests**
Update the test name to a declarative form such as “duplicates a template by ID”.</violation>
<violation number="10" location="spec/templates_spec.rb:244">
Rule violated: **No `should` in tests**
Replace “should” with direct wording like “duplicates a template by alias”.</violation>
<violation number="11" location="spec/templates_spec.rb:257">
Rule violated: **No `should` in tests**
Use declarative language for the test name, e.g., “lists templates”.</violation>
<violation number="12" location="spec/templates_spec.rb:313">
Rule violated: **No `should` in tests**
Change the description to direct phrasing, such as “removes template by ID”.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
| end | ||
|
|
||
| # https://resend.com/docs/api-reference/templates/update-template | ||
| def update(template_id, params = {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The update method signature diverges from the established pattern in other API modules like Domains and Emails. To maintain consistency across the SDK, this method should accept a single params hash and derive the template_id from it, rather than requiring the ID as a separate argument.
Prompt for AI agents
Address the following comment on lib/resend/templates.rb at line 20:
<comment>The `update` method signature diverges from the established pattern in other API modules like `Domains` and `Emails`. To maintain consistency across the SDK, this method should accept a single `params` hash and derive the `template_id` from it, rather than requiring the ID as a separate argument.</comment>
<file context>
@@ -0,0 +1,50 @@
+ end
+
+ # https://resend.com/docs/api-reference/templates/update-template
+ def update(template_id, params = {})
+ path = "templates/#{template_id}"
+ Resend::Request.new(path, params, "patch").perform
</file context>
| expect(result[:object]).to eql("template") | ||
| end | ||
|
|
||
| it "should update a template by alias" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rule violated: No should in tests
Rewrite the test description without “should”; e.g., “updates a template by alias”.
Prompt for AI agents
Address the following comment on spec/templates_spec.rb at line 192:
<comment>Rewrite the test description without “should”; e.g., “updates a template by alias”.</comment>
<file context>
@@ -0,0 +1,337 @@
+ expect(result[:object]).to eql("template")
+ end
+
+ it "should update a template by alias" do
+ resp = {
+ "id": "34a080c9-b17d-4187-ad80-5af20266e535",
</file context>
| it "should update a template by alias" do | |
| it "updates a template by alias" do |
| expect(result[:object]).to eql("template") | ||
| end | ||
|
|
||
| it "should update a template with variables" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rule violated: No should in tests
Adjust the test name to a declarative statement, for example “updates a template with variables”.
Prompt for AI agents
Address the following comment on spec/templates_spec.rb at line 170:
<comment>Adjust the test name to a declarative statement, for example “updates a template with variables”.</comment>
<file context>
@@ -0,0 +1,337 @@
+ expect(result[:object]).to eql("template")
+ end
+
+ it "should update a template with variables" do
+ resp = {
+ "id": "34a080c9-b17d-4187-ad80-5af20266e535",
</file context>
| it "should update a template with variables" do | |
| it "updates a template with variables" do |
| end | ||
|
|
||
| describe "update" do | ||
| it "should update a template" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rule violated: No should in tests
Switch to direct phrasing for the test description, such as “updates a template”.
Prompt for AI agents
Address the following comment on spec/templates_spec.rb at line 155:
<comment>Switch to direct phrasing for the test description, such as “updates a template”.</comment>
<file context>
@@ -0,0 +1,337 @@
+ end
+
+ describe "update" do
+ it "should update a template" do
+ resp = {
+ "id": "34a080c9-b17d-4187-ad80-5af20266e535",
</file context>
| it "should update a template" do | |
| it "updates a template" do |
| expect(template[:variables][0]['fallback_value']).to eql("John Doe") | ||
| end | ||
|
|
||
| it "should retrieve a template by alias" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rule violated: No should in tests
Rephrase this test description without “should”; use direct wording like “retrieves a template by alias”.
Prompt for AI agents
Address the following comment on spec/templates_spec.rb at line 127:
<comment>Rephrase this test description without “should”; use direct wording like “retrieves a template by alias”.</comment>
<file context>
@@ -0,0 +1,337 @@
+ expect(template[:variables][0]['fallback_value']).to eql("John Doe")
+ end
+
+ it "should retrieve a template by alias" do
+ resp = {
+ "object": "template",
</file context>
| it "should retrieve a template by alias" do | |
| it "retrieves a template by alias" do |
| end | ||
|
|
||
| describe "remove" do | ||
| it "should remove template by ID" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rule violated: No should in tests
Change the description to direct phrasing, such as “removes template by ID”.
Prompt for AI agents
Address the following comment on spec/templates_spec.rb at line 313:
<comment>Change the description to direct phrasing, such as “removes template by ID”.</comment>
<file context>
@@ -0,0 +1,337 @@
+ end
+
+ describe "remove" do
+ it "should remove template by ID" do
+ resp = {
+ "object": "template",
</file context>
| it "should remove template by ID" do | |
| it "removes template by ID" do |
| end | ||
|
|
||
| describe "list" do | ||
| it "should list templates" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rule violated: No should in tests
Use declarative language for the test name, e.g., “lists templates”.
Prompt for AI agents
Address the following comment on spec/templates_spec.rb at line 257:
<comment>Use declarative language for the test name, e.g., “lists templates”.</comment>
<file context>
@@ -0,0 +1,337 @@
+ end
+
+ describe "list" do
+ it "should list templates" do
+ resp = {
+ "object": "list",
</file context>
| it "should list templates" do | |
| it "lists templates" do |
| expect(result[:object]).to eql("template") | ||
| end | ||
|
|
||
| it "should duplicate a template by alias" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rule violated: No should in tests
Replace “should” with direct wording like “duplicates a template by alias”.
Prompt for AI agents
Address the following comment on spec/templates_spec.rb at line 244:
<comment>Replace “should” with direct wording like “duplicates a template by alias”.</comment>
<file context>
@@ -0,0 +1,337 @@
+ expect(result[:object]).to eql("template")
+ end
+
+ it "should duplicate a template by alias" do
+ resp = {
+ "id": "e169aa45-1ecf-4183-9955-b1499d5701d3",
</file context>
| it "should duplicate a template by alias" do | |
| it "duplicates a template by alias" do |
| end | ||
|
|
||
| describe "duplicate" do | ||
| it "should duplicate a template by ID" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rule violated: No should in tests
Update the test name to a declarative form such as “duplicates a template by ID”.
Prompt for AI agents
Address the following comment on spec/templates_spec.rb at line 233:
<comment>Update the test name to a declarative form such as “duplicates a template by ID”.</comment>
<file context>
@@ -0,0 +1,337 @@
+ end
+
+ describe "duplicate" do
+ it "should duplicate a template by ID" do
+ resp = {
+ "id": "e169aa45-1ecf-4183-9955-b1499d5701d3",
</file context>
| it "should duplicate a template by ID" do | |
| it "duplicates a template by ID" do |
| end | ||
|
|
||
| describe "publish" do | ||
| it "should publish a template by ID" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rule violated: No should in tests
Use direct language in the test description—“publishes a template by ID”.
Prompt for AI agents
Address the following comment on spec/templates_spec.rb at line 209:
<comment>Use direct language in the test description—“publishes a template by ID”.</comment>
<file context>
@@ -0,0 +1,337 @@
+ end
+
+ describe "publish" do
+ it "should publish a template by ID" do
+ resp = {
+ "id": "34a080c9-b17d-4187-ad80-5af20266e535",
</file context>
| it "should publish a template by ID" do | |
| it "publishes a template by ID" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
Summary by cubic
Implements a Templates API in the Ruby SDK to manage email templates end-to-end. Enables creating, editing, publishing, duplicating, listing, and deleting templates.