Skip to content

Expose the workspace url returned by the v1 API - #2

Open
mechelon wants to merge 1 commit into
mainfrom
workspace-url
Open

mechelon wants to merge 1 commit into
mainfrom
workspace-url

Conversation

@mechelon

Copy link
Copy Markdown
Member

The v1 API now returns a link on every workspace that opens it directly in Polyscope (beyondcode/polyscope-website#97). The SDK already picked it up as a dynamic property. But IDEs and PHPStan didn't know it existed, and reading it from an older API response raised an "Undefined property" warning. Now it's a declared, nullable property on the Workspace resource.

How to verify

  1. Point an app at this branch and fetch a workspace:
    $workspace = Polyscope::workspace('<id>');
    echo $workspace->url;
    Prints https://getpolyscope.com/servers/<server_id>/session?workspace=<id>.
  2. Polyscope::workspaces() and Polyscope::createWorkspace([...]) return the same url for that workspace.
  3. Open the link signed in as the server's owner: the workspace opens. The web app has to be built from beyondcode/polyscope#497 for this. Before that, the session page opens but the workspace isn't selected.

Automated coverage

  • url mapped on list, create and show: covered — test_listing_workspaces_maps_url in tests/PolyscopeSDKTest.php checks all three in one test
  • null when the API leaves url out: partly covered — same test. Without the property declared it reports a PHPUnit warning, not a failure, because phpunit.xml.dist doesn't set failOnWarning (checked: Tests: 1, Assertions: 4, Warnings: 1)

Measured: 15 tests, 82 assertions passing on PHP 8.4.27; PHPStan level 5 clean.

Technical notes

Follow-ups

  • beyondcode/polyscope-website: the "Getting a Single Workspace" example in resources/docs/integrations/laravel-php-sdk.md doesn't show $workspace->url yet.

The v1 API now returns a url on every workspace that opens it directly
in Polyscope (beyondcode/polyscope-website#97). Declaring it on the
Workspace resource gives IDE and PHPStan support and a null default
when an older API response leaves it out, instead of an undefined
property warning.
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.

1 participant