READMEs: fix every sample that misstates the API

Merged
JE
4mo ago
+59-43

Six commits, one per SDK. Every defect below was proven against the real SDK before editing, and every corrected snippet was re-proven green. Nothing here touches behavior — READMEs plus five doc comments in Kotlin/Swift source that showed the same phantom signatures.

Ruby — todos.create takes todolist_id:, not project_id:

The Quick Start's documented call fails at argument binding, before any HTTP:

ArgumentError: unknown keyword: :project_id

The corrected call (with http_post stubbed on the service singleton) POSTs /todolists/67890/todos.json.

Go — five fences didn't compile

Each reproduced offline as the exact compiler error (scratch module + replace directive, GOPROXY=off); all corrected snippets go build + go vet clean:

cannot range over projects (variable of type *basecamp.ProjectListResult)   [both Quick Start programs]

not enough arguments in call to account.Campfires().List
	have (context.Context)
	want (context.Context, *basecamp.CampfireListOptions)
not enough arguments in call to account.Campfires().ListLines
	have (context.Context, int64)
	want (context.Context, int64, *basecamp.CampfireLineListOptions)

not enough arguments in call to account.Webhooks().List
	have (context.Context, int64)
	want (context.Context, int64, *basecamp.WebhookListOptions)

no new variables on left side of :=                                          [OTel fence redeclares hooks]

undefined: prometheus                                                        [chain-hooks fence]

Also "Requires Go 1.25 or later" → 1.26, matching go.mod. The README's fragment conventions (undeclared ctx, use(), top-level return err) are established style and stay.

Kotlin — error-handling sample didn't compile; tables lied

  • todos.get(projectId = 123, todoId = 456) — the generated signature is get(todoId: Long) (generated/services/todos.kt).
  • The when over sealed BasecampException covered 9 of 11 subclasses; a non-exhaustive when statement over a sealed subject is a compile error, and the SDK's own ErrorTest.kt pins all 11 branches ("This ensures all branches compile (exhaustive when)"). Added DiscoverySelection/DeviceFlow branches and their Error Types rows.
  • Configuration Options documented maxRetries/baseRetryDelay, but BasecampClientBuilder has no setter for either and the client constructor is internal — marked as fixed defaults.
  • consoleHooks sample output showed Projects.List; the generated OperationInfo emits Projects.ListProjects.
  • Same phantom todos.get in BasecampException/BasecampClient doc comments.

Swift — phantom arity plus an API that needs macOS 13

  • todos.get(projectId: 123, todoId: 456) — the generated signature is get(todoId: Int).
  • The same fence used Task.sleep(for: .seconds(...)) while Package.swift declares .macOS(.v12). Proven under a macOS 12 target:
error: 'sleep(for:tolerance:clock:)' is only available in macOS 13.0 or newer

Replaced with the nanoseconds form the SDK's own retry path uses (green under the same target). Also fixed the phantom signatures in BasecampError/AccountClient/Pagination doc comments.

TypeScript — list() auto-paginates; the docs claimed the opposite

"List methods return a single page of results by default" inverts reality. Behavioral proof against a stubbed fetch serving two pages:

HTTP calls: 2; items returned: 3; meta.totalCount: 3; Array.isArray: true
maxItems:2 -> items: 2; truncated: true

The Pagination section now leads with auto-pagination and ListResult/.meta, shows maxItems, and reframes fetchAllPages/paginateAll as the escape hatch for raw client.GET calls. The helper callbacks read (r) => r.json() as Promise<any[]> because bare r.json() is Promise<unknown> under the repo's strict/NodeNext config and fails tsc --noEmit; all three replacement blocks typecheck clean under that config.

All six SDKs — "45 services" → 46

Stale since EverythingService landed. Verified per SDK: 46 Kotlin accessors, 46 Swift accessors, 46 Ruby service classes (47 files minus base_service.rb), 46 Python service modules (excluding _base/_async_base), matching SPEC.md's counts.

Deliberately not touched

  • Install sections stay version-less (#495).
  • Root README — all six quick starts verified correct.
  • python/README.md Retry Behavior — current #502 text.
  • ruby/README.md Retry Behavior — defective but deserves the #502-style whole-section treatment; issue to follow.
  • Kotlin "2.0+" floor — repeated verbatim in CONTRIBUTING.md, so changing it is a policy call, not a doc fix.

Summary by cubic

Fix incorrect README code samples and doc comments across all SDKs to match real API signatures, pagination behavior, and compile-time constraints. No runtime changes; updates service count references to 46.

  • Bug Fixes
    • Ruby: todos.create uses todolist_id, not project_id.
    • Go: All snippets compile; iterate result.Projects, pass nil to Campfires/Webhooks list calls, fix OTel hooks reassignment (construct client after), add prometheus import; "Requires Go 1.26".
    • Kotlin: Use todos.get(todoId), make BasecampException sample exhaustive with DiscoverySelection/DeviceFlow; mark maxRetries/baseRetryDelay as fixed defaults; console hooks show Projects.ListProjects; fix doc comments.
    • Swift: Use todos.get(todoId), replace Task.sleep(for:) with nanoseconds for macOS 12; fix doc comments and the pagination example.
    • TypeScript: list() auto-paginates and returns a ListResult with .meta.totalCount and .truncated; show maxItems; update raw pagination examples using fetchAllPages/paginateAll from @37signals/basecamp with typed r.json().
    • All SDKs: "45 services" → 46 to reflect EverythingService.