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:
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.
ShadeClientshould accept the same parameters as the global config and bind them to a single instance, which is then passed to resource methods.Proposed Steps:
src/shade/client.pywith aShadeClientdataclass/class.api_key,environment,api_base,timeout,max_retries.client=kwarg and fall back to global config if omitted.ShadeClient.from_env()factory that readsSHADE_API_KEYandSHADE_ENVIRONMENTfrom environment variables.Acceptance Criteria:
client = ShadeClient(api_key="sk_test_xxx")creates an isolated client.ShadeClientinstances with different keys can coexist without interfering.ShadeClient.from_env()readsSHADE_API_KEYfrom the environment correctly.api_keyon the instance when global is alsoNoneraisesAuthenticationError.