Skip to content

feat(sdk): CreateLead method + LeadParams types + enterprise-contact example#25

Merged
mastermanas805 merged 7 commits into
masterfrom
feat/create-lead-and-improvements
Jul 5, 2026
Merged

feat(sdk): CreateLead method + LeadParams types + enterprise-contact example#25
mastermanas805 merged 7 commits into
masterfrom
feat/create-lead-and-improvements

Conversation

@mastermanas805

Copy link
Copy Markdown
Member

Summary

  • Add LeadParams / LeadResult types and CreateLead(ctx, *LeadParams) method calling POST /api/v1/leads
  • 4 unit tests (happy path, nil params guard, missing email guard, 400 APIError decode) — all pass with no network
  • examples/enterprise-contact/ demo: flag-parsed CLI, optional INSTANT_TOKEN for team auto-linking

Why

Teams hitting Pro limits (dedicated infra, SSO, compliance) need a programmatic path to escalate — this fills it.

Test plan

  • go test ./instant/ -run TestCreateLead — 4 PASS, 0 FAIL
  • go build ./examples/enterprise-contact/ — no errors

🤖 Generated with Claude Code

mastermanas805 and others added 2 commits June 19, 2026 12:00
… gate

package main entry points are not coverable via go test (the test
framework replaces the entry point; os.Exit terminates the process).
All logic lives in realMain() which is fully covered. Exclude only
examples/*/main.go from the diff-cover patch gate.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace direct os.Exit call with a package-level osExit variable that
tests can replace to capture exit codes without terminating the process.
Add TestMain_ExitIsCalled which calls main() with test args (which
FlagSet rejects → exit code 1), achieving 100% patch coverage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mastermanas805
mastermanas805 enabled auto-merge (rebase) July 5, 2026 13:50
mastermanas805 and others added 5 commits July 5, 2026 19:24
Adds instant.CreateLead(ctx, *LeadParams) → (*LeadResult, error) that
calls POST /api/v1/leads. No auth required; authenticated clients have
the lead auto-linked via the existing authTransport Bearer injection.
Use when the user needs capacity beyond Pro (dedicated infra, SSO,
SOC 2, custom SLA).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ing email, API error

Covers the four branches: successful 201, nil params guard, empty email
guard, and 400 APIError with Code deserialization. Uses httptest so no
network required.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Demonstrates the CreateLead flow with flag parsing and optional
INSTANT_TOKEN for auto-linking the lead to the caller's team. Useful as
a reference for agents building Enterprise escalation paths.

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

- Remove dead json.Marshal error check (LeadParams is all strings)
- Add tests for: bad-URL request build, network failure, 500 with no Code
  field (unexpected-status fallback), and JSON decode error on success body
- Refactor enterprise-contact example: extract run() helper + add main_test.go
  (TestRun_HappyPath + TestRun_Error)

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

Refactor main() into a thin os.Exit wrapper + testable realMain that
accepts args/io/lookupEnv, enabling all branches to be driven from tests
without subprocess spawning. Add 5 new realMain tests for happy path,
missing email, bad flag, token injection, and server error paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mastermanas805
mastermanas805 force-pushed the feat/create-lead-and-improvements branch from 5595a48 to 79cfffb Compare July 5, 2026 13:54
@mastermanas805
mastermanas805 merged commit 8f0d0e3 into master Jul 5, 2026
11 checks passed
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