Skip to content

connect() Factory #117

@derpixler

Description

@derpixler

API Reference: Zammad API Authentication

The one-line entry point. ZammadClient::connect() accepts named parameters — exactly one auth method must be provided:

Parameter Auth Method Header
token: HTTP Token Authorization: Token token=...
oauth2: OAuth2 Authorization: Bearer ...
user:+pass: Basic Auth Authorization: Basic base64(user:pass)

Throws InvalidArgumentException when zero or multiple auth methods are provided. Auto-wires Guzzle → RetryAfterMiddlewareRequestHandler internally — the caller gets a fully configured client.

Sets User-Agent: Zammad API PHP on every request. Optional debug: true (Guzzle debug to stdout) and verifySsl: false (disable TLS verification for development).

The DI constructor new ZammadClient($handler) remains available for containers — connect() is the sugar, not a replacement.

Acceptance Criteria

  • Testing: ZammadClientTest — testConnectTokenAuth sets Authorization header, testConnectOAuth2 sets Bearer, testConnectBasicAuth sets Basic, User-Agent header present, debug and verifySsl options passed to Guzzle
  • Documentation in README: README "Quick Start" — all three auth methods (token, oauth2, user+pass) shown

Depends on

Produces

  • ZammadClient (connect method)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Task.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions