Skip to content

feat: add support for templates API#92

Merged
jayanratna merged 7 commits intomainfrom
templates
Oct 31, 2025
Merged

feat: add support for templates API#92
jayanratna merged 7 commits intomainfrom
templates

Conversation

@jayanratna
Copy link
Copy Markdown
Collaborator

@jayanratna jayanratna commented Oct 28, 2025

This PR adds support for the templates API.


Summary by cubic

Add full support for the Templates API, including CRUD, publish, and duplicate operations. Also adds stricter ID validation for single-resource requests.

  • New Features

    • New templates service: get, create, list, update, remove, publish, duplicate.
    • New Template resource with typed properties.
    • Client and ServiceFactory wired to expose templates; Payload helpers for publish/duplicate send an empty JSON body ({}).
  • Bug Fixes

    • Payload::get now throws an InvalidArgumentException when the ID is an empty string.

Written for commit 04a3612. Summary will update automatically on new commits.

@jayanratna jayanratna marked this pull request as ready for review October 28, 2025 19:55
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 11 files

Prompt for AI agents (all 3 issues)

Understand the root cause of the following 3 issues and fix them.


<file name="src/Template.php">

<violation number="1" location="src/Template.php:13">
`$published_at` can be null for draft templates, so this docblock should allow null to keep type information accurate for consumers.</violation>
</file>

<file name="tests/Fixtures/Template.php">

<violation number="1" location="tests/Fixtures/Template.php:21">
The first list entry uses the variable ID instead of the template ID, so the fixture data is inconsistent with template() and can break tests or clients relying on matching IDs.</violation>
</file>

<file name="tests/Transporters/HttpTransporter.php">

<violation number="1" location="tests/Transporters/HttpTransporter.php:215">
The UnserializableResponse thrown for an empty JSON body uses the message &#39;Empty response body&#39;, but this assertion expects &#39;Empty&#39;, so the test will always fail. Update the expected message to match the actual exception text.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

'text' => 'Hello, world!',
'variables' => [
[
'id' => 'e169aa45-1ecf-4183-9955-b1499d5701d3',
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first list entry uses the variable ID instead of the template ID, so the fixture data is inconsistent with template() and can break tests or clients relying on matching IDs.

Prompt for AI agents
Address the following comment on tests/Fixtures/Template.php at line 21:

<comment>The first list entry uses the variable ID instead of the template ID, so the fixture data is inconsistent with template() and can break tests or clients relying on matching IDs.</comment>

<file context>
@@ -0,0 +1,58 @@
+        &#39;text&#39; =&gt; &#39;Hello, world!&#39;,
+        &#39;variables&#39; =&gt; [
+            [
+                &#39;id&#39; =&gt; &#39;e169aa45-1ecf-4183-9955-b1499d5701d3&#39;,
+                &#39;key&#39; =&gt; &#39;user_name&#39;,
+                &#39;type&#39; =&gt; &#39;string&#39;,
</file context>
Fix with Cubic

jayanratna and others added 4 commits October 29, 2025 16:24
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
@jayanratna jayanratna merged commit cdb0c52 into main Oct 31, 2025
6 checks passed
@jayanratna jayanratna deleted the templates branch October 31, 2025 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants