Skip to content

Add client meta add endpoint#22

Open
Arittra-Bag wants to merge 2 commits into
mainfrom
feat/client-meta-api
Open

Add client meta add endpoint#22
Arittra-Bag wants to merge 2 commits into
mainfrom
feat/client-meta-api

Conversation

@Arittra-Bag
Copy link
Copy Markdown
Collaborator

Closes: #13

Copilot AI review requested due to automatic review settings May 18, 2026 13:03
@Arittra-Bag
Copy link
Copy Markdown
Collaborator Author

Verified against live WP Cloud client meta API.

Input tested:

  • add_meta("webhook_url", "https://example.com/sdk-add-meta-test-1") when webhook_url was absent.
  • add_meta("webhook_url", "https://example.com/sdk-add-meta-test-2") again while the key already existed.
  • set_meta("webhook_url", original_value) to restore the original webhook URL.

Observed:

  • First add_meta() created the key successfully.
  • Duplicate add_meta() also succeeded and overwrote the value.
  • Original webhook_url was restored successfully.

Conclusion:
add_meta() correctly hits the new /client-meta/{client}/{key}/add endpoint, but live API behavior for duplicate webhook_url is overwrite/upsert, not InvalidRequestError. I’m leaving SDK behavior API-authoritative rather than adding client-side duplicate checks.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds the client metadata add operation so SDK consumers can create metadata keys without overwriting existing values.

Changes:

  • Adds ClientClient.add_meta(...) for POST /client-meta/{client}/{key}/add.
  • Clarifies set_meta(...) documentation as update/overwrite behavior and cross-references add_meta.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Arittra-Bag
Copy link
Copy Markdown
Collaborator Author

[1] add_meta uses /add and succeeds
ok
[2] add_meta surfaces API 400 as InvalidRequestError
ok: [400] Meta key already exists
[3] set_meta still uses /update
ok
[4] docstrings cross-reference
ok

I also ran a live WP Cloud smoke test. add_meta() created webhook_url when absent, set_meta() updated it, and the original webhook value was restored afterward.

Please note: live WP Cloud currently treats duplicate add for webhook_url as overwrite/upsert rather than returning 400. Since the SDK correctly calls the documented /add endpoint and inherited error handling already surfaces API 400s as InvalidRequestError, I kept the SDK API-authoritative and did not add client-side duplicate checks, as also mentioned in the previous comment - #22 (comment).

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.

feat(api): add client.client.add_meta (create-if-absent) alongside set_meta (update-only)

2 participants