Skip to content

Implement ShadeClient class for per-instance configuration #2

Description

@codebestia

Description:

While global config is convenient, multi-tenant applications (e.g. a SaaS acting on behalf of multiple merchants) need isolated client instances that carry their own credentials. ShadeClient should accept the same parameters as the global config and bind them to a single instance, which is then passed to resource methods.

Proposed Steps:

  • Create src/shade/client.py with a ShadeClient dataclass/class.
  • Constructor parameters: api_key, environment, api_base, timeout, max_retries.
  • Each resource class should accept an optional client= kwarg and fall back to global config if omitted.
  • Provide a ShadeClient.from_env() factory that reads SHADE_API_KEY and SHADE_ENVIRONMENT from environment variables.

Acceptance Criteria:

  • client = ShadeClient(api_key="sk_test_xxx") creates an isolated client.
  • Resource calls using this client use its credentials, not global config.
  • Two ShadeClient instances with different keys can coexist without interfering.
  • ShadeClient.from_env() reads SHADE_API_KEY from the environment correctly.
  • Missing api_key on the instance when global is also None raises AuthenticationError.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions