Skip to content

feat(networking): add getWorkflows list endpoint#6853

Merged
facumenzella merged 8 commits into
mainfrom
port/android-3509
May 28, 2026
Merged

feat(networking): add getWorkflows list endpoint#6853
facumenzella merged 8 commits into
mainfrom
port/android-3509

Conversation

@facumenzella

@facumenzella facumenzella commented May 27, 2026

Copy link
Copy Markdown
Member

Summary

Port of RevenueCat/purchases-android#3509

  • Adds WorkflowSummary (id, displayName, offeringId?, prefetch) and WorkflowsListResponse models with Codable + HTTPResponseBody conformances
  • Adds GetWorkflowsListOperation and WorkflowsListCallback for GET /v1/subscribers/{userId}/workflows
  • Adds WorkflowsAPI.getWorkflows(appUserID:isAppBackgrounded:completion:) with in-flight request deduplication and background-aware delay (same pattern as getWorkflow)
  • Adds BackendGetWorkflowsListTests covering: HTTP call, background delay, request deduplication, response deserialization, network error, empty userID guard

Notes

  • getWorkflows has supportsSignatureVerification=false and needsNonceForSigning=false, matching Android (no signing for the list endpoint)
  • The singular getWorkflow (by ID) retains supportsSignatureVerification=true
  • Snapshot tests will be recorded on first CI run

Note

Low Risk
Additive networking and models following existing workflow GET patterns; no purchase or identity logic changes. Reviewers should confirm list-endpoint signature/ETag flags match backend expectations (list is grouped with verified GET paths).

Overview
Adds client support for listing a subscriber’s workflows via GET /v1/subscribers/{appUserID}/workflows, including an optional type query filter.

New WorkflowSummary / WorkflowsListResponse models decode list payloads (with prefetch defaulting to false and tolerant handling of unknown JSON keys). GetWorkflowsListOperation and WorkflowsListCallback mirror the existing single-workflow fetch: cacheable in-flight deduplication keyed by user + type, empty appUserID short-circuit, and background jitter delay. WorkflowsAPI.getWorkflows wires this through HTTPRequest.Path.getWorkflows, with ETag and auth aligned to other subscriber GETs.

Tests add BackendGetWorkflowsListTests, decoding coverage, MockWorkflowsAPI stubs, and snapshot fixes so default list calls use /workflows while type=paywall keeps the query string.

Reviewed by Cursor Bugbot for commit bb97ebf. Bugbot is set up for automated code reviews on this repo. Configure here.

Port of RevenueCat/purchases-android#3509

Adds WorkflowSummary and WorkflowsListResponse models, GetWorkflowsListOperation,
and WorkflowsAPI.getWorkflows() to support listing a subscriber's workflows via
GET /v1/subscribers/{userId}/workflows. Includes request deduplication and
background-aware delay, matching the existing getWorkflow(by id) pattern.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
facumenzella and others added 4 commits May 27, 2026 12:23
Register the two new source files in the root RevenueCat.xcodeproj so
xcodebuild (used by CI) can find them. SPM discovers them automatically
but the tracked root project needs explicit file references and build
file entries.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…point

The getWorkflows endpoint does not send a type filter query parameter.
The snapshots were created from an earlier design and needed to be
updated to match the actual request URL.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…eCase

JSONDecoder.default uses .convertFromSnakeCase, which converts JSON keys to
camelCase before matching against CodingKey raw values. The explicit CodingKeys
had snake_case raw values (e.g. "display_name"), causing a mismatch since the
decoder would convert display_name to displayName before the lookup.

Removing the explicit CodingKeys lets Swift synthesize them with camelCase raw
values, which correctly match the converted keys.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@facumenzella facumenzella marked this pull request as ready for review May 27, 2026 13:26
@facumenzella facumenzella requested a review from a team as a code owner May 27, 2026 13:26

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 03263e2. Configure here.

Comment thread Sources/Networking/HTTPClient/HTTPRequestPath.swift Outdated
…tness tests

- Add optional `type: String?` parameter to `getWorkflows` path, operation,
  API method, and mock, matching Android PR #3509 which supports
  `?type=<value>` query filtering on the list endpoint
- Include `type` in the operation deduplication cache key so calls with
  different types are not coalesced
- Add `testGetWorkflowsWithTypePassesQueryParameter` with snapshots for all
  OS variants
- Add `WorkflowSummaryDecodingTests` covering explicit-null `offering_id`,
  absent `prefetch` default, and unknown-field tolerance for both
  `WorkflowSummary` and `WorkflowsListResponse`
- Remove unnecessary `import Foundation` from `WorkflowsListCallback.swift`

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@vegaro vegaro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should make sure it uses signature verification before merging. Otherwise it looks good after a couple nits

Comment thread Sources/Networking/Operations/GetWorkflowsListOperation.swift Outdated
Comment thread Sources/Networking/Operations/GetWorkflowsListOperation.swift Outdated
…ache key separator and indentation

- Move .getWorkflows to supportsSignatureVerification=true, matching .getWorkflow and Android PR (#3509)
- Add "\n" separator between appUserID and type in individualizedCacheKeyPart to prevent collision
- Fix indentation of factory closure closing brace and label to match GetWorkflowOperation pattern

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@facumenzella facumenzella enabled auto-merge (squash) May 28, 2026 05:21
@facumenzella facumenzella merged commit a3ea621 into main May 28, 2026
17 of 20 checks passed
@facumenzella facumenzella deleted the port/android-3509 branch May 28, 2026 05:31
rickvdl added a commit that referenced this pull request May 28, 2026
…stTests (#6861)

PR #6853 added getWorkflows list tests with snapshots for iOS 16-18, 26,
macOS, tvOS, and watchOS, but omitted iOS 14 and iOS 15. The run-test-ios-15-and-14
CI job fails because swift-snapshot-testing finds no reference files for the
6 new testGetWorkflows* tests on those platforms.

iOS 14/15 use StoreKit 1 (X-StoreKit-Version: 1, X-StoreKit2-Enabled: false),
matching the pattern of existing iOS14/15 snapshots in this suite.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants