+
+
+## Summary
+
+Bolt API Reference: Postman Collection:
+
+[](https://god.gw.postman.com/run-collection/9136127-55d2bde1-a248-473f-95b5-64cfd02fb445?action=collection%2Ffork&collection-url=entityId%3D9136127-55d2bde1-a248-473f-95b5-64cfd02fb445%26entityType%3Dcollection%26workspaceId%3D78beee89-4238-4c5f-bd1f-7e98978744b4#?env%5BBolt%20Sandbox%20Environment%5D=W3sia2V5IjoiYXBpX2Jhc2VfdXJsIiwidmFsdWUiOiJodHRwczovL2FwaS1zYW5kYm94LmJvbHQuY29tIiwidHlwZSI6ImRlZmF1bHQiLCJlbmFibGVkIjp0cnVlfSx7ImtleSI6InRrX2Jhc2UiLCJ2YWx1ZSI6Imh0dHBzOi8vc2FuZGJveC5ib2x0dGsuY29tIiwidHlwZSI6ImRlZmF1bHQiLCJlbmFibGVkIjp0cnVlfSx7ImtleSI6ImFwaV9rZXkiLCJ2YWx1ZSI6IjxyZXBsYWNlIHdpdGggeW91ciBCb2x0IFNhbmRib3ggQVBJIGtleT4iLCJ0eXBlIjoic2VjcmV0IiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJwdWJsaXNoYWJsZV9rZXkiLCJ2YWx1ZSI6IjxyZXBsYWNlIHdpdGggeW91ciBCb2x0IFNhbmRib3ggcHVibGlzaGFibGUga2V5PiIsInR5cGUiOiJkZWZhdWx0IiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJkaXZpc2lvbl9pZCIsInZhbHVlIjoiPHJlcGxhY2Ugd2l0aCB5b3VyIEJvbHQgU2FuZGJveCBwdWJsaWMgZGl2aXNpb24gSUQ+IiwidHlwZSI6ImRlZmF1bHQiLCJlbmFibGVkIjp0cnVlfV0=)
+
+## About
+ A comprehensive Bolt API reference for interacting with Transactions, Orders, Product Catalog, Configuration, Testing, and much more.
+
+ Note: You must also reference the [Merchant Callback API](https://github.com/BoltApp/Bolt-Python-SDK/blob/master//api-merchant) when building a managed checkout custom cart integration
+
+
+
+## Table of Contents
+
+* [bolt-api-sdk](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/#bolt-api-sdk)
+ * [About](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/#about)
+ * [SDK Installation](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/#sdk-installation)
+ * [IDE Support](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/#ide-support)
+ * [SDK Example Usage](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/#sdk-example-usage)
+ * [Authentication](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/#authentication)
+ * [Available Resources and Operations](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/#available-resources-and-operations)
+ * [Retries](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/#retries)
+ * [Error Handling](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/#error-handling)
+ * [Server Selection](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/#server-selection)
+ * [Custom HTTP Client](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/#custom-http-client)
+ * [Resource Management](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/#resource-management)
+ * [Debugging](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/#debugging)
+* [Development](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/#development)
+ * [Maturity](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/#maturity)
+ * [Contributions](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/#contributions)
+
+
+
+
+## SDK Installation
+
+> [!NOTE]
+> **Python version upgrade policy**
+>
+> Once a Python version reaches its [official end of life date](https://devguide.python.org/versions/), a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated.
+
+The SDK can be installed with *uv*, *pip*, or *poetry* package managers.
+
+### uv
+
+*uv* is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.
+
+```bash
+uv add bolt-api-sdk
+```
+
+### PIP
+
+*PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
+
+```bash
+pip install bolt-api-sdk
+```
+
+### Poetry
+
+*Poetry* is a modern tool that simplifies dependency management and package publishing by using a single `pyproject.toml` file to handle project metadata and dependencies.
+
+```bash
+poetry add bolt-api-sdk
+```
+
+### Shell and script usage with `uv`
+
+You can use this SDK in a Python shell with [uv](https://docs.astral.sh/uv/) and the `uvx` command that comes with it like so:
+
+```shell
+uvx --from bolt-api-sdk python
+```
+
+It's also possible to write a standalone Python script without needing to set up a whole project like so:
+
+```python
+#!/usr/bin/env -S uv run --script
+# /// script
+# requires-python = ">=3.10"
+# dependencies = [
+# "bolt-api-sdk",
+# ]
+# ///
+
+from bolt_api_sdk import Bolt
+
+sdk = Bolt(
+ # SDK arguments
+)
+
+# Rest of script here...
+```
+
+Once that is saved to a file, you can run it with `uv run script.py` where
+`script.py` can be replaced with the actual file name.
+
+
+
+## IDE Support
+
+### PyCharm
+
+Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.
+
+- [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
+
+
+
+## SDK Example Usage
+
+### Example
+
+```python
+# Synchronous Example
+from bolt_api_sdk import Bolt, models
+import os
+
+
+with Bolt() as bolt:
+
+ res = bolt.account.get_account(security=models.GetAccountSecurity(
+ o_auth=os.getenv("BOLT_O_AUTH", ""),
+ x_api_key=os.getenv("BOLT_X_API_KEY", ""),
+ ))
+
+ # Handle response
+ print(res)
+```
+
+
+
+The same SDK client can also be used to make asynchronous requests by importing asyncio.
+
+```python
+# Asynchronous Example
+import asyncio
+from bolt_api_sdk import Bolt, models
+import os
+
+async def main():
+
+ async with Bolt() as bolt:
+
+ res = await bolt.account.get_account_async(security=models.GetAccountSecurity(
+ o_auth=os.getenv("BOLT_O_AUTH", ""),
+ x_api_key=os.getenv("BOLT_X_API_KEY", ""),
+ ))
+
+ # Handle response
+ print(res)
+
+asyncio.run(main())
+```
+
+
+
+## Authentication
+
+### Per-Client Security Schemes
+
+This SDK supports the following security schemes globally:
+
+| Name | Type | Scheme | Environment Variable |
+| ----------- | ------ | ------------ | -------------------- |
+| `x_api_key` | apiKey | API key | `BOLT_X_API_KEY` |
+| `o_auth` | oauth2 | OAuth2 token | `BOLT_O_AUTH` |
+
+You can set the security parameters through the `security` optional parameter when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:
+```python
+from bolt_api_sdk import Bolt, models
+import os
+
+
+with Bolt(
+ security=models.Security(
+ x_api_key=os.getenv("BOLT_X_API_KEY", ""),
+ ),
+) as bolt:
+
+ res = bolt.account.create_account(create_account_input={
+ "addresses": [
+ {
+ "company": "Bolt",
+ "country": "United States",
+ "country_code": "US",
+ "door_code": "123456",
+ "email": "alan.watts@example.com",
+ "first_name": "Alan",
+ "last_name": "Watts",
+ "locality": "Brooklyn",
+ "name": "Alan Watts",
+ "phone": "+12125550199",
+ "postal_code": "10044",
+ "region": "NY",
+ "region_code": "NY",
+ "street_address1": "888 main street",
+ "street_address2": "apt 3021",
+ "street_address3": "c/o Alicia Watts",
+ "street_address4": "Bridge Street Apartment Building B",
+ "metadata": {},
+ },
+ ],
+ "payment_methods": [
+ {
+ "billing_address": {
+ "company": "Bolt",
+ "country": "United States",
+ "country_code": "US",
+ "default": True,
+ "door_code": "123456",
+ "email": "alan.watts@example.com",
+ "first_name": "Alan",
+ "last_name": "Watts",
+ "locality": "Brooklyn",
+ "name": "Alan Watts",
+ "phone": "+12125550199",
+ "postal_code": "10044",
+ "region": "NY",
+ "region_code": "NY",
+ "street_address1": "888 main street",
+ "street_address2": "apt 3021",
+ "street_address3": "c/o Alicia Watts",
+ "street_address4": "Bridge Street Apartment Building B",
+ },
+ "billing_address_id": None,
+ "bin": "411111",
+ "expiration": "2025-11",
+ "last4": "1234",
+ "metadata": {},
+ "postal_code": "10044",
+ "token": "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0",
+ "token_type": models.PaymentMethodAccountTokenType.BOLT,
+ },
+ ],
+ "profile": {
+ "email": "alan.watts@example.com",
+ "first_name": "Alan",
+ "last_name": "Watts",
+ "metadata": {},
+ "phone": "+12125550199",
+ },
+ })
+
+ # Handle response
+ print(res)
+
+```
+
+### Per-Operation Security Schemes
+
+Some operations in this SDK require the security scheme to be specified at the request level. For example:
+```python
+from bolt_api_sdk import Bolt, models
+import os
+
+
+with Bolt() as bolt:
+
+ res = bolt.account.get_account(security=models.GetAccountSecurity(
+ o_auth=os.getenv("BOLT_O_AUTH", ""),
+ x_api_key=os.getenv("BOLT_X_API_KEY", ""),
+ ))
+
+ # Handle response
+ print(res)
+
+```
+
+
+
+## Available Resources and Operations
+
+
+Available methods
+
+### [Account](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/account/README.md)
+
+* [get_account](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/account/README.md#get_account) - Get Account Details
+* [create_account](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/account/README.md#create_account) - Create Bolt Account
+* [update_account_profile](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/account/README.md#update_account_profile) - Update Profile
+* [add_address](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/account/README.md#add_address) - Add Address
+* [delete_address](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/account/README.md#delete_address) - Delete Address
+* [replace_address](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/account/README.md#replace_address) - Replace Address
+* [edit_address](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/account/README.md#edit_address) - Edit Address
+* [detect_account](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/account/README.md#detect_account) - Detect Account
+* [add_payment_method](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/account/README.md#add_payment_method) - Add Payment Method
+* [delete_payment_method](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/account/README.md#delete_payment_method) - Delete Payment Method
+
+### [Configuration](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/configuration/README.md)
+
+* [get_merchant_callbacks](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/configuration/README.md#get_merchant_callbacks) - Get Callback URLs
+* [set_merchant_callbacks](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/configuration/README.md#set_merchant_callbacks) - Set Callback URLs
+* [get_merchant_identifiers](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/configuration/README.md#get_merchant_identifiers) - Get Merchant Identifiers
+
+### [OAuth](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/oauth/README.md)
+
+* [o_auth_token](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/oauth/README.md#o_auth_token) - OAuth Token Endpoint
+
+### [Orders](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/orders/README.md)
+
+* [create_order_token](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/orders/README.md#create_order_token) - Create Order Token
+* [track_order](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/orders/README.md#track_order) - Send order tracking details
+
+### [Statements](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/statements/README.md)
+
+* [get_statements](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/statements/README.md#get_statements) - Fetch a Statement
+
+### [Testing](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/testing/README.md)
+
+* [test_shipping](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/testing/README.md#test_shipping) - Test Shipping
+* [create_testing_shopper_account](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/testing/README.md#create_testing_shopper_account) - Create Testing Shopper Account
+* [get_test_credit_card_token](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/testing/README.md#get_test_credit_card_token) - Fetch a Test Credit Card Token
+
+### [Transactions](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/transactions/README.md)
+
+* [authorize_transaction](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/transactions/README.md#authorize_transaction) - Authorize a Card
+* [capture_transaction](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/transactions/README.md#capture_transaction) - Capture a Transaction
+* [refund_transaction](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/transactions/README.md#refund_transaction) - Refund a Transaction
+* [review_transaction](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/transactions/README.md#review_transaction) - Review Transaction
+* [void_transaction](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/transactions/README.md#void_transaction) - Void a Transaction
+* [get_transaction_details](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/transactions/README.md#get_transaction_details) - Transaction Details
+* [update_transaction](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/transactions/README.md#update_transaction) - Update a Transaction
+
+### [Webhooks](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/webhooks/README.md)
+
+* [query_webhooks](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/webhooks/README.md#query_webhooks) - Query Webhooks
+* [create_webhook](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/webhooks/README.md#create_webhook) - Create Bolt Webhook
+* [delete_webhook](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/webhooks/README.md#delete_webhook) - Delete a Bolt Webhook
+* [get_webhook](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/docs/sdks/webhooks/README.md#get_webhook) - Get Webhook
+
+
+
+
+
+## Retries
+
+Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
+
+To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call:
+```python
+from bolt_api_sdk import Bolt, models
+from bolt_api_sdk.utils import BackoffStrategy, RetryConfig
+import os
+
+
+with Bolt() as bolt:
+
+ res = bolt.account.get_account(security=models.GetAccountSecurity(
+ o_auth=os.getenv("BOLT_O_AUTH", ""),
+ x_api_key=os.getenv("BOLT_X_API_KEY", ""),
+ ),
+ RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
+
+ # Handle response
+ print(res)
+
+```
+
+If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK:
+```python
+from bolt_api_sdk import Bolt, models
+from bolt_api_sdk.utils import BackoffStrategy, RetryConfig
+import os
+
+
+with Bolt(
+ retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
+) as bolt:
+
+ res = bolt.account.get_account(security=models.GetAccountSecurity(
+ o_auth=os.getenv("BOLT_O_AUTH", ""),
+ x_api_key=os.getenv("BOLT_X_API_KEY", ""),
+ ))
+
+ # Handle response
+ print(res)
+
+```
+
+
+
+## Error Handling
+
+[`BoltError`](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/./src/bolt_api_sdk/errors/bolterror.py) is the base class for all HTTP error responses. It has the following properties:
+
+| Property | Type | Description |
+| ------------------ | ---------------- | --------------------------------------------------------------------------------------- |
+| `err.message` | `str` | Error message |
+| `err.status_code` | `int` | HTTP response status code eg `404` |
+| `err.headers` | `httpx.Headers` | HTTP response headers |
+| `err.body` | `str` | HTTP body. Can be empty string if no body is returned. |
+| `err.raw_response` | `httpx.Response` | Raw HTTP response |
+| `err.data` | | Optional. Some errors may contain structured data. [See Error Classes](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/#error-classes). |
+
+### Example
+```python
+from bolt_api_sdk import Bolt, errors
+
+
+with Bolt() as bolt:
+ res = None
+ try:
+
+ res = bolt.account.detect_account(x_publishable_key="")
+
+ # Handle response
+ print(res)
+
+
+ except errors.BoltError as e:
+ # The base class for HTTP error responses
+ print(e.message)
+ print(e.status_code)
+ print(e.body)
+ print(e.headers)
+ print(e.raw_response)
+
+ # Depending on the method different errors may be thrown
+ if isinstance(e, errors.ErrorsBoltAPIResponse):
+ print(e.data.errors) # Optional[List[models.ErrorBoltAPI]]
+ print(e.data.result) # Optional[models.RequestResult]
+```
+
+### Error Classes
+**Primary error:**
+* [`BoltError`](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/./src/bolt_api_sdk/errors/bolterror.py): The base class for HTTP error responses.
+
+Less common errors (8)
+
+
+
+**Network errors:**
+* [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors.
+ * [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server.
+ * [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out.
+
+
+**Inherit from [`BoltError`](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/./src/bolt_api_sdk/errors/bolterror.py)**:
+* [`ErrorsBoltAPIResponse`](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/./src/bolt_api_sdk/errors/errorsboltapiresponse.py): Applicable to 19 of 31 methods.*
+* [`ErrorsOauthServerResponse`](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/./src/bolt_api_sdk/errors/errorsoauthserverresponse.py): Invalid request to OAuth Token. Applicable to 1 of 31 methods.*
+* [`UnprocessableEntityError`](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/./src/bolt_api_sdk/errors/unprocessableentityerror.py): Unprocessable Entity. Status code `422`. Applicable to 1 of 31 methods.*
+* [`ResponseValidationError`](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/./src/bolt_api_sdk/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute.
+
+
+
+\* Check [the method documentation](https://github.com/BoltApp/Bolt-Python-SDK/blob/master/#available-resources-and-operations) to see if the error is applicable.
+
+
+
+## Server Selection
+
+### Select Server by Index
+
+You can override the default server globally by passing a server index to the `server_idx: int` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
+
+| # | Server | Description |
+| --- | ------------------------------ | ------------------------------- |
+| 0 | `https://api.bolt.com` | The Production URL (Live Data). |
+| 1 | `https://api-sandbox.bolt.com` | The Sandbox URL (Test Data). |
+| 2 | `https://api-staging.bolt.com` | The Staging URL (Staged Data). |
+
+#### Example
+
+```python
+from bolt_api_sdk import Bolt, models
+import os
+
+
+with Bolt(
+ server_idx=0,
+) as bolt:
+
+ res = bolt.account.get_account(security=models.GetAccountSecurity(
+ o_auth=os.getenv("BOLT_O_AUTH", ""),
+ x_api_key=os.getenv("BOLT_X_API_KEY", ""),
+ ))
+
+ # Handle response
+ print(res)
+
+```
+
+### Override Server URL Per-Client
+
+The default server can also be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
+```python
+from bolt_api_sdk import Bolt, models
+import os
+
+
+with Bolt(
+ server_url="https://api-staging.bolt.com",
+) as bolt:
+
+ res = bolt.account.get_account(security=models.GetAccountSecurity(
+ o_auth=os.getenv("BOLT_O_AUTH", ""),
+ x_api_key=os.getenv("BOLT_X_API_KEY", ""),
+ ))
+
+ # Handle response
+ print(res)
+
+```
+
+
+
+## Custom HTTP Client
+
+The Python SDK makes API calls using the [httpx](https://www.python-httpx.org/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.
+Depending on whether you are using the sync or async version of the SDK, you can pass an instance of `HttpClient` or `AsyncHttpClient` respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls.
+This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of `httpx.Client` or `httpx.AsyncClient` directly.
+
+For example, you could specify a header for every request that this sdk makes as follows:
+```python
+from bolt_api_sdk import Bolt
+import httpx
+
+http_client = httpx.Client(headers={"x-custom-header": "someValue"})
+s = Bolt(client=http_client)
+```
+
+or you could wrap the client with your own custom logic:
+```python
+from bolt_api_sdk import Bolt
+from bolt_api_sdk.httpclient import AsyncHttpClient
+import httpx
+
+class CustomClient(AsyncHttpClient):
+ client: AsyncHttpClient
+
+ def __init__(self, client: AsyncHttpClient):
+ self.client = client
+
+ async def send(
+ self,
+ request: httpx.Request,
+ *,
+ stream: bool = False,
+ auth: Union[
+ httpx._types.AuthTypes, httpx._client.UseClientDefault, None
+ ] = httpx.USE_CLIENT_DEFAULT,
+ follow_redirects: Union[
+ bool, httpx._client.UseClientDefault
+ ] = httpx.USE_CLIENT_DEFAULT,
+ ) -> httpx.Response:
+ request.headers["Client-Level-Header"] = "added by client"
+
+ return await self.client.send(
+ request, stream=stream, auth=auth, follow_redirects=follow_redirects
+ )
+
+ def build_request(
+ self,
+ method: str,
+ url: httpx._types.URLTypes,
+ *,
+ content: Optional[httpx._types.RequestContent] = None,
+ data: Optional[httpx._types.RequestData] = None,
+ files: Optional[httpx._types.RequestFiles] = None,
+ json: Optional[Any] = None,
+ params: Optional[httpx._types.QueryParamTypes] = None,
+ headers: Optional[httpx._types.HeaderTypes] = None,
+ cookies: Optional[httpx._types.CookieTypes] = None,
+ timeout: Union[
+ httpx._types.TimeoutTypes, httpx._client.UseClientDefault
+ ] = httpx.USE_CLIENT_DEFAULT,
+ extensions: Optional[httpx._types.RequestExtensions] = None,
+ ) -> httpx.Request:
+ return self.client.build_request(
+ method,
+ url,
+ content=content,
+ data=data,
+ files=files,
+ json=json,
+ params=params,
+ headers=headers,
+ cookies=cookies,
+ timeout=timeout,
+ extensions=extensions,
+ )
+
+s = Bolt(async_client=CustomClient(httpx.AsyncClient()))
+```
+
+
+
+## Resource Management
+
+The `Bolt` class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a [context manager][context-manager] and reuse it across the application.
+
+[context-manager]: https://docs.python.org/3/reference/datamodel.html#context-managers
+
+```python
+from bolt_api_sdk import Bolt
+def main():
+
+ with Bolt() as bolt:
+ # Rest of application here...
+
+
+# Or when using async:
+async def amain():
+
+ async with Bolt() as bolt:
+ # Rest of application here...
+```
+
+
+
+## Debugging
+
+You can setup your SDK to emit debug logs for SDK requests and responses.
+
+You can pass your own logger class directly into your SDK.
+```python
+from bolt_api_sdk import Bolt
+import logging
+
+logging.basicConfig(level=logging.DEBUG)
+s = Bolt(debug_logger=logging.getLogger("bolt_api_sdk"))
+```
+
+You can also enable a default debug logger by setting an environment variable `BOLT_DEBUG` to true.
+
+
+
+
+# Development
+
+## Maturity
+
+This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
+to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
+looking for the latest version.
+
+## Contributions
+
+While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
+We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
+
+### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=bolt-api-sdk&utm_campaign=python)
diff --git a/README.md b/README.md
index a9373f9a..4a56c2e2 100644
--- a/README.md
+++ b/README.md
@@ -91,7 +91,7 @@ It's also possible to write a standalone Python script without needing to set up
```python
#!/usr/bin/env -S uv run --script
# /// script
-# requires-python = ">=3.9"
+# requires-python = ">=3.10"
# dependencies = [
# "bolt-api-sdk",
# ]
@@ -288,7 +288,7 @@ with Bolt() as bolt:
Available methods
-### [account](docs/sdks/account/README.md)
+### [Account](docs/sdks/account/README.md)
* [get_account](docs/sdks/account/README.md#get_account) - Get Account Details
* [create_account](docs/sdks/account/README.md#create_account) - Create Bolt Account
@@ -301,33 +301,32 @@ with Bolt() as bolt:
* [add_payment_method](docs/sdks/account/README.md#add_payment_method) - Add Payment Method
* [delete_payment_method](docs/sdks/account/README.md#delete_payment_method) - Delete Payment Method
-
-### [configuration](docs/sdks/configuration/README.md)
+### [Configuration](docs/sdks/configuration/README.md)
* [get_merchant_callbacks](docs/sdks/configuration/README.md#get_merchant_callbacks) - Get Callback URLs
* [set_merchant_callbacks](docs/sdks/configuration/README.md#set_merchant_callbacks) - Set Callback URLs
* [get_merchant_identifiers](docs/sdks/configuration/README.md#get_merchant_identifiers) - Get Merchant Identifiers
-### [o_auth](docs/sdks/oauth/README.md)
+### [OAuth](docs/sdks/oauth/README.md)
* [o_auth_token](docs/sdks/oauth/README.md#o_auth_token) - OAuth Token Endpoint
-### [orders](docs/sdks/orders/README.md)
+### [Orders](docs/sdks/orders/README.md)
* [create_order_token](docs/sdks/orders/README.md#create_order_token) - Create Order Token
* [track_order](docs/sdks/orders/README.md#track_order) - Send order tracking details
-### [statements](docs/sdks/statements/README.md)
+### [Statements](docs/sdks/statements/README.md)
* [get_statements](docs/sdks/statements/README.md#get_statements) - Fetch a Statement
-### [testing](docs/sdks/testing/README.md)
+### [Testing](docs/sdks/testing/README.md)
* [test_shipping](docs/sdks/testing/README.md#test_shipping) - Test Shipping
* [create_testing_shopper_account](docs/sdks/testing/README.md#create_testing_shopper_account) - Create Testing Shopper Account
* [get_test_credit_card_token](docs/sdks/testing/README.md#get_test_credit_card_token) - Fetch a Test Credit Card Token
-### [transactions](docs/sdks/transactions/README.md)
+### [Transactions](docs/sdks/transactions/README.md)
* [authorize_transaction](docs/sdks/transactions/README.md#authorize_transaction) - Authorize a Card
* [capture_transaction](docs/sdks/transactions/README.md#capture_transaction) - Capture a Transaction
@@ -337,7 +336,7 @@ with Bolt() as bolt:
* [get_transaction_details](docs/sdks/transactions/README.md#get_transaction_details) - Transaction Details
* [update_transaction](docs/sdks/transactions/README.md#update_transaction) - Update a Transaction
-### [webhooks](docs/sdks/webhooks/README.md)
+### [Webhooks](docs/sdks/webhooks/README.md)
* [query_webhooks](docs/sdks/webhooks/README.md#query_webhooks) - Query Webhooks
* [create_webhook](docs/sdks/webhooks/README.md#create_webhook) - Create Bolt Webhook
@@ -483,7 +482,7 @@ import os
with Bolt(
- server_idx=2,
+ server_idx=0,
) as bolt:
res = bolt.account.get_account(security=models.GetAccountSecurity(
diff --git a/RELEASES.md b/RELEASES.md
new file mode 100644
index 00000000..aa5bc1ef
--- /dev/null
+++ b/RELEASES.md
@@ -0,0 +1,11 @@
+
+
+## 2026-07-29 00:48:51
+### Changes
+Based on:
+- OpenAPI Doc
+- Speakeasy CLI 1.791.0 (2.924.0) https://github.com/speakeasy-api/speakeasy
+### Generated
+- [python v0.6.0] .
+### Releases
+- [PyPI v0.6.0] https://pypi.org/project/bolt-api-sdk/0.6.0 - .
\ No newline at end of file
diff --git a/docs/models/accountdetailsaddressviewpriority.md b/docs/models/accountdetailsaddressviewpriority.md
index f9fa2a74..bb2837d9 100644
--- a/docs/models/accountdetailsaddressviewpriority.md
+++ b/docs/models/accountdetailsaddressviewpriority.md
@@ -2,6 +2,14 @@
The shopper-indicated priority of this address compared to other addresses on their account.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import AccountDetailsAddressViewPriority
+
+value = AccountDetailsAddressViewPriority.PRIMARY
+```
+
## Values
diff --git a/docs/models/accountidentifierstatus.md b/docs/models/accountidentifierstatus.md
index ce51582d..cc3a569c 100644
--- a/docs/models/accountidentifierstatus.md
+++ b/docs/models/accountidentifierstatus.md
@@ -2,6 +2,14 @@
The status of the shopper account identifier (email or phone). If the account does not have this identifier, the status is "missing"; If the identifier has been used to receive an OTP code, the status is "verified"; If the identifier has not been used to receive an OTP code, the status is "unverified".
+## Example Usage
+
+```python
+from bolt_api_sdk.models import AccountIdentifierStatus
+
+value = AccountIdentifierStatus.MISSING
+```
+
## Values
diff --git a/docs/models/action.md b/docs/models/action.md
index 36259c26..9080f68f 100644
--- a/docs/models/action.md
+++ b/docs/models/action.md
@@ -1,5 +1,13 @@
# Action
+## Example Usage
+
+```python
+from bolt_api_sdk.models import Action
+
+value = Action.SET_PASSWORD
+```
+
## Values
diff --git a/docs/models/addaddresspriority.md b/docs/models/addaddresspriority.md
index 14a1a2fd..e7b0e870 100644
--- a/docs/models/addaddresspriority.md
+++ b/docs/models/addaddresspriority.md
@@ -2,6 +2,14 @@
The shopper-indicated priority of this address compared to other addresses on their account.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import AddAddressPriority
+
+value = AddAddressPriority.PRIMARY
+```
+
## Values
diff --git a/docs/models/addpaymentmethodnetwork.md b/docs/models/addpaymentmethodnetwork.md
index 34bdb1a2..0967b95d 100644
--- a/docs/models/addpaymentmethodnetwork.md
+++ b/docs/models/addpaymentmethodnetwork.md
@@ -1,5 +1,13 @@
# AddPaymentMethodNetwork
+## Example Usage
+
+```python
+from bolt_api_sdk.models import AddPaymentMethodNetwork
+
+value = AddPaymentMethodNetwork.VISA
+```
+
## Values
diff --git a/docs/models/addpaymentmethodpriority.md b/docs/models/addpaymentmethodpriority.md
index 395c3883..afc15d88 100644
--- a/docs/models/addpaymentmethodpriority.md
+++ b/docs/models/addpaymentmethodpriority.md
@@ -3,6 +3,14 @@
Used to indicate the card's priority. '1' indicates primary, while '2' indicates a secondary card.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import AddPaymentMethodPriority
+
+value = AddPaymentMethodPriority.ONE
+```
+
## Values
diff --git a/docs/models/addpaymentmethodrequestbody.md b/docs/models/addpaymentmethodrequestbody.md
index a707143e..96f610b4 100644
--- a/docs/models/addpaymentmethodrequestbody.md
+++ b/docs/models/addpaymentmethodrequestbody.md
@@ -9,7 +9,7 @@ The `credit_card` object is used to to pay for guest checkout transactions or sa
| Field | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `billing_address` | [models.Address](../models/address.md) | :heavy_check_mark: | The Address object is used for billing, shipping, and physical store address use cases. | |
-| `billing_address_id` | *OptionalNullable[str]* | :heavy_minus_sign: | The unique Bolt ID associated with a saved shopper address. This can be obtained by accessing a shopper's account details. If you use this field, you do not need to use `billing_address`. | |
+| `billing_address_id` | *OptionalNullable[str]* | :heavy_minus_sign: | The unique Bolt ID associated with a saved shopper address. This can be obtained by accessing a shopper's account details. If you use this field, you do not need to use `billing_address`. | null |
| `bin` | *Optional[str]* | :heavy_minus_sign: | The Bank Identification Number for the credit card. This is typically the first 4-6 digits of the credit card number. | 411111 |
| `cryptogram` | *Optional[str]* | :heavy_minus_sign: | N/A | |
| `eci` | *Optional[str]* | :heavy_minus_sign: | N/A | |
diff --git a/docs/models/addpaymentmethodtokentype.md b/docs/models/addpaymentmethodtokentype.md
index 98472c25..735e2a21 100644
--- a/docs/models/addpaymentmethodtokentype.md
+++ b/docs/models/addpaymentmethodtokentype.md
@@ -3,6 +3,14 @@
Used to define which payment processor generated the token for this credit card. For those using Bolt's tokenizer, the value must be `bolt`.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import AddPaymentMethodTokenType
+
+value = AddPaymentMethodTokenType.VANTIV
+```
+
## Values
diff --git a/docs/models/addressviewpriority.md b/docs/models/addressviewpriority.md
index e44be85b..53404055 100644
--- a/docs/models/addressviewpriority.md
+++ b/docs/models/addressviewpriority.md
@@ -2,6 +2,14 @@
The shopper-indicated priority of this address compared to other addresses on their account.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import AddressViewPriority
+
+value = AddressViewPriority.PRIMARY
+```
+
## Values
diff --git a/docs/models/authorizationverificationstatus.md b/docs/models/authorizationverificationstatus.md
index ba041a19..6f063f44 100644
--- a/docs/models/authorizationverificationstatus.md
+++ b/docs/models/authorizationverificationstatus.md
@@ -2,6 +2,14 @@
Used to track the status of micro-authorizations. **Nullable** for Transactions Details.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import AuthorizationVerificationStatus
+
+value = AuthorizationVerificationStatus.NEW
+```
+
## Values
diff --git a/docs/models/authverificationstatus.md b/docs/models/authverificationstatus.md
index c1220351..4216a662 100644
--- a/docs/models/authverificationstatus.md
+++ b/docs/models/authverificationstatus.md
@@ -1,5 +1,13 @@
# AuthVerificationStatus
+## Example Usage
+
+```python
+from bolt_api_sdk.models import AuthVerificationStatus
+
+value = AuthVerificationStatus.UNKNOWN
+```
+
## Values
diff --git a/docs/models/avsresponse.md b/docs/models/avsresponse.md
index cb5f8a22..ac774bae 100644
--- a/docs/models/avsresponse.md
+++ b/docs/models/avsresponse.md
@@ -1,5 +1,13 @@
# AvsResponse
+## Example Usage
+
+```python
+from bolt_api_sdk.models import AvsResponse
+
+value = AvsResponse.ZERO
+```
+
## Values
diff --git a/docs/models/capturestatus.md b/docs/models/capturestatus.md
index 61868eb9..c019d88e 100644
--- a/docs/models/capturestatus.md
+++ b/docs/models/capturestatus.md
@@ -2,6 +2,14 @@
The status of the capture. **Nullable** for Transactions Details.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CaptureStatus
+
+value = CaptureStatus.SUCCEEDED
+```
+
## Values
diff --git a/docs/models/captureviewtype.md b/docs/models/captureviewtype.md
index 2770f11b..07728af3 100644
--- a/docs/models/captureviewtype.md
+++ b/docs/models/captureviewtype.md
@@ -3,6 +3,14 @@
Fee type options. **Nullable** for Transactions Details.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CaptureViewType
+
+value = CaptureViewType.NET
+```
+
## Values
diff --git a/docs/models/carddisplaynetwork.md b/docs/models/carddisplaynetwork.md
index 0bc31e25..563bc50f 100644
--- a/docs/models/carddisplaynetwork.md
+++ b/docs/models/carddisplaynetwork.md
@@ -2,6 +2,14 @@
The card's network. **Nullable** for Transactions Details.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CardDisplayNetwork
+
+value = CardDisplayNetwork.CREDIT_CARD
+```
+
## Values
diff --git a/docs/models/cardnetwork.md b/docs/models/cardnetwork.md
index 595c1928..378a3712 100644
--- a/docs/models/cardnetwork.md
+++ b/docs/models/cardnetwork.md
@@ -3,6 +3,14 @@
The card's network code. **Nullable** for Transactions Details. Note: LEGACY diners_club_us_ca now tagged as mastercard
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CardNetwork
+
+value = CardNetwork.VISA
+```
+
## Values
diff --git a/docs/models/cardstatus.md b/docs/models/cardstatus.md
index 5a94d051..01dcb2a5 100644
--- a/docs/models/cardstatus.md
+++ b/docs/models/cardstatus.md
@@ -2,6 +2,14 @@
The card's status. **Nullable** for Transactions Details.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CardStatus
+
+value = CardStatus.ACTIVE
+```
+
## Values
diff --git a/docs/models/cardtokentype.md b/docs/models/cardtokentype.md
index 15ab4ead..9775e803 100644
--- a/docs/models/cardtokentype.md
+++ b/docs/models/cardtokentype.md
@@ -3,6 +3,14 @@
Used to define which payment processor generated the token for this credit card.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CardTokenType
+
+value = CardTokenType.VANTIV
+```
+
## Values
diff --git a/docs/models/cartdiscountdiscountcategory.md b/docs/models/cartdiscountdiscountcategory.md
index 66471c3b..dc14001e 100644
--- a/docs/models/cartdiscountdiscountcategory.md
+++ b/docs/models/cartdiscountdiscountcategory.md
@@ -1,5 +1,13 @@
# CartDiscountDiscountCategory
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CartDiscountDiscountCategory
+
+value = CartDiscountDiscountCategory.COUPON
+```
+
## Values
@@ -14,4 +22,5 @@
| `MEMBERSHIP_GIFTCARD` | membership_giftcard |
| `SUBSCRIPTION_DISCOUNT` | subscription_discount |
| `REWARDS_DISCOUNT` | rewards_discount |
+| `SHIPPING_DISCOUNT` | shipping_discount |
| `UNKNOWN` | unknown |
\ No newline at end of file
diff --git a/docs/models/cartdiscounttype.md b/docs/models/cartdiscounttype.md
index fb70306a..30ee7ba3 100644
--- a/docs/models/cartdiscounttype.md
+++ b/docs/models/cartdiscounttype.md
@@ -2,6 +2,14 @@
The type of discount.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CartDiscountType
+
+value = CartDiscountType.FIXED_AMOUNT
+```
+
## Values
diff --git a/docs/models/cartitemshipmenttype.md b/docs/models/cartitemshipmenttype.md
index 2f779681..9a515e21 100644
--- a/docs/models/cartitemshipmenttype.md
+++ b/docs/models/cartitemshipmenttype.md
@@ -1,5 +1,13 @@
# CartItemShipmentType
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CartItemShipmentType
+
+value = CartItemShipmentType.UNKNOWN
+```
+
## Values
diff --git a/docs/models/cartitemtype.md b/docs/models/cartitemtype.md
index 7158ee0d..9dc2c1d2 100644
--- a/docs/models/cartitemtype.md
+++ b/docs/models/cartitemtype.md
@@ -1,5 +1,13 @@
# CartItemType
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CartItemType
+
+value = CartItemType.UNKNOWN
+```
+
## Values
diff --git a/docs/models/cartshipmenttype.md b/docs/models/cartshipmenttype.md
index d05351ad..9ad99aa3 100644
--- a/docs/models/cartshipmenttype.md
+++ b/docs/models/cartshipmenttype.md
@@ -2,6 +2,14 @@
The type corresponding to this shipment, if applicable.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CartShipmentType
+
+value = CartShipmentType.DOOR_DELIVERY
+```
+
## Values
diff --git a/docs/models/channel.md b/docs/models/channel.md
index c0095fac..bd89a64f 100644
--- a/docs/models/channel.md
+++ b/docs/models/channel.md
@@ -2,6 +2,14 @@
Used to determine the channel from which the order was created.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import Channel
+
+value = Channel.BROWSER
+```
+
## Values
diff --git a/docs/models/chargebackreasoncode.md b/docs/models/chargebackreasoncode.md
index 5ecad8e4..be1602d9 100644
--- a/docs/models/chargebackreasoncode.md
+++ b/docs/models/chargebackreasoncode.md
@@ -2,6 +2,14 @@
Bolt's [standardized reason codes](https://help.bolt.com/merchants/references/policies/disputes/dispute-codes/).
+## Example Usage
+
+```python
+from bolt_api_sdk.models import ChargebackReasonCode
+
+value = ChargebackReasonCode.AUTHORIZATION_FAILED
+```
+
## Values
diff --git a/docs/models/chargebackrepresentmentresult.md b/docs/models/chargebackrepresentmentresult.md
index d22b1be7..f8148311 100644
--- a/docs/models/chargebackrepresentmentresult.md
+++ b/docs/models/chargebackrepresentmentresult.md
@@ -2,6 +2,14 @@
The result of the chargeback representment.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import ChargebackRepresentmentResult
+
+value = ChargebackRepresentmentResult.NONE
+```
+
## Values
diff --git a/docs/models/checkoutsetup.md b/docs/models/checkoutsetup.md
index bac0d49e..f7c03c8d 100644
--- a/docs/models/checkoutsetup.md
+++ b/docs/models/checkoutsetup.md
@@ -1,5 +1,13 @@
# CheckoutSetup
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CheckoutSetup
+
+value = CheckoutSetup.SHIPPING_STEP
+```
+
## Values
diff --git a/docs/models/consumermembershipstatus.md b/docs/models/consumermembershipstatus.md
index 415fc7b7..3f3fd3e9 100644
--- a/docs/models/consumermembershipstatus.md
+++ b/docs/models/consumermembershipstatus.md
@@ -2,6 +2,14 @@
True if user has an AllPass membership associated to their Bolt Account. **Nullable** for Transactions Details.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import ConsumerMembershipStatus
+
+value = ConsumerMembershipStatus.ACTIVE
+```
+
## Values
diff --git a/docs/models/creditcard.md b/docs/models/creditcard.md
index b7bd7fdc..9c14c6ae 100644
--- a/docs/models/creditcard.md
+++ b/docs/models/creditcard.md
@@ -15,4 +15,5 @@ The credit_card object is used to to pay for guest-checkout transactions or save
| `priority` | [Optional[models.CreditCardPriority]](../models/creditcardpriority.md) | :heavy_minus_sign: | Used to indicate the card's priority. '1' indicates primary, while '2' indicates a secondary card. | |
| `save` | *Optional[bool]* | :heavy_minus_sign: | Determines whether or not the credit card will be saved to the shopper's account. Defaults to `true`. | |
| `token` | *str* | :heavy_check_mark: | The Bolt token associated to the credit card. | a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0 |
-| `token_type` | [models.CreditCardTokenType](../models/creditcardtokentype.md) | :heavy_check_mark: | Used to define which payment processor generated the token for this credit card; for those using Bolt's tokenizer, the value must be `bolt`. | bolt |
\ No newline at end of file
+| `token_type` | [models.CreditCardTokenType](../models/creditcardtokentype.md) | :heavy_check_mark: | Used to define which payment processor generated the token for this credit card; for those using Bolt's tokenizer, the value must be `bolt`. | bolt |
+| `affirm_vcn_token` | *OptionalNullable[str]* | :heavy_minus_sign: | The checkout token associated with Affirm VCN credit cards. | a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0 |
\ No newline at end of file
diff --git a/docs/models/creditcardauthorizationreason.md b/docs/models/creditcardauthorizationreason.md
index a9197da0..179ea4e0 100644
--- a/docs/models/creditcardauthorizationreason.md
+++ b/docs/models/creditcardauthorizationreason.md
@@ -13,6 +13,14 @@ The reason code explaining the authorization status.
* `10` - unsupported_payment_method
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CreditCardAuthorizationReason
+
+value = CreditCardAuthorizationReason.NONE
+```
+
## Values
diff --git a/docs/models/creditcardauthorizationstatus.md b/docs/models/creditcardauthorizationstatus.md
index 595a9fa8..8666e326 100644
--- a/docs/models/creditcardauthorizationstatus.md
+++ b/docs/models/creditcardauthorizationstatus.md
@@ -6,6 +6,14 @@ The status of the authorization request.
* `3` - error
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CreditCardAuthorizationStatus
+
+value = CreditCardAuthorizationStatus.SUCCEEDED
+```
+
## Values
diff --git a/docs/models/creditcardcreditviewstatus.md b/docs/models/creditcardcreditviewstatus.md
index 218cedef..50eebbad 100644
--- a/docs/models/creditcardcreditviewstatus.md
+++ b/docs/models/creditcardcreditviewstatus.md
@@ -2,6 +2,14 @@
The status of the refund to a card.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CreditCardCreditViewStatus
+
+value = CreditCardCreditViewStatus.SUCCEEDED
+```
+
## Values
diff --git a/docs/models/creditcardpriority.md b/docs/models/creditcardpriority.md
index a80089cd..de65de5f 100644
--- a/docs/models/creditcardpriority.md
+++ b/docs/models/creditcardpriority.md
@@ -2,6 +2,14 @@
Used to indicate the card's priority. '1' indicates primary, while '2' indicates a secondary card.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CreditCardPriority
+
+value = CreditCardPriority.ONE
+```
+
## Values
diff --git a/docs/models/creditcardtokentype.md b/docs/models/creditcardtokentype.md
index 724edb55..8ccda32a 100644
--- a/docs/models/creditcardtokentype.md
+++ b/docs/models/creditcardtokentype.md
@@ -2,6 +2,14 @@
Used to define which payment processor generated the token for this credit card; for those using Bolt's tokenizer, the value must be `bolt`.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CreditCardTokenType
+
+value = CreditCardTokenType.BOLT
+```
+
## Values
diff --git a/docs/models/creditcardvoidcause.md b/docs/models/creditcardvoidcause.md
index 93feec70..9c0dcbcb 100644
--- a/docs/models/creditcardvoidcause.md
+++ b/docs/models/creditcardvoidcause.md
@@ -2,6 +2,14 @@
Specifies why this particular transaction is voided.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CreditCardVoidCause
+
+value = CreditCardVoidCause.MERCHANT_ACTION
+```
+
## Values
diff --git a/docs/models/creditcardvoidstatus.md b/docs/models/creditcardvoidstatus.md
index 684131fc..5d77e85e 100644
--- a/docs/models/creditcardvoidstatus.md
+++ b/docs/models/creditcardvoidstatus.md
@@ -2,6 +2,14 @@
The status of the void request.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CreditCardVoidStatus
+
+value = CreditCardVoidStatus.SUCCEEDED
+```
+
## Values
diff --git a/docs/models/customfieldscontext.md b/docs/models/customfieldscontext.md
index a0ede303..731fd1a9 100644
--- a/docs/models/customfieldscontext.md
+++ b/docs/models/customfieldscontext.md
@@ -2,6 +2,14 @@
The app context of where the custom field is used.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CustomFieldsContext
+
+value = CustomFieldsContext.CHECKOUT
+```
+
## Values
diff --git a/docs/models/customfieldviewcheckoutstep.md b/docs/models/customfieldviewcheckoutstep.md
index 8d9113eb..3255af78 100644
--- a/docs/models/customfieldviewcheckoutstep.md
+++ b/docs/models/customfieldviewcheckoutstep.md
@@ -1,5 +1,13 @@
# CustomFieldViewCheckoutStep
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CustomFieldViewCheckoutStep
+
+value = CustomFieldViewCheckoutStep.SHIPPING_STEP
+```
+
## Values
diff --git a/docs/models/customfieldviewcontext.md b/docs/models/customfieldviewcontext.md
index 68830d4f..53f53689 100644
--- a/docs/models/customfieldviewcontext.md
+++ b/docs/models/customfieldviewcontext.md
@@ -1,5 +1,13 @@
# CustomFieldViewContext
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CustomFieldViewContext
+
+value = CustomFieldViewContext.CHECKOUT
+```
+
## Values
diff --git a/docs/models/cvvresponse.md b/docs/models/cvvresponse.md
index 32e852ec..c4613c9b 100644
--- a/docs/models/cvvresponse.md
+++ b/docs/models/cvvresponse.md
@@ -1,5 +1,13 @@
# CvvResponse
+## Example Usage
+
+```python
+from bolt_api_sdk.models import CvvResponse
+
+value = CvvResponse.M
+```
+
## Values
diff --git a/docs/models/decision.md b/docs/models/decision.md
index 84b6e33b..565e15ff 100644
--- a/docs/models/decision.md
+++ b/docs/models/decision.md
@@ -1,5 +1,13 @@
# Decision
+## Example Usage
+
+```python
+from bolt_api_sdk.models import Decision
+
+value = Decision.APPROVE
+```
+
## Values
diff --git a/docs/models/editaddresspriority.md b/docs/models/editaddresspriority.md
index 20155892..163c3a91 100644
--- a/docs/models/editaddresspriority.md
+++ b/docs/models/editaddresspriority.md
@@ -2,6 +2,14 @@
The shopper-indicated priority of this address compared to other addresses on their account.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import EditAddressPriority
+
+value = EditAddressPriority.PRIMARY
+```
+
## Values
diff --git a/docs/models/emailpriority.md b/docs/models/emailpriority.md
index d7775b83..93aa7c6c 100644
--- a/docs/models/emailpriority.md
+++ b/docs/models/emailpriority.md
@@ -2,6 +2,14 @@
This is the priority of the contact method. This field's contents are not displayed in the transaction details view.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import EmailPriority
+
+value = EmailPriority.PRIMARY
+```
+
## Values
diff --git a/docs/models/emailstatus.md b/docs/models/emailstatus.md
index 47163a49..df82bccd 100644
--- a/docs/models/emailstatus.md
+++ b/docs/models/emailstatus.md
@@ -2,6 +2,14 @@
This is the status of the contact method.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import EmailStatus
+
+value = EmailStatus.ACTIVE
+```
+
## Values
diff --git a/docs/models/fulfillmenttype.md b/docs/models/fulfillmenttype.md
index 54931f63..9542cb43 100644
--- a/docs/models/fulfillmenttype.md
+++ b/docs/models/fulfillmenttype.md
@@ -1,5 +1,13 @@
# FulfillmentType
+## Example Usage
+
+```python
+from bolt_api_sdk.models import FulfillmentType
+
+value = FulfillmentType.PHYSICAL_DOOR_DELIVERY
+```
+
## Values
diff --git a/docs/models/hideapm.md b/docs/models/hideapm.md
index aff18e99..a0be8d90 100644
--- a/docs/models/hideapm.md
+++ b/docs/models/hideapm.md
@@ -1,5 +1,13 @@
# HideApm
+## Example Usage
+
+```python
+from bolt_api_sdk.models import HideApm
+
+value = HideApm.PAYPAL
+```
+
## Values
diff --git a/docs/models/hooktype.md b/docs/models/hooktype.md
index 148d8d5e..236e2d5f 100644
--- a/docs/models/hooktype.md
+++ b/docs/models/hooktype.md
@@ -1,5 +1,13 @@
# HookType
+## Example Usage
+
+```python
+from bolt_api_sdk.models import HookType
+
+value = HookType.ONE
+```
+
## Values
diff --git a/docs/models/icartdiscountviewdiscountcategory.md b/docs/models/icartdiscountviewdiscountcategory.md
index 31211567..13487c86 100644
--- a/docs/models/icartdiscountviewdiscountcategory.md
+++ b/docs/models/icartdiscountviewdiscountcategory.md
@@ -1,5 +1,13 @@
# ICartDiscountViewDiscountCategory
+## Example Usage
+
+```python
+from bolt_api_sdk.models import ICartDiscountViewDiscountCategory
+
+value = ICartDiscountViewDiscountCategory.COUPON
+```
+
## Values
@@ -14,4 +22,5 @@
| `MEMBERSHIP_GIFTCARD` | membership_giftcard |
| `SUBSCRIPTION_DISCOUNT` | subscription_discount |
| `REWARDS_DISCOUNT` | rewards_discount |
+| `SHIPPING_DISCOUNT` | shipping_discount |
| `UNKNOWN` | unknown |
\ No newline at end of file
diff --git a/docs/models/icartitemviewshipmenttype.md b/docs/models/icartitemviewshipmenttype.md
index a8412f8c..765ec609 100644
--- a/docs/models/icartitemviewshipmenttype.md
+++ b/docs/models/icartitemviewshipmenttype.md
@@ -1,5 +1,13 @@
# ICartItemViewShipmentType
+## Example Usage
+
+```python
+from bolt_api_sdk.models import ICartItemViewShipmentType
+
+value = ICartItemViewShipmentType.UNKNOWN
+```
+
## Values
diff --git a/docs/models/icartitemviewtype.md b/docs/models/icartitemviewtype.md
index 3a22f899..344f4017 100644
--- a/docs/models/icartitemviewtype.md
+++ b/docs/models/icartitemviewtype.md
@@ -1,5 +1,13 @@
# ICartItemViewType
+## Example Usage
+
+```python
+from bolt_api_sdk.models import ICartItemViewType
+
+value = ICartItemViewType.UNKNOWN
+```
+
## Values
diff --git a/docs/models/icustomfieldviewcheckoutstep.md b/docs/models/icustomfieldviewcheckoutstep.md
index bb269fea..3f0f47b4 100644
--- a/docs/models/icustomfieldviewcheckoutstep.md
+++ b/docs/models/icustomfieldviewcheckoutstep.md
@@ -1,5 +1,13 @@
# ICustomFieldViewCheckoutStep
+## Example Usage
+
+```python
+from bolt_api_sdk.models import ICustomFieldViewCheckoutStep
+
+value = ICustomFieldViewCheckoutStep.SHIPPING_STEP
+```
+
## Values
diff --git a/docs/models/icustomfieldviewcontext.md b/docs/models/icustomfieldviewcontext.md
index f1276543..1d343afd 100644
--- a/docs/models/icustomfieldviewcontext.md
+++ b/docs/models/icustomfieldviewcontext.md
@@ -1,5 +1,13 @@
# ICustomFieldViewContext
+## Example Usage
+
+```python
+from bolt_api_sdk.models import ICustomFieldViewContext
+
+value = ICustomFieldViewContext.CHECKOUT
+```
+
## Values
diff --git a/docs/models/instorecartshipmentdistanceunit.md b/docs/models/instorecartshipmentdistanceunit.md
index 365f4fd3..70b5164b 100644
--- a/docs/models/instorecartshipmentdistanceunit.md
+++ b/docs/models/instorecartshipmentdistanceunit.md
@@ -1,5 +1,13 @@
# InStoreCartShipmentDistanceUnit
+## Example Usage
+
+```python
+from bolt_api_sdk.models import InStoreCartShipmentDistanceUnit
+
+value = InStoreCartShipmentDistanceUnit.KM
+```
+
## Values
diff --git a/docs/models/instoreshipment2distanceunit.md b/docs/models/instoreshipment2distanceunit.md
index 7c3dd138..00ec9223 100644
--- a/docs/models/instoreshipment2distanceunit.md
+++ b/docs/models/instoreshipment2distanceunit.md
@@ -1,5 +1,13 @@
# InStoreShipment2DistanceUnit
+## Example Usage
+
+```python
+from bolt_api_sdk.models import InStoreShipment2DistanceUnit
+
+value = InStoreShipment2DistanceUnit.MILE
+```
+
## Values
diff --git a/docs/models/itemshipmenttype.md b/docs/models/itemshipmenttype.md
index 4702c9b9..028d1b06 100644
--- a/docs/models/itemshipmenttype.md
+++ b/docs/models/itemshipmenttype.md
@@ -2,6 +2,14 @@
The shipment type selected by the shopper.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import ItemShipmentType
+
+value = ItemShipmentType.UNKNOWN
+```
+
## Values
diff --git a/docs/models/manualdisputesstatus.md b/docs/models/manualdisputesstatus.md
index 1ed8a3c1..09213e3e 100644
--- a/docs/models/manualdisputesstatus.md
+++ b/docs/models/manualdisputesstatus.md
@@ -1,5 +1,13 @@
# ManualDisputesStatus
+## Example Usage
+
+```python
+from bolt_api_sdk.models import ManualDisputesStatus
+
+value = ManualDisputesStatus.PENDING
+```
+
## Values
diff --git a/docs/models/manualdisputeviewstatus.md b/docs/models/manualdisputeviewstatus.md
index e31ef0f2..dee499f6 100644
--- a/docs/models/manualdisputeviewstatus.md
+++ b/docs/models/manualdisputeviewstatus.md
@@ -1,5 +1,13 @@
# ManualDisputeViewStatus
+## Example Usage
+
+```python
+from bolt_api_sdk.models import ManualDisputeViewStatus
+
+value = ManualDisputeViewStatus.PENDING
+```
+
## Values
diff --git a/docs/models/merchantcallbackurltype.md b/docs/models/merchantcallbackurltype.md
index f4ce37ef..fd37436d 100644
--- a/docs/models/merchantcallbackurltype.md
+++ b/docs/models/merchantcallbackurltype.md
@@ -2,6 +2,14 @@
Bolt merchant division callback URL type
+## Example Usage
+
+```python
+from bolt_api_sdk.models import MerchantCallbackURLType
+
+value = MerchantCallbackURLType.OAUTH_REDIRECT
+```
+
## Values
diff --git a/docs/models/merchantcreditcardauthorization.md b/docs/models/merchantcreditcardauthorization.md
index 9721089d..bc05eec0 100644
--- a/docs/models/merchantcreditcardauthorization.md
+++ b/docs/models/merchantcreditcardauthorization.md
@@ -13,7 +13,7 @@ This request is used for authorizing a new, unsaved card.
| `credit_card` | [models.CreditCard](../models/creditcard.md) | :heavy_check_mark: | The credit_card object is used to to pay for guest-checkout transactions or save payment method details to an account. Once saved, you can reference the credit card with the associated `credit_card_id` for future transactions. Add `billing_address` to this if storing a billing address for a returning shopper. | |
| `division_id` | *str* | :heavy_check_mark: | The unique ID associated to the merchant's Bolt Account division; Merchants can have different divisions to suit multiple use cases (storefronts, pay-by-link, phone order processing). Use the Bolt Merchant Dashboard to switch between divisions and find the division ID under `Merchant Division Public ID`. | 3X9aPQ67-YrB |
| `merchant_event_id` | *Optional[str]* | :heavy_minus_sign: | The reference ID associated with a transaction event (auth, capture, refund, void). This is an arbitrary identifier created by the merchant. Bolt does not enforce any uniqueness constraints on this ID. It is up to the merchant to generate identifiers that properly fulfill its needs. | dbe0cd5d-3261-41d9-ba61-49e5b9d07567 |
-| `previous_transaction_id` | *OptionalNullable[str]* | :heavy_minus_sign: | The unique ID associated with to the shopper's previous subscription-based transaction. Leave `null` for standard, non-subscription transactions. | |
+| `previous_transaction_id` | *OptionalNullable[str]* | :heavy_minus_sign: | The unique ID associated with to the shopper's previous subscription-based transaction. Leave `null` for standard, non-subscription transactions. | null |
| `processing_initiator` | [Optional[models.MerchantCreditCardAuthorizationProcessingInitiator]](../models/merchantcreditcardauthorizationprocessinginitiator.md) | :heavy_minus_sign: | Determines who initiated the transaction (e.g. shopper, merchant) and how they did it (e.g. recurring subscription, on-file card).
* `initial_card_on_file` - The first transaction made for a card. The system then saves this card for future transactions. * `initial_recurring` - The first time any card is used to pay for a recurring charge. For example, a subscription. * `stored_cardholder_initiated` - The subsequent (second, third, etc.) transactions a shopper initiates with a stored card. This includes every situation during which a cardholder requests a charge, for example if the cardholder requests a merchant charge their card. * `stored_merchant_initiated` - The subsequent (second, third, etc.) transactions a merchant initiates with a stored card only when the cardholder does not request the charge. For example, when a customer service representative buys on behalf of a shopper or when a business adds funds to a public transit card. * `following_recurring` - The subsequent (second, third, etc.) transactions a card is used to pay for a recurring charge. For example, a subscription. * `cardholder_initiated` - When a cardholder begins a transaction that isn’t stored in Bolt and won’t be stored in Bolt for future transactions. * `recurring` - Any time a card is used to pay for a recurring charge (for example, a subscription). Only use this value when you don’t know if it’s the first recurring charge. | |
| `shipping_address` | [Optional[models.Address]](../models/address.md) | :heavy_minus_sign: | The Address object is used for billing, shipping, and physical store address use cases. | |
| `source` | [models.MerchantCreditCardAuthorizationSource](../models/merchantcreditcardauthorizationsource.md) | :heavy_check_mark: | N/A | |
diff --git a/docs/models/merchantcreditcardauthorizationprocessinginitiator.md b/docs/models/merchantcreditcardauthorizationprocessinginitiator.md
index b73a0358..e2a7dc18 100644
--- a/docs/models/merchantcreditcardauthorizationprocessinginitiator.md
+++ b/docs/models/merchantcreditcardauthorizationprocessinginitiator.md
@@ -11,6 +11,14 @@ Determines who initiated the transaction (e.g. shopper, merchant) and how they d
* `recurring` - Any time a card is used to pay for a recurring charge (for example, a subscription). Only use this value when you don’t know if it’s the first recurring charge.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import MerchantCreditCardAuthorizationProcessingInitiator
+
+value = MerchantCreditCardAuthorizationProcessingInitiator.INITIAL_CARD_ON_FILE
+```
+
## Values
diff --git a/docs/models/merchantcreditcardauthorizationrecharge.md b/docs/models/merchantcreditcardauthorizationrecharge.md
index cc221170..b3df55f7 100644
--- a/docs/models/merchantcreditcardauthorizationrecharge.md
+++ b/docs/models/merchantcreditcardauthorizationrecharge.md
@@ -12,7 +12,7 @@ This request is used for authorizing an existing, saved card associated with the
| `credit_card_id` | *str* | :heavy_check_mark: | The unique ID associated to the saved credit card in the account's wallet. | SAeEcU1hpMobc |
| `division_id` | *str* | :heavy_check_mark: | The unique ID associated to the merchant's Bolt Account division; Merchants can have different divisions to suit multiple use cases (storefronts, pay-by-link, phone order processing). Use the Bolt Merchant Dashboard to switch between divisions and find the division ID under `Merchant Division Public ID`. | 3X9aPQ67-YrB |
| `merchant_event_id` | *Optional[str]* | :heavy_minus_sign: | The reference ID associated with a transaction event (auth, capture, refund, void). This is an arbitrary identifier created by the merchant. Bolt does not enforce any uniqueness constraints on this ID. It is up to the merchant to generate identifiers that properly fulfill its needs. | dbe0cd5d-3261-41d9-ba61-49e5b9d07567 |
-| `previous_transaction_id` | *OptionalNullable[str]* | :heavy_minus_sign: | The unique ID associated with to the shopper's previous subscription-based transaction. Leave `null` for standard, non-subscription transactions. | |
+| `previous_transaction_id` | *OptionalNullable[str]* | :heavy_minus_sign: | The unique ID associated with to the shopper's previous subscription-based transaction. Leave `null` for standard, non-subscription transactions. | null |
| `processing_initiator` | [Optional[models.ProcessingInitiator]](../models/processinginitiator.md) | :heavy_minus_sign: | Defines which payment method was used to initiate the transaction. | stored_cardholder_initiated |
| `shipping_address` | [Optional[models.Address]](../models/address.md) | :heavy_minus_sign: | The Address object is used for billing, shipping, and physical store address use cases. | |
| `source` | [models.MerchantCreditCardAuthorizationRechargeSource](../models/merchantcreditcardauthorizationrechargesource.md) | :heavy_check_mark: | N/A | |
diff --git a/docs/models/merchantcreditcardauthorizationrechargesource.md b/docs/models/merchantcreditcardauthorizationrechargesource.md
index 011d1d59..a7b9d3de 100644
--- a/docs/models/merchantcreditcardauthorizationrechargesource.md
+++ b/docs/models/merchantcreditcardauthorizationrechargesource.md
@@ -1,5 +1,13 @@
# MerchantCreditCardAuthorizationRechargeSource
+## Example Usage
+
+```python
+from bolt_api_sdk.models import MerchantCreditCardAuthorizationRechargeSource
+
+value = MerchantCreditCardAuthorizationRechargeSource.DIRECT_PAYMENTS
+```
+
## Values
diff --git a/docs/models/merchantcreditcardauthorizationsource.md b/docs/models/merchantcreditcardauthorizationsource.md
index a82e4c8e..cf10c13c 100644
--- a/docs/models/merchantcreditcardauthorizationsource.md
+++ b/docs/models/merchantcreditcardauthorizationsource.md
@@ -1,5 +1,13 @@
# MerchantCreditCardAuthorizationSource
+## Example Usage
+
+```python
+from bolt_api_sdk.models import MerchantCreditCardAuthorizationSource
+
+value = MerchantCreditCardAuthorizationSource.DIRECT_PAYMENTS
+```
+
## Values
diff --git a/docs/models/merchantonboardingstatuscode.md b/docs/models/merchantonboardingstatuscode.md
index 4299a79f..78060317 100644
--- a/docs/models/merchantonboardingstatuscode.md
+++ b/docs/models/merchantonboardingstatuscode.md
@@ -1,5 +1,13 @@
# MerchantOnboardingStatusCode
+## Example Usage
+
+```python
+from bolt_api_sdk.models import MerchantOnboardingStatusCode
+
+value = MerchantOnboardingStatusCode.NEW_MERCHANT
+```
+
## Values
diff --git a/docs/models/merchantplatform.md b/docs/models/merchantplatform.md
index 55553c03..539809b5 100644
--- a/docs/models/merchantplatform.md
+++ b/docs/models/merchantplatform.md
@@ -2,6 +2,14 @@
The type of platform being used for this merchant division.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import MerchantPlatform
+
+value = MerchantPlatform.NONE
+```
+
## Values
diff --git a/docs/models/merchantstatus.md b/docs/models/merchantstatus.md
index d75307a8..c9dc4fa3 100644
--- a/docs/models/merchantstatus.md
+++ b/docs/models/merchantstatus.md
@@ -6,6 +6,14 @@ The merchant's status:
* `3` - Offboarding
+## Example Usage
+
+```python
+from bolt_api_sdk.models import MerchantStatus
+
+value = MerchantStatus.ONE
+```
+
## Values
diff --git a/docs/models/method.md b/docs/models/method.md
index feec76e7..d86c3de9 100644
--- a/docs/models/method.md
+++ b/docs/models/method.md
@@ -1,5 +1,13 @@
# Method
+## Example Usage
+
+```python
+from bolt_api_sdk.models import Method
+
+value = Method.CODE
+```
+
## Values
diff --git a/docs/models/mocktrackinginputstatus.md b/docs/models/mocktrackinginputstatus.md
index 71e79931..d92b5b60 100644
--- a/docs/models/mocktrackinginputstatus.md
+++ b/docs/models/mocktrackinginputstatus.md
@@ -2,6 +2,14 @@
The shipment status of a simulated order.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import MockTrackingInputStatus
+
+value = MockTrackingInputStatus.IN_TRANSIT
+```
+
## Values
diff --git a/docs/models/network.md b/docs/models/network.md
index fc776ce2..74fb045f 100644
--- a/docs/models/network.md
+++ b/docs/models/network.md
@@ -1,5 +1,13 @@
# Network
+## Example Usage
+
+```python
+from bolt_api_sdk.models import Network
+
+value = Network.VISA
+```
+
## Values
diff --git a/docs/models/oauthtokeninputgranttype.md b/docs/models/oauthtokeninputgranttype.md
index 06639521..b68e3169 100644
--- a/docs/models/oauthtokeninputgranttype.md
+++ b/docs/models/oauthtokeninputgranttype.md
@@ -5,6 +5,14 @@ The type of OAuth 2.0 grant being utilized.
The value will always be `authorization_code` when exchanging an authorization code for an access token.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import OAuthTokenInputGrantType
+
+value = OAuthTokenInputGrantType.AUTHORIZATION_CODE
+```
+
## Values
diff --git a/docs/models/oauthtokeninputrefreshgranttype.md b/docs/models/oauthtokeninputrefreshgranttype.md
index 8f106e51..6af28fe9 100644
--- a/docs/models/oauthtokeninputrefreshgranttype.md
+++ b/docs/models/oauthtokeninputrefreshgranttype.md
@@ -5,6 +5,14 @@ The type of OAuth 2.0 grant being utilized.
The value will always be `refresh_token` when exchanging a refresh token for an access token.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import OAuthTokenInputRefreshGrantType
+
+value = OAuthTokenInputRefreshGrantType.REFRESH_TOKEN
+```
+
## Values
diff --git a/docs/models/paymentmethodaccount.md b/docs/models/paymentmethodaccount.md
index 8557b5e2..4ac76174 100644
--- a/docs/models/paymentmethodaccount.md
+++ b/docs/models/paymentmethodaccount.md
@@ -9,7 +9,7 @@ The `credit_card` object is used to to pay for guest checkout transactions or sa
| Field | Type | Required | Description | Example |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `billing_address` | [models.Address](../models/address.md) | :heavy_check_mark: | The Address object is used for billing, shipping, and physical store address use cases. | |
-| `billing_address_id` | *OptionalNullable[str]* | :heavy_minus_sign: | The unique Bolt ID associated with a saved shopper address. This can be obtained by accessing a shopper's account details. If you use this field, you do not need to use `billing_address`. | |
+| `billing_address_id` | *OptionalNullable[str]* | :heavy_minus_sign: | The unique Bolt ID associated with a saved shopper address. This can be obtained by accessing a shopper's account details. If you use this field, you do not need to use `billing_address`. | null |
| `bin` | *Optional[str]* | :heavy_minus_sign: | The Bank Identification Number for the credit card. This is typically the first 4-6 digits of the credit card number. | 411111 |
| `cryptogram` | *Optional[str]* | :heavy_minus_sign: | N/A | |
| `eci` | *Optional[str]* | :heavy_minus_sign: | N/A | |
diff --git a/docs/models/paymentmethodaccountpriority.md b/docs/models/paymentmethodaccountpriority.md
index 4c474576..77c843c1 100644
--- a/docs/models/paymentmethodaccountpriority.md
+++ b/docs/models/paymentmethodaccountpriority.md
@@ -3,6 +3,14 @@
Used to indicate the card's priority. '1' indicates primary, while '2' indicates a secondary card.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import PaymentMethodAccountPriority
+
+value = PaymentMethodAccountPriority.ONE
+```
+
## Values
diff --git a/docs/models/paymentmethodaccounttokentype.md b/docs/models/paymentmethodaccounttokentype.md
index e1f7e4fd..2e51f0f1 100644
--- a/docs/models/paymentmethodaccounttokentype.md
+++ b/docs/models/paymentmethodaccounttokentype.md
@@ -3,6 +3,14 @@
Used to define which payment processor generated the token for this credit card. For those using Bolt's tokenizer, the value must be `bolt`.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import PaymentMethodAccountTokenType
+
+value = PaymentMethodAccountTokenType.VANTIV
+```
+
## Values
diff --git a/docs/models/paymentservice.md b/docs/models/paymentservice.md
index 40a4998c..2109b41d 100644
--- a/docs/models/paymentservice.md
+++ b/docs/models/paymentservice.md
@@ -1,5 +1,13 @@
# PaymentService
+## Example Usage
+
+```python
+from bolt_api_sdk.models import PaymentService
+
+value = PaymentService.AFFIRM
+```
+
## Values
diff --git a/docs/models/phonepriority.md b/docs/models/phonepriority.md
index c0267a61..35c98ba1 100644
--- a/docs/models/phonepriority.md
+++ b/docs/models/phonepriority.md
@@ -2,6 +2,14 @@
This is the priority of the contact method. This field's contents are not displayed in the transaction details view.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import PhonePriority
+
+value = PhonePriority.PRIMARY
+```
+
## Values
diff --git a/docs/models/phonestatus.md b/docs/models/phonestatus.md
index cf3aa275..eaebfcc7 100644
--- a/docs/models/phonestatus.md
+++ b/docs/models/phonestatus.md
@@ -2,6 +2,14 @@
This is the status of the contact method.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import PhoneStatus
+
+value = PhoneStatus.ACTIVE
+```
+
## Values
diff --git a/docs/models/phoneviewpriority.md b/docs/models/phoneviewpriority.md
index 28db2c17..998afd50 100644
--- a/docs/models/phoneviewpriority.md
+++ b/docs/models/phoneviewpriority.md
@@ -1,5 +1,13 @@
# PhoneViewPriority
+## Example Usage
+
+```python
+from bolt_api_sdk.models import PhoneViewPriority
+
+value = PhoneViewPriority.PRIMARY
+```
+
## Values
diff --git a/docs/models/platformaccountstatus.md b/docs/models/platformaccountstatus.md
index c1e971d0..d798cb90 100644
--- a/docs/models/platformaccountstatus.md
+++ b/docs/models/platformaccountstatus.md
@@ -1,5 +1,13 @@
# PlatformAccountStatus
+## Example Usage
+
+```python
+from bolt_api_sdk.models import PlatformAccountStatus
+
+value = PlatformAccountStatus.NONE
+```
+
## Values
diff --git a/docs/models/priority.md b/docs/models/priority.md
index cbaeef11..b51a2161 100644
--- a/docs/models/priority.md
+++ b/docs/models/priority.md
@@ -3,6 +3,14 @@
Describes the card's priority.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import Priority
+
+value = Priority.PRIMARY
+```
+
## Values
diff --git a/docs/models/processinginitiator.md b/docs/models/processinginitiator.md
index 75a1cbef..e4b54bb3 100644
--- a/docs/models/processinginitiator.md
+++ b/docs/models/processinginitiator.md
@@ -2,6 +2,14 @@
Defines which payment method was used to initiate the transaction.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import ProcessingInitiator
+
+value = ProcessingInitiator.INITIAL_CARD_ON_FILE
+```
+
## Values
diff --git a/docs/models/processor.md b/docs/models/processor.md
index 4de8e78f..bd8a430c 100644
--- a/docs/models/processor.md
+++ b/docs/models/processor.md
@@ -1,5 +1,13 @@
# Processor
+## Example Usage
+
+```python
+from bolt_api_sdk.models import Processor
+
+value = Processor.VANTIV
+```
+
## Values
diff --git a/docs/models/replaceaddresspriority.md b/docs/models/replaceaddresspriority.md
index d60fcceb..6111c94b 100644
--- a/docs/models/replaceaddresspriority.md
+++ b/docs/models/replaceaddresspriority.md
@@ -2,6 +2,14 @@
The shopper-indicated priority of this address compared to other addresses on their account.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import ReplaceAddressPriority
+
+value = ReplaceAddressPriority.PRIMARY
+```
+
## Values
diff --git a/docs/models/representmentresult.md b/docs/models/representmentresult.md
index 84603ed9..de1bb198 100644
--- a/docs/models/representmentresult.md
+++ b/docs/models/representmentresult.md
@@ -1,5 +1,13 @@
# RepresentmentResult
+## Example Usage
+
+```python
+from bolt_api_sdk.models import RepresentmentResult
+
+value = RepresentmentResult.NONE
+```
+
## Values
diff --git a/docs/models/requeststatus.md b/docs/models/requeststatus.md
index e1fa54f8..ff39aea9 100644
--- a/docs/models/requeststatus.md
+++ b/docs/models/requeststatus.md
@@ -1,5 +1,13 @@
# RequestStatus
+## Example Usage
+
+```python
+from bolt_api_sdk.models import RequestStatus
+
+value = RequestStatus.REVIEWED
+```
+
## Values
diff --git a/docs/models/riskdecisionfactoryml.md b/docs/models/riskdecisionfactoryml.md
index 17f377fc..9fc52515 100644
--- a/docs/models/riskdecisionfactoryml.md
+++ b/docs/models/riskdecisionfactoryml.md
@@ -2,6 +2,14 @@
One of the main contributing factors to the fraud decision and score.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import RiskDecisionFactorYml
+
+value = RiskDecisionFactorYml.ADDRESS_DETAILS
+```
+
## Values
diff --git a/docs/models/riskreviewstatus.md b/docs/models/riskreviewstatus.md
index 752d64cd..e3bef1d9 100644
--- a/docs/models/riskreviewstatus.md
+++ b/docs/models/riskreviewstatus.md
@@ -2,6 +2,14 @@
Describes the current Risk Review status. A transaction could be unreviewed, reviewed, or pending manual review by the Bolt team.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import RiskReviewStatus
+
+value = RiskReviewStatus.UNKNOWN
+```
+
## Values
diff --git a/docs/models/savedcreditcardviewtype.md b/docs/models/savedcreditcardviewtype.md
index 27ef542b..96b0a1f2 100644
--- a/docs/models/savedcreditcardviewtype.md
+++ b/docs/models/savedcreditcardviewtype.md
@@ -2,6 +2,14 @@
The payment method type. If empty, the property defaults to `card`.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import SavedCreditCardViewType
+
+value = SavedCreditCardViewType.CARD
+```
+
## Values
diff --git a/docs/models/savedpaypalaccountviewtype.md b/docs/models/savedpaypalaccountviewtype.md
index 39802865..34da7061 100644
--- a/docs/models/savedpaypalaccountviewtype.md
+++ b/docs/models/savedpaypalaccountviewtype.md
@@ -2,6 +2,14 @@
Type field indicates this is a saved PayPal to differentiate it from a saved card.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import SavedPaypalAccountViewType
+
+value = SavedPaypalAccountViewType.PAYPAL
+```
+
## Values
diff --git a/docs/models/scope.md b/docs/models/scope.md
index 64b1307f..1b474a90 100644
--- a/docs/models/scope.md
+++ b/docs/models/scope.md
@@ -2,6 +2,14 @@
The scope issued to the merchant when receiving an authorization code. Options include `bolt.account.manage`, `bolt.account.view`, `openid`. You can find more information on these options in our [OAuth scope documentation](https://help.bolt.com/developers/references/bolt-oauth/#scopes).
+## Example Usage
+
+```python
+from bolt_api_sdk.models import Scope
+
+value = Scope.BOLT_ACCOUNT_MANAGE
+```
+
## Values
diff --git a/docs/models/splitsviewtype.md b/docs/models/splitsviewtype.md
index 4553edcb..4c57423a 100644
--- a/docs/models/splitsviewtype.md
+++ b/docs/models/splitsviewtype.md
@@ -3,6 +3,14 @@
**Nullable** for Transactions Details.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import SplitsViewType
+
+value = SplitsViewType.NET
+```
+
## Values
diff --git a/docs/models/statementsfiletype.md b/docs/models/statementsfiletype.md
index c14d70c5..c3f370f7 100644
--- a/docs/models/statementsfiletype.md
+++ b/docs/models/statementsfiletype.md
@@ -2,6 +2,14 @@
This is the type of the file. Currently, Bolt only supports CSV statements.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import StatementsFileType
+
+value = StatementsFileType.CSV
+```
+
## Values
diff --git a/docs/models/statementstype.md b/docs/models/statementstype.md
index 709d58e9..38f97e58 100644
--- a/docs/models/statementstype.md
+++ b/docs/models/statementstype.md
@@ -6,6 +6,14 @@ The time period and statement type:
* [Dispute statement](https://help.bolt.com/operations/disputes/dispute-statements/#how-to-read-dispute-statements): Use `monthly_dispute`
+## Example Usage
+
+```python
+from bolt_api_sdk.models import StatementsType
+
+value = StatementsType.DAILY_TRANSACTION
+```
+
## Values
diff --git a/docs/models/trackingdetail.md b/docs/models/trackingdetail.md
index 417802aa..d354dd0e 100644
--- a/docs/models/trackingdetail.md
+++ b/docs/models/trackingdetail.md
@@ -7,7 +7,7 @@
| -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- |
| `city` | *str* | :heavy_check_mark: | N/A | New York |
| `country` | *str* | :heavy_check_mark: | N/A | USA |
-| `datetime` | [date](https://docs.python.org/3/library/datetime.html#date-objects) | :heavy_check_mark: | N/A | 2017-07-21T17:32:28Z |
+| `datetime_` | [date](https://docs.python.org/3/library/datetime.html#date-objects) | :heavy_check_mark: | N/A | 2017-07-21T17:32:28Z |
| `message` | *str* | :heavy_check_mark: | N/A | BILLING INFORMATION RECEIVED |
| `state` | *str* | :heavy_check_mark: | N/A | New York |
| `status` | [models.TrackingDetailStatus](../models/trackingdetailstatus.md) | :heavy_check_mark: | The transit status of the order being tracked. | in_transit |
diff --git a/docs/models/trackingdetailstatus.md b/docs/models/trackingdetailstatus.md
index 5978cc1d..51a7ab4b 100644
--- a/docs/models/trackingdetailstatus.md
+++ b/docs/models/trackingdetailstatus.md
@@ -2,6 +2,14 @@
The transit status of the order being tracked.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import TrackingDetailStatus
+
+value = TrackingDetailStatus.UNKNOWN
+```
+
## Values
diff --git a/docs/models/transactiondetailsviewviewstatus.md b/docs/models/transactiondetailsviewviewstatus.md
index d38eeb9e..bbdd581d 100644
--- a/docs/models/transactiondetailsviewviewstatus.md
+++ b/docs/models/transactiondetailsviewviewstatus.md
@@ -1,5 +1,13 @@
# TransactionDetailsViewViewStatus
+## Example Usage
+
+```python
+from bolt_api_sdk.models import TransactionDetailsViewViewStatus
+
+value = TransactionDetailsViewViewStatus.NOT_VIEWED
+```
+
## Values
diff --git a/docs/models/transactionindemnificationdecision.md b/docs/models/transactionindemnificationdecision.md
index 2b278a86..c40ca8d5 100644
--- a/docs/models/transactionindemnificationdecision.md
+++ b/docs/models/transactionindemnificationdecision.md
@@ -3,6 +3,14 @@
Describes whether the transaction is indemnified by Bolt for fraud.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import TransactionIndemnificationDecision
+
+value = TransactionIndemnificationDecision.UNKNOWN
+```
+
## Values
diff --git a/docs/models/transactionindemnificationreason.md b/docs/models/transactionindemnificationreason.md
index d7f094ba..9ab63700 100644
--- a/docs/models/transactionindemnificationreason.md
+++ b/docs/models/transactionindemnificationreason.md
@@ -3,6 +3,14 @@
Describes the reason that the transaction is or is not indemnified by Bolt for fraud.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import TransactionIndemnificationReason
+
+value = TransactionIndemnificationReason.UNKNOWN
+```
+
## Values
diff --git a/docs/models/transactionprocessor.md b/docs/models/transactionprocessor.md
index acc42482..777ab295 100644
--- a/docs/models/transactionprocessor.md
+++ b/docs/models/transactionprocessor.md
@@ -2,6 +2,14 @@
The processor used. **Nullable** for Transactions Details.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import TransactionProcessor
+
+value = TransactionProcessor.ADYEN_GATEWAY
+```
+
## Values
diff --git a/docs/models/transactionprocessorstatus.md b/docs/models/transactionprocessorstatus.md
index eaf9a027..c0c73c91 100644
--- a/docs/models/transactionprocessorstatus.md
+++ b/docs/models/transactionprocessorstatus.md
@@ -2,6 +2,14 @@
The processor's status. Only `primary` and `active` processor are displayed.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import TransactionProcessorStatus
+
+value = TransactionProcessorStatus.PRIMARY
+```
+
## Values
diff --git a/docs/models/transactionsplitsviewtype.md b/docs/models/transactionsplitsviewtype.md
index 55b3fe8a..3cbadc97 100644
--- a/docs/models/transactionsplitsviewtype.md
+++ b/docs/models/transactionsplitsviewtype.md
@@ -1,5 +1,13 @@
# TransactionSplitsViewType
+## Example Usage
+
+```python
+from bolt_api_sdk.models import TransactionSplitsViewType
+
+value = TransactionSplitsViewType.NET
+```
+
## Values
diff --git a/docs/models/transactionstatus.md b/docs/models/transactionstatus.md
index f0b1b63c..6046e8ef 100644
--- a/docs/models/transactionstatus.md
+++ b/docs/models/transactionstatus.md
@@ -2,6 +2,14 @@
The transaction's status.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import TransactionStatus
+
+value = TransactionStatus.IN_PROGRESS
+```
+
## Values
diff --git a/docs/models/transactiontimelineviewtype.md b/docs/models/transactiontimelineviewtype.md
index 78339bdf..211d58f4 100644
--- a/docs/models/transactiontimelineviewtype.md
+++ b/docs/models/transactiontimelineviewtype.md
@@ -1,5 +1,13 @@
# TransactionTimelineViewType
+## Example Usage
+
+```python
+from bolt_api_sdk.models import TransactionTimelineViewType
+
+value = TransactionTimelineViewType.COMPLETED
+```
+
## Values
diff --git a/docs/models/transactiontype.md b/docs/models/transactiontype.md
index 77c04843..8eb8b043 100644
--- a/docs/models/transactiontype.md
+++ b/docs/models/transactiontype.md
@@ -2,6 +2,14 @@
The type of transaction.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import TransactionType
+
+value = TransactionType.CC_PAYMENT
+```
+
## Values
diff --git a/docs/models/transactionviewviewstatus.md b/docs/models/transactionviewviewstatus.md
index deb4fb72..b91e54ba 100644
--- a/docs/models/transactionviewviewstatus.md
+++ b/docs/models/transactionviewviewstatus.md
@@ -1,5 +1,13 @@
# TransactionViewViewStatus
+## Example Usage
+
+```python
+from bolt_api_sdk.models import TransactionViewViewStatus
+
+value = TransactionViewViewStatus.NOT_VIEWED
+```
+
## Values
diff --git a/docs/models/type.md b/docs/models/type.md
index b320cd5e..e1e1bd72 100644
--- a/docs/models/type.md
+++ b/docs/models/type.md
@@ -2,6 +2,14 @@
Determines if item is a physical, digital, or bundled good, or if the good type is unknown.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import Type
+
+value = Type.BUNDLED
+```
+
## Values
diff --git a/docs/models/unit.md b/docs/models/unit.md
index d81ddb7f..259c3571 100644
--- a/docs/models/unit.md
+++ b/docs/models/unit.md
@@ -2,6 +2,14 @@
The unit for this subscription's frequency.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import Unit
+
+value = Unit.DAY
+```
+
## Values
diff --git a/docs/models/useridentifier.md b/docs/models/useridentifier.md
index 742ddd7f..856dac2e 100644
--- a/docs/models/useridentifier.md
+++ b/docs/models/useridentifier.md
@@ -7,8 +7,8 @@ The object containing key lookup IDs associated with the shopper's account, such
| Field | Type | Required | Description | Example |
| --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
-| `artifact` | *Optional[str]* | :heavy_minus_sign: | N/A | |
+| `artifact` | *Optional[str]* | :heavy_minus_sign: | N/A | null |
| `email` | *Optional[str]* | :heavy_minus_sign: | An email address. | alan.watts@example.com |
-| `email_id` | *Optional[str]* | :heavy_minus_sign: | The ID associated with the identifying email address for this account. | |
+| `email_id` | *Optional[str]* | :heavy_minus_sign: | The ID associated with the identifying email address for this account. | null |
| `phone` | *str* | :heavy_check_mark: | A phone number following E164 standards, in its globalized format, i.e. prepended with a plus sign. | +12125550199 |
-| `phone_id` | *Optional[str]* | :heavy_minus_sign: | The ID associated with the identifying phone number for this account. | |
\ No newline at end of file
+| `phone_id` | *Optional[str]* | :heavy_minus_sign: | The ID associated with the identifying phone number for this account. | null |
\ No newline at end of file
diff --git a/docs/models/voidcause.md b/docs/models/voidcause.md
index 44b72cae..dba29e55 100644
--- a/docs/models/voidcause.md
+++ b/docs/models/voidcause.md
@@ -2,6 +2,14 @@
Determines why the transaction was voided.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import VoidCause
+
+value = VoidCause.MERCHANT_ACTION
+```
+
## Values
diff --git a/docs/models/webhookeventgroup.md b/docs/models/webhookeventgroup.md
index e01069fa..76432597 100644
--- a/docs/models/webhookeventgroup.md
+++ b/docs/models/webhookeventgroup.md
@@ -4,6 +4,14 @@ Subscribe to a group of events.
`all`: subscribe to all existing and future event types
+## Example Usage
+
+```python
+from bolt_api_sdk.models import WebhookEventGroup
+
+value = WebhookEventGroup.ALL
+```
+
## Values
diff --git a/docs/models/webhookstype.md b/docs/models/webhookstype.md
index f96a6e9b..96363c15 100644
--- a/docs/models/webhookstype.md
+++ b/docs/models/webhookstype.md
@@ -3,6 +3,14 @@
[Webhook events](https://help.bolt.com/developers/guides/webhooks/#transaction-hook-types) that trigger a notification to the URL. **Note**:`newsletter_subscription` is only for merchant use cases.
+## Example Usage
+
+```python
+from bolt_api_sdk.models import WebhooksType
+
+value = WebhooksType.PAYMENT
+```
+
## Values
diff --git a/docs/sdks/account/README.md b/docs/sdks/account/README.md
index 8e939a2a..44a52cf1 100644
--- a/docs/sdks/account/README.md
+++ b/docs/sdks/account/README.md
@@ -1,5 +1,4 @@
# Account
-(*account*)
## Overview
diff --git a/docs/sdks/bolt/README.md b/docs/sdks/bolt/README.md
deleted file mode 100644
index f6e30098..00000000
--- a/docs/sdks/bolt/README.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# Bolt SDK
-
-## Overview
-
-Bolt API Reference: Postman Collection:
-
-[](https://god.gw.postman.com/run-collection/9136127-55d2bde1-a248-473f-95b5-64cfd02fb445?action=collection%2Ffork&collection-url=entityId%3D9136127-55d2bde1-a248-473f-95b5-64cfd02fb445%26entityType%3Dcollection%26workspaceId%3D78beee89-4238-4c5f-bd1f-7e98978744b4#?env%5BBolt%20Sandbox%20Environment%5D=W3sia2V5IjoiYXBpX2Jhc2VfdXJsIiwidmFsdWUiOiJodHRwczovL2FwaS1zYW5kYm94LmJvbHQuY29tIiwidHlwZSI6ImRlZmF1bHQiLCJlbmFibGVkIjp0cnVlfSx7ImtleSI6InRrX2Jhc2UiLCJ2YWx1ZSI6Imh0dHBzOi8vc2FuZGJveC5ib2x0dGsuY29tIiwidHlwZSI6ImRlZmF1bHQiLCJlbmFibGVkIjp0cnVlfSx7ImtleSI6ImFwaV9rZXkiLCJ2YWx1ZSI6IjxyZXBsYWNlIHdpdGggeW91ciBCb2x0IFNhbmRib3ggQVBJIGtleT4iLCJ0eXBlIjoic2VjcmV0IiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJwdWJsaXNoYWJsZV9rZXkiLCJ2YWx1ZSI6IjxyZXBsYWNlIHdpdGggeW91ciBCb2x0IFNhbmRib3ggcHVibGlzaGFibGUga2V5PiIsInR5cGUiOiJkZWZhdWx0IiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJkaXZpc2lvbl9pZCIsInZhbHVlIjoiPHJlcGxhY2Ugd2l0aCB5b3VyIEJvbHQgU2FuZGJveCBwdWJsaWMgZGl2aXNpb24gSUQ+IiwidHlwZSI6ImRlZmF1bHQiLCJlbmFibGVkIjp0cnVlfV0=)
-
-## About
- A comprehensive Bolt API reference for interacting with Transactions, Orders, Product Catalog, Configuration, Testing, and much more.
-
- Note: You must also reference the [Merchant Callback API](/api-merchant) when building a managed checkout custom cart integration
-
-
-### Available Operations
diff --git a/docs/sdks/configuration/README.md b/docs/sdks/configuration/README.md
index e527dd78..b9540b74 100644
--- a/docs/sdks/configuration/README.md
+++ b/docs/sdks/configuration/README.md
@@ -1,5 +1,4 @@
# Configuration
-(*configuration*)
## Overview
diff --git a/docs/sdks/oauth/README.md b/docs/sdks/oauth/README.md
index 986f525f..fe2a8c9f 100644
--- a/docs/sdks/oauth/README.md
+++ b/docs/sdks/oauth/README.md
@@ -1,5 +1,4 @@
# OAuth
-(*o_auth*)
## Overview
@@ -19,9 +18,9 @@ To use this endpoint, first use the Authorization Code Request flow by using the
**Reminder - the Content-Type of this request must be application/x-www-form-urlencoded**
-### Example Usage
+### Example Usage: authorization_code_request
-
+
```python
from bolt_api_sdk import Bolt, models
import os
@@ -34,9 +33,9 @@ with Bolt(
) as bolt:
res = bolt.o_auth.o_auth_token(request_body={
- "client_id": "",
- "client_secret": "",
- "code": "",
+ "client_id": "PUBLISHABLE_KEY_PLACEHOLDER",
+ "client_secret": "API_KEY_PLACEHOLDER",
+ "code": "AUTH_CODE_PLACEHOLDER",
"grant_type": models.OAuthTokenInputGrantType.AUTHORIZATION_CODE,
"scope": models.Scope.BOLT_ACCOUNT_VIEW,
})
@@ -44,6 +43,72 @@ with Bolt(
# Handle response
print(res)
+```
+### Example Usage: authorization_code_response
+
+
+```python
+from bolt_api_sdk import Bolt, models
+import os
+
+
+with Bolt(
+ security=models.Security(
+ x_api_key=os.getenv("BOLT_X_API_KEY", ""),
+ ),
+) as bolt:
+
+ res = bolt.o_auth.o_auth_token()
+
+ # Handle response
+ print(res)
+
+```
+### Example Usage: refresh_token_request
+
+
+```python
+from bolt_api_sdk import Bolt, models
+import os
+
+
+with Bolt(
+ security=models.Security(
+ x_api_key=os.getenv("BOLT_X_API_KEY", ""),
+ ),
+) as bolt:
+
+ res = bolt.o_auth.o_auth_token(request_body={
+ "client_id": "PUBLISHABLE_KEY_PLACEHOLDER",
+ "client_secret": "API_KEY_PLACEHOLDER",
+ "grant_type": models.OAuthTokenInputRefreshGrantType.REFRESH_TOKEN,
+ "refresh_token": "REFRESH_TOKEN_PLACEHOLDER",
+ "scope": "bolt.account.view",
+ })
+
+ # Handle response
+ print(res)
+
+```
+### Example Usage: refresh_token_response
+
+
+```python
+from bolt_api_sdk import Bolt, models
+import os
+
+
+with Bolt(
+ security=models.Security(
+ x_api_key=os.getenv("BOLT_X_API_KEY", ""),
+ ),
+) as bolt:
+
+ res = bolt.o_auth.o_auth_token()
+
+ # Handle response
+ print(res)
+
```
### Parameters
diff --git a/docs/sdks/orders/README.md b/docs/sdks/orders/README.md
index 35930e9b..1a85d55e 100644
--- a/docs/sdks/orders/README.md
+++ b/docs/sdks/orders/README.md
@@ -1,5 +1,4 @@
# Orders
-(*orders*)
## Overview
diff --git a/docs/sdks/statements/README.md b/docs/sdks/statements/README.md
index ea6c750d..ad2c804d 100644
--- a/docs/sdks/statements/README.md
+++ b/docs/sdks/statements/README.md
@@ -1,5 +1,4 @@
# Statements
-(*statements*)
## Overview
diff --git a/docs/sdks/testing/README.md b/docs/sdks/testing/README.md
index 1f241d9a..bed77f64 100644
--- a/docs/sdks/testing/README.md
+++ b/docs/sdks/testing/README.md
@@ -1,5 +1,4 @@
# Testing
-(*testing*)
## Overview
@@ -38,7 +37,7 @@ with Bolt(
{
"city": "New York",
"country": "USA",
- "datetime": parse_datetime("2017-07-21T17:32:28Z"),
+ "datetime_": parse_datetime("2017-07-21T17:32:28Z"),
"message": "BILLING INFORMATION RECEIVED",
"state": "New York",
"status": models.TrackingDetailStatus.IN_TRANSIT,
diff --git a/docs/sdks/transactions/README.md b/docs/sdks/transactions/README.md
index 1e0c4748..72f0d326 100644
--- a/docs/sdks/transactions/README.md
+++ b/docs/sdks/transactions/README.md
@@ -1,5 +1,4 @@
# Transactions
-(*transactions*)
## Overview
diff --git a/docs/sdks/webhooks/README.md b/docs/sdks/webhooks/README.md
index da95ea76..9d686db3 100644
--- a/docs/sdks/webhooks/README.md
+++ b/docs/sdks/webhooks/README.md
@@ -1,5 +1,4 @@
# Webhooks
-(*webhooks*)
## Overview
diff --git a/poetry.lock b/poetry.lock
index 6c4e5d62..17fa39b4 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -96,7 +96,7 @@ description = "Backport of PEP 654 (exception groups)"
optional = false
python-versions = ">=3.7"
groups = ["main"]
-markers = "python_version < \"3.11\""
+markers = "python_version == \"3.10\""
files = [
{file = "exceptiongroup-1.3.0-py3-none-any.whl", hash = "sha256:4d111e6e0c13d0644cad6ddaa7ed0261a0b36971f6d23e7ec9b4b9097da78a10"},
{file = "exceptiongroup-1.3.0.tar.gz", hash = "sha256:b241f5885f560bc56a59ee63ca4c6a8bfa46ae4ad651af316d4e81817bb9fd88"},
@@ -463,7 +463,6 @@ mccabe = ">=0.6,<0.8"
platformdirs = ">=2.2.0"
tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""}
tomlkit = ">=0.10.1"
-typing-extensions = {version = ">=3.10.0", markers = "python_version < \"3.10\""}
[package.extras]
spelling = ["pyenchant (>=3.2,<4.0)"]
@@ -471,14 +470,14 @@ testutils = ["gitpython (>3)"]
[[package]]
name = "pyright"
-version = "1.1.405"
+version = "1.1.398"
description = "Command line wrapper for pyright"
optional = false
python-versions = ">=3.7"
groups = ["dev"]
files = [
- {file = "pyright-1.1.405-py3-none-any.whl", hash = "sha256:a2cb13700b5508ce8e5d4546034cb7ea4aedb60215c6c33f56cec7f53996035a"},
- {file = "pyright-1.1.405.tar.gz", hash = "sha256:5c2a30e1037af27eb463a1cc0b9f6d65fec48478ccf092c1ac28385a15c55763"},
+ {file = "pyright-1.1.398-py3-none-any.whl", hash = "sha256:0a70bfd007d9ea7de1cf9740e1ad1a40a122592cfe22a3f6791b06162ad08753"},
+ {file = "pyright-1.1.398.tar.gz", hash = "sha256:357a13edd9be8082dc73be51190913e475fa41a6efb6ec0d4b7aab3bc11638d8"},
]
[package.dependencies]
@@ -509,7 +508,7 @@ description = "A lil' TOML parser"
optional = false
python-versions = ">=3.8"
groups = ["dev"]
-markers = "python_version < \"3.11\""
+markers = "python_version == \"3.10\""
files = [
{file = "tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249"},
{file = "tomli-2.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6"},
@@ -586,5 +585,5 @@ typing-extensions = ">=4.12.0"
[metadata]
lock-version = "2.1"
-python-versions = ">=3.9.2"
-content-hash = "feed8629015d65736379dae580e2f7eaa121b01095a9a91a2344efb03270b34e"
+python-versions = ">=3.10"
+content-hash = "b9ce93184dabbd3aebeddc118a61e5e48e0be9e513c3a4433601b6005506d6ac"
diff --git a/pylintrc b/pylintrc
index e8cd3e85..cb9c15d3 100644
--- a/pylintrc
+++ b/pylintrc
@@ -89,7 +89,7 @@ persistent=yes
# Minimum Python version to use for version dependent checks. Will default to
# the version used to run pylint.
-py-version=3.9
+py-version=3.10
# Discover python modules and packages in the file system subtree.
recursive=no
@@ -458,7 +458,8 @@ disable=raw-checker-failed,
consider-using-with,
wildcard-import,
unused-wildcard-import,
- too-many-return-statements
+ too-many-return-statements,
+ redefined-builtin
# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
diff --git a/pyproject.toml b/pyproject.toml
index a60c2721..86e378c4 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,18 +1,19 @@
[project]
name = "bolt-api-sdk"
-version = "0.5.6"
+version = "0.6.0"
description = "Python Client SDK Generated by Speakeasy."
authors = [{ name = "Speakeasy" },]
-readme = "README.md"
-requires-python = ">=3.9.2"
+readme = "README-PYPI.md"
+requires-python = ">=3.10"
dependencies = [
"httpcore >=1.0.9",
"httpx >=0.28.1",
- "pydantic >=2.11.2",
+ "pydantic >=2.11.2,<2.13",
]
[tool.poetry]
+repository = "https://github.com/BoltApp/Bolt-Python-SDK.git"
packages = [
{ include = "bolt_api_sdk", from = "src" }
]
@@ -27,7 +28,7 @@ in-project = true
[tool.poetry.group.dev.dependencies]
mypy = "==1.15.0"
pylint = "==3.2.3"
-pyright = "==1.1.405"
+pyright = "==1.1.398"
[build-system]
requires = ["poetry-core"]
diff --git a/scripts/prepare_readme.py b/scripts/prepare_readme.py
new file mode 100644
index 00000000..b28491f3
--- /dev/null
+++ b/scripts/prepare_readme.py
@@ -0,0 +1,35 @@
+"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
+
+import re
+import shutil
+
+try:
+ with open("README.md", "r", encoding="utf-8") as rh:
+ readme_contents = rh.read()
+ GITHUB_URL = "https://github.com/BoltApp/Bolt-Python-SDK.git"
+ GITHUB_URL = (
+ GITHUB_URL[: -len(".git")] if GITHUB_URL.endswith(".git") else GITHUB_URL
+ )
+ REPO_SUBDIR = ""
+ # links on PyPI should have absolute URLs
+ readme_contents = re.sub(
+ r"(\[[^\]]+\]\()((?!https?:)[^\)]+)(\))",
+ lambda m: m.group(1)
+ + GITHUB_URL
+ + "/blob/master/"
+ + REPO_SUBDIR
+ + m.group(2)
+ + m.group(3),
+ readme_contents,
+ )
+
+ with open("README-PYPI.md", "w", encoding="utf-8") as wh:
+ wh.write(readme_contents)
+except Exception as e:
+ try:
+ print("Failed to rewrite README.md to README-PYPI.md, copying original instead")
+ print(e)
+ shutil.copyfile("README.md", "README-PYPI.md")
+ except Exception as ie:
+ print("Failed to copy README.md to README-PYPI.md")
+ print(ie)
diff --git a/scripts/publish.sh b/scripts/publish.sh
index 5eb52a49..2a3ead70 100755
--- a/scripts/publish.sh
+++ b/scripts/publish.sh
@@ -1,4 +1,6 @@
#!/usr/bin/env bash
export POETRY_PYPI_TOKEN_PYPI=${PYPI_TOKEN}
+poetry run python scripts/prepare_readme.py
+
poetry publish --build --skip-existing
diff --git a/src/bolt_api_sdk/_hooks/oauth2scopes.py b/src/bolt_api_sdk/_hooks/oauth2scopes.py
new file mode 100644
index 00000000..7e1b4aa4
--- /dev/null
+++ b/src/bolt_api_sdk/_hooks/oauth2scopes.py
@@ -0,0 +1,22 @@
+"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
+
+from enum import Enum
+
+
+class OAuthOAuth2Scope(str, Enum):
+ r"""Available scopes for the OAuth OAuth 2.0 scheme (authorizationCode flow).
+
+ Bolt utilizes the OAuth flow that developers can use to attain access to Bolt Account data via APIs.
+ For all APIs that require authorization, please provide your `access_token` returned from `/v1/oauth/token` via the basic auth bearer header `Authorization: bearer ${TOKEN}`.
+ [Read more about the OAuth token endpoint.](/api-bolt/#tag/OAuth)
+
+ """
+
+ BOLT_ACCOUNT_MANAGE = "bolt.account.manage"
+ r"""This scope grants permissions to perform read/edit/delete actions on Bolt Account data"""
+
+ BOLT_ACCOUNT_VIEW = "bolt.account.view"
+ r"""This scope grants permissions to perform read only actions on Bolt Account data"""
+
+ OPENID = "openid"
+ r"""This scope grants permissions that enable Bolt SSO by granting an id token JWT that stores account data. Not used in v1/account endpoints"""
diff --git a/src/bolt_api_sdk/_hooks/types.py b/src/bolt_api_sdk/_hooks/types.py
index 6d208776..0d4e3c6b 100644
--- a/src/bolt_api_sdk/_hooks/types.py
+++ b/src/bolt_api_sdk/_hooks/types.py
@@ -3,7 +3,7 @@
from abc import ABC, abstractmethod
from bolt_api_sdk.sdkconfiguration import SDKConfiguration
import httpx
-from typing import Any, Callable, List, Optional, Tuple, Union
+from typing import Any, Callable, Dict, List, Optional, Tuple, Union
class HookContext:
@@ -12,6 +12,8 @@ class HookContext:
operation_id: str
oauth2_scopes: Optional[List[str]] = None
security_source: Optional[Union[Any, Callable[[], Any]]] = None
+ tags: Optional[List[str]] = None
+ extensions: Optional[Dict[str, Any]] = None
def __init__(
self,
@@ -20,12 +22,16 @@ def __init__(
operation_id: str,
oauth2_scopes: Optional[List[str]],
security_source: Optional[Union[Any, Callable[[], Any]]],
+ tags: Optional[List[str]],
+ extensions: Optional[Dict[str, Any]],
):
self.config = config
self.base_url = base_url
self.operation_id = operation_id
self.oauth2_scopes = oauth2_scopes
self.security_source = security_source
+ self.tags = tags
+ self.extensions = extensions
class BeforeRequestContext(HookContext):
@@ -36,6 +42,8 @@ def __init__(self, hook_ctx: HookContext):
hook_ctx.operation_id,
hook_ctx.oauth2_scopes,
hook_ctx.security_source,
+ hook_ctx.tags,
+ hook_ctx.extensions,
)
@@ -47,6 +55,8 @@ def __init__(self, hook_ctx: HookContext):
hook_ctx.operation_id,
hook_ctx.oauth2_scopes,
hook_ctx.security_source,
+ hook_ctx.tags,
+ hook_ctx.extensions,
)
@@ -58,6 +68,8 @@ def __init__(self, hook_ctx: HookContext):
hook_ctx.operation_id,
hook_ctx.oauth2_scopes,
hook_ctx.security_source,
+ hook_ctx.tags,
+ hook_ctx.extensions,
)
diff --git a/src/bolt_api_sdk/_version.py b/src/bolt_api_sdk/_version.py
index a4ce10c5..d109319d 100644
--- a/src/bolt_api_sdk/_version.py
+++ b/src/bolt_api_sdk/_version.py
@@ -3,10 +3,10 @@
import importlib.metadata
__title__: str = "bolt-api-sdk"
-__version__: str = "0.5.6"
+__version__: str = "0.6.0"
__openapi_doc_version__: str = "1.0.1"
-__gen_version__: str = "2.716.16"
-__user_agent__: str = "speakeasy-sdk/python 0.5.6 2.716.16 1.0.1 bolt-api-sdk"
+__gen_version__: str = "2.924.0"
+__user_agent__: str = "speakeasy-sdk/python 0.6.0 2.924.0 1.0.1 bolt-api-sdk"
try:
if __package__ is not None:
diff --git a/src/bolt_api_sdk/account.py b/src/bolt_api_sdk/account.py
index 2079a534..9590e486 100644
--- a/src/bolt_api_sdk/account.py
+++ b/src/bolt_api_sdk/account.py
@@ -60,6 +60,7 @@ def get_account(
accept_header_value="application/json",
http_headers=http_headers,
security=utils.get_pydantic_model(security, models.GetAccountSecurity),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -78,9 +79,11 @@ def get_account(
operation_id="getAccount",
oauth2_scopes=None,
security_source=get_security_from_env(security, models.Security),
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -143,6 +146,7 @@ async def get_account_async(
accept_header_value="application/json",
http_headers=http_headers,
security=utils.get_pydantic_model(security, models.GetAccountSecurity),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -161,9 +165,11 @@ async def get_account_async(
operation_id="getAccount",
oauth2_scopes=None,
security_source=get_security_from_env(security, models.Security),
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -195,6 +201,8 @@ def create_account(
Create a Bolt shopping account.
+ If set, this operation will use `x_api_key` from the global security.
+
:param x_publishable_key: The publicly viewable identifier used to identify a merchant division. This key is found in the Developer > API section of the Bolt Merchant Dashboard [RECOMMENDED].
:param idempotency_key: A key created by merchants that ensures `POST` and `PATCH` requests are only performed once. [Read more about Idempotent Requests here](/developers/references/idempotency/).
:param create_account_input:
@@ -235,12 +243,14 @@ def create_account(
http_headers=http_headers,
security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body(
- request.create_account_input,
+ request.create_account_input if request is not None else None,
False,
True,
"json",
Optional[models.CreateAccountInput],
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -257,13 +267,15 @@ def create_account(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="createAccount",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -295,6 +307,8 @@ async def create_account_async(
Create a Bolt shopping account.
+ If set, this operation will use `x_api_key` from the global security.
+
:param x_publishable_key: The publicly viewable identifier used to identify a merchant division. This key is found in the Developer > API section of the Bolt Merchant Dashboard [RECOMMENDED].
:param idempotency_key: A key created by merchants that ensures `POST` and `PATCH` requests are only performed once. [Read more about Idempotent Requests here](/developers/references/idempotency/).
:param create_account_input:
@@ -335,12 +349,14 @@ async def create_account_async(
http_headers=http_headers,
security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body(
- request.create_account_input,
+ request.create_account_input if request is not None else None,
False,
True,
"json",
Optional[models.CreateAccountInput],
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -357,13 +373,15 @@ async def create_account_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="createAccount",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -439,12 +457,13 @@ def update_account_profile(
security, models.UpdateAccountProfileSecurity
),
get_serialized_body=lambda: utils.serialize_request_body(
- request.update_profile,
+ request.update_profile if request is not None else None,
False,
True,
"json",
Optional[models.UpdateProfile],
),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -463,9 +482,11 @@ def update_account_profile(
operation_id="updateAccountProfile",
oauth2_scopes=None,
security_source=get_security_from_env(security, models.Security),
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -541,12 +562,13 @@ async def update_account_profile_async(
security, models.UpdateAccountProfileSecurity
),
get_serialized_body=lambda: utils.serialize_request_body(
- request.update_profile,
+ request.update_profile if request is not None else None,
False,
True,
"json",
Optional[models.UpdateProfile],
),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -565,9 +587,11 @@ async def update_account_profile_async(
operation_id="updateAccountProfile",
oauth2_scopes=None,
security_source=get_security_from_env(security, models.Security),
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -641,12 +665,13 @@ def add_address(
http_headers=http_headers,
security=utils.get_pydantic_model(security, models.AddAddressSecurity),
get_serialized_body=lambda: utils.serialize_request_body(
- request.address_account,
+ request.address_account if request is not None else None,
False,
True,
"json",
Optional[models.AddressAccount],
),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -665,9 +690,11 @@ def add_address(
operation_id="addAddress",
oauth2_scopes=None,
security_source=get_security_from_env(security, models.Security),
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -741,12 +768,13 @@ async def add_address_async(
http_headers=http_headers,
security=utils.get_pydantic_model(security, models.AddAddressSecurity),
get_serialized_body=lambda: utils.serialize_request_body(
- request.address_account,
+ request.address_account if request is not None else None,
False,
True,
"json",
Optional[models.AddressAccount],
),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -765,9 +793,11 @@ async def add_address_async(
operation_id="addAddress",
oauth2_scopes=None,
security_source=get_security_from_env(security, models.Security),
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -836,6 +866,7 @@ def delete_address(
accept_header_value="*/*",
http_headers=http_headers,
security=utils.get_pydantic_model(security, models.DeleteAddressSecurity),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -854,9 +885,11 @@ def delete_address(
operation_id="deleteAddress",
oauth2_scopes=None,
security_source=get_security_from_env(security, models.Security),
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -925,6 +958,7 @@ async def delete_address_async(
accept_header_value="*/*",
http_headers=http_headers,
security=utils.get_pydantic_model(security, models.DeleteAddressSecurity),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -943,9 +977,11 @@ async def delete_address_async(
operation_id="deleteAddress",
oauth2_scopes=None,
security_source=get_security_from_env(security, models.Security),
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -1019,11 +1055,15 @@ def replace_address(
:param door_code: The building door code or community gate code.
:param name: The given and surname of the person associated with this address.
:param phone: A phone number following E164 standards, in its globalized format, i.e. prepended with a plus sign.
- :param region_code: The ISO 3166-2 region code associated with this address. - * If specified, value must be valid for the `country`. - * If null, value is inferred from the `region`.
+ :param region_code: The ISO 3166-2 region code associated with this address.
+ - * If specified, value must be valid for the `country`.
+ - * If null, value is inferred from the `region`.
+
:param street_address2: Any apartment, floor, or unit details.
:param street_address3: Any additional street address details.
:param street_address4: Any additional street address details.
:param metadata: A key-value pair object that allows users to store arbitrary information associated with an object. For any individual account object, we allow up to 50 keys. Keys can be up to 40 characters long and values can be up to 500 characters long. Metadata should not contain any sensitive customer information, like PII (Personally Identifiable Information). For more information about metadata, see our [documentation](https://help.bolt.com/developers/references/embedded-metadata/).
+
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -1082,12 +1122,13 @@ def replace_address(
http_headers=http_headers,
security=utils.get_pydantic_model(security, models.ReplaceAddressSecurity),
get_serialized_body=lambda: utils.serialize_request_body(
- request.address_account,
+ request.address_account if request is not None else None,
False,
True,
"json",
Optional[models.AddressAccount],
),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -1106,9 +1147,11 @@ def replace_address(
operation_id="replaceAddress",
oauth2_scopes=None,
security_source=get_security_from_env(security, models.Security),
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -1182,11 +1225,15 @@ async def replace_address_async(
:param door_code: The building door code or community gate code.
:param name: The given and surname of the person associated with this address.
:param phone: A phone number following E164 standards, in its globalized format, i.e. prepended with a plus sign.
- :param region_code: The ISO 3166-2 region code associated with this address. - * If specified, value must be valid for the `country`. - * If null, value is inferred from the `region`.
+ :param region_code: The ISO 3166-2 region code associated with this address.
+ - * If specified, value must be valid for the `country`.
+ - * If null, value is inferred from the `region`.
+
:param street_address2: Any apartment, floor, or unit details.
:param street_address3: Any additional street address details.
:param street_address4: Any additional street address details.
:param metadata: A key-value pair object that allows users to store arbitrary information associated with an object. For any individual account object, we allow up to 50 keys. Keys can be up to 40 characters long and values can be up to 500 characters long. Metadata should not contain any sensitive customer information, like PII (Personally Identifiable Information). For more information about metadata, see our [documentation](https://help.bolt.com/developers/references/embedded-metadata/).
+
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -1245,12 +1292,13 @@ async def replace_address_async(
http_headers=http_headers,
security=utils.get_pydantic_model(security, models.ReplaceAddressSecurity),
get_serialized_body=lambda: utils.serialize_request_body(
- request.address_account,
+ request.address_account if request is not None else None,
False,
True,
"json",
Optional[models.AddressAccount],
),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -1269,9 +1317,11 @@ async def replace_address_async(
operation_id="replaceAddress",
oauth2_scopes=None,
security_source=get_security_from_env(security, models.Security),
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -1343,11 +1393,15 @@ def edit_address(
:param door_code: The building door code or community gate code.
:param name: The given and surname of the person associated with this address.
:param phone: A phone number following E164 standards, in its globalized format, i.e. prepended with a plus sign.
- :param region_code: The ISO 3166-2 region code associated with this address. - * If specified, value must be valid for the `country`. - * If null, value is inferred from the `region`.
+ :param region_code: The ISO 3166-2 region code associated with this address.
+ - * If specified, value must be valid for the `country`.
+ - * If null, value is inferred from the `region`.
+
:param street_address2: Any apartment, floor, or unit details.
:param street_address3: Any additional street address details.
:param street_address4: Any additional street address details.
:param metadata: A key-value pair object that allows users to store arbitrary information associated with an object. For any individual account object, we allow up to 50 keys. Keys can be up to 40 characters long and values can be up to 500 characters long. Metadata should not contain any sensitive customer information, like PII (Personally Identifiable Information). For more information about metadata, see our [documentation](https://help.bolt.com/developers/references/embedded-metadata/).
+
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -1405,12 +1459,13 @@ def edit_address(
http_headers=http_headers,
security=utils.get_pydantic_model(security, models.EditAddressSecurity),
get_serialized_body=lambda: utils.serialize_request_body(
- request.address_account,
+ request.address_account if request is not None else None,
False,
True,
"json",
Optional[models.AddressAccount],
),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -1429,9 +1484,11 @@ def edit_address(
operation_id="editAddress",
oauth2_scopes=None,
security_source=get_security_from_env(security, models.Security),
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -1503,11 +1560,15 @@ async def edit_address_async(
:param door_code: The building door code or community gate code.
:param name: The given and surname of the person associated with this address.
:param phone: A phone number following E164 standards, in its globalized format, i.e. prepended with a plus sign.
- :param region_code: The ISO 3166-2 region code associated with this address. - * If specified, value must be valid for the `country`. - * If null, value is inferred from the `region`.
+ :param region_code: The ISO 3166-2 region code associated with this address.
+ - * If specified, value must be valid for the `country`.
+ - * If null, value is inferred from the `region`.
+
:param street_address2: Any apartment, floor, or unit details.
:param street_address3: Any additional street address details.
:param street_address4: Any additional street address details.
:param metadata: A key-value pair object that allows users to store arbitrary information associated with an object. For any individual account object, we allow up to 50 keys. Keys can be up to 40 characters long and values can be up to 500 characters long. Metadata should not contain any sensitive customer information, like PII (Personally Identifiable Information). For more information about metadata, see our [documentation](https://help.bolt.com/developers/references/embedded-metadata/).
+
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -1565,12 +1626,13 @@ async def edit_address_async(
http_headers=http_headers,
security=utils.get_pydantic_model(security, models.EditAddressSecurity),
get_serialized_body=lambda: utils.serialize_request_body(
- request.address_account,
+ request.address_account if request is not None else None,
False,
True,
"json",
Optional[models.AddressAccount],
),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -1589,9 +1651,11 @@ async def edit_address_async(
operation_id="editAddress",
oauth2_scopes=None,
security_source=get_security_from_env(security, models.Security),
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -1660,6 +1724,7 @@ def detect_account(
user_agent_header="user-agent",
accept_header_value="application/json",
http_headers=http_headers,
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -1676,11 +1741,13 @@ def detect_account(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="detectAccount",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=None,
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -1755,6 +1822,7 @@ async def detect_account_async(
user_agent_header="user-agent",
accept_header_value="application/json",
http_headers=http_headers,
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -1771,11 +1839,13 @@ async def detect_account_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="detectAccount",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=None,
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -1865,12 +1935,13 @@ def add_payment_method(
security, models.AddPaymentMethodSecurity
),
get_serialized_body=lambda: utils.serialize_request_body(
- request.request_body,
+ request.request_body if request is not None else None,
False,
True,
"json",
Optional[models.AddPaymentMethodRequestBody],
),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -1889,9 +1960,11 @@ def add_payment_method(
operation_id="addPaymentMethod",
oauth2_scopes=None,
security_source=get_security_from_env(security, models.Security),
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -1975,12 +2048,13 @@ async def add_payment_method_async(
security, models.AddPaymentMethodSecurity
),
get_serialized_body=lambda: utils.serialize_request_body(
- request.request_body,
+ request.request_body if request is not None else None,
False,
True,
"json",
Optional[models.AddPaymentMethodRequestBody],
),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -1999,9 +2073,11 @@ async def add_payment_method_async(
operation_id="addPaymentMethod",
oauth2_scopes=None,
security_source=get_security_from_env(security, models.Security),
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -2072,6 +2148,7 @@ def delete_payment_method(
security=utils.get_pydantic_model(
security, models.DeletePaymentMethodSecurity
),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -2090,9 +2167,11 @@ def delete_payment_method(
operation_id="deletePaymentMethod",
oauth2_scopes=None,
security_source=get_security_from_env(security, models.Security),
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["403", "404", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -2169,6 +2248,7 @@ async def delete_payment_method_async(
security=utils.get_pydantic_model(
security, models.DeletePaymentMethodSecurity
),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -2187,9 +2267,11 @@ async def delete_payment_method_async(
operation_id="deletePaymentMethod",
oauth2_scopes=None,
security_source=get_security_from_env(security, models.Security),
+ tags=["Account"],
+ extensions=None,
),
request=req,
- error_status_codes=["403", "404", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
diff --git a/src/bolt_api_sdk/basesdk.py b/src/bolt_api_sdk/basesdk.py
index 3f281c6e..5a0f36fd 100644
--- a/src/bolt_api_sdk/basesdk.py
+++ b/src/bolt_api_sdk/basesdk.py
@@ -6,8 +6,14 @@
AfterErrorContext,
AfterSuccessContext,
BeforeRequestContext,
+ HookContext,
+)
+from bolt_api_sdk.utils import (
+ RetryConfig,
+ SerializedRequestBody,
+ get_body_content,
+ run_sync_in_thread,
)
-from bolt_api_sdk.utils import RetryConfig, SerializedRequestBody, get_body_content
import httpx
from typing import Callable, List, Mapping, Optional, Tuple
from urllib.parse import parse_qs, urlparse
@@ -60,6 +66,8 @@ def _build_request_async(
] = None,
url_override: Optional[str] = None,
http_headers: Optional[Mapping[str, str]] = None,
+ allow_empty_value: Optional[List[str]] = None,
+ allowed_fields: Optional[List[str]] = None,
) -> httpx.Request:
client = self.sdk_configuration.async_client
return self._build_request_with_client(
@@ -80,6 +88,8 @@ def _build_request_async(
get_serialized_body,
url_override,
http_headers,
+ allow_empty_value,
+ allowed_fields,
)
def _build_request(
@@ -102,6 +112,8 @@ def _build_request(
] = None,
url_override: Optional[str] = None,
http_headers: Optional[Mapping[str, str]] = None,
+ allow_empty_value: Optional[List[str]] = None,
+ allowed_fields: Optional[List[str]] = None,
) -> httpx.Request:
client = self.sdk_configuration.client
return self._build_request_with_client(
@@ -122,6 +134,8 @@ def _build_request(
get_serialized_body,
url_override,
http_headers,
+ allow_empty_value,
+ allowed_fields,
)
def _build_request_with_client(
@@ -145,6 +159,8 @@ def _build_request_with_client(
] = None,
url_override: Optional[str] = None,
http_headers: Optional[Mapping[str, str]] = None,
+ allow_empty_value: Optional[List[str]] = None,
+ allowed_fields: Optional[List[str]] = None,
) -> httpx.Request:
query_params = {}
@@ -160,6 +176,7 @@ def _build_request_with_client(
query_params = utils.get_query_params(
request if request_has_query_params else None,
_globals if request_has_query_params else None,
+ allow_empty_value,
)
else:
# Pick up the query parameter from the override so they can be
@@ -177,7 +194,9 @@ def _build_request_with_client(
security = security()
security = utils.get_security_from_env(security, models.Security)
if security is not None:
- security_headers, security_query_params = utils.get_security(security)
+ security_headers, security_query_params = utils.get_security(
+ security, allowed_fields
+ )
headers = {**headers, **security_headers}
query_params = {**query_params, **security_query_params}
@@ -214,15 +233,15 @@ def _build_request_with_client(
data=serialized_request_body.data,
files=serialized_request_body.files,
headers=headers,
- timeout=timeout,
+ timeout=timeout if timeout is not None else httpx.USE_CLIENT_DEFAULT,
)
def do_request(
self,
- hook_ctx,
- request,
- error_status_codes,
- stream=False,
+ hook_ctx: HookContext,
+ request: httpx.Request,
+ is_error_status_code: Callable[[int], bool],
+ stream: bool = False,
retry_config: Optional[Tuple[RetryConfig, List[str]]] = None,
) -> httpx.Response:
client = self.sdk_configuration.client
@@ -234,6 +253,8 @@ def do():
http_res = None
try:
req = hooks.before_request(BeforeRequestContext(hook_ctx), request)
+ if "timeout" in request.extensions and "timeout" not in req.extensions:
+ req.extensions["timeout"] = request.extensions["timeout"]
logger.debug(
"Request:\nMethod: %s\nURL: %s\nHeaders: %s\nBody: %s",
req.method,
@@ -264,19 +285,6 @@ def do():
"" if stream else http_res.text,
)
- if utils.match_status_codes(error_status_codes, http_res.status_code):
- result, err = hooks.after_error(
- AfterErrorContext(hook_ctx), http_res, None
- )
- if err is not None:
- logger.debug("Request Exception", exc_info=True)
- raise err
- if result is not None:
- http_res = result
- else:
- logger.debug("Raising unexpected SDK error")
- raise errors.APIError("Unexpected error occurred", http_res)
-
return http_res
if retry_config is not None:
@@ -284,17 +292,27 @@ def do():
else:
http_res = do()
- if not utils.match_status_codes(error_status_codes, http_res.status_code):
+ if is_error_status_code(http_res.status_code):
+ result, err = hooks.after_error(AfterErrorContext(hook_ctx), http_res, None)
+ if err is not None:
+ logger.debug("Request Exception", exc_info=True)
+ raise err
+ if result is not None:
+ http_res = result
+ else:
+ logger.debug("Raising unexpected SDK error")
+ raise errors.APIError("Unexpected error occurred", http_res)
+ else:
http_res = hooks.after_success(AfterSuccessContext(hook_ctx), http_res)
return http_res
async def do_request_async(
self,
- hook_ctx,
- request,
- error_status_codes,
- stream=False,
+ hook_ctx: HookContext,
+ request: httpx.Request,
+ is_error_status_code: Callable[[int], bool],
+ stream: bool = False,
retry_config: Optional[Tuple[RetryConfig, List[str]]] = None,
) -> httpx.Response:
client = self.sdk_configuration.async_client
@@ -305,7 +323,12 @@ async def do_request_async(
async def do():
http_res = None
try:
- req = hooks.before_request(BeforeRequestContext(hook_ctx), request)
+ req = await run_sync_in_thread(
+ hooks.before_request, BeforeRequestContext(hook_ctx), request
+ )
+
+ if "timeout" in request.extensions and "timeout" not in req.extensions:
+ req.extensions["timeout"] = request.extensions["timeout"]
logger.debug(
"Request:\nMethod: %s\nURL: %s\nHeaders: %s\nBody: %s",
req.method,
@@ -319,7 +342,10 @@ async def do():
http_res = await client.send(req, stream=stream)
except Exception as e:
- _, e = hooks.after_error(AfterErrorContext(hook_ctx), None, e)
+ _, e = await run_sync_in_thread(
+ hooks.after_error, AfterErrorContext(hook_ctx), None, e
+ )
+
if e is not None:
logger.debug("Request Exception", exc_info=True)
raise e
@@ -336,19 +362,6 @@ async def do():
"" if stream else http_res.text,
)
- if utils.match_status_codes(error_status_codes, http_res.status_code):
- result, err = hooks.after_error(
- AfterErrorContext(hook_ctx), http_res, None
- )
- if err is not None:
- logger.debug("Request Exception", exc_info=True)
- raise err
- if result is not None:
- http_res = result
- else:
- logger.debug("Raising unexpected SDK error")
- raise errors.APIError("Unexpected error occurred", http_res)
-
return http_res
if retry_config is not None:
@@ -358,7 +371,22 @@ async def do():
else:
http_res = await do()
- if not utils.match_status_codes(error_status_codes, http_res.status_code):
- http_res = hooks.after_success(AfterSuccessContext(hook_ctx), http_res)
+ if is_error_status_code(http_res.status_code):
+ result, err = await run_sync_in_thread(
+ hooks.after_error, AfterErrorContext(hook_ctx), http_res, None
+ )
+
+ if err is not None:
+ logger.debug("Request Exception", exc_info=True)
+ raise err
+ if result is not None:
+ http_res = result
+ else:
+ logger.debug("Raising unexpected SDK error")
+ raise errors.APIError("Unexpected error occurred", http_res)
+ else:
+ http_res = await run_sync_in_thread(
+ hooks.after_success, AfterSuccessContext(hook_ctx), http_res
+ )
return http_res
diff --git a/src/bolt_api_sdk/configuration.py b/src/bolt_api_sdk/configuration.py
index ca1ff860..e5f530c5 100644
--- a/src/bolt_api_sdk/configuration.py
+++ b/src/bolt_api_sdk/configuration.py
@@ -25,6 +25,8 @@ def get_merchant_callbacks(
Retrieves callbacks URLs for a Bolt merchant division.
+ If set, this operation will use `x_api_key` from the global security.
+
:param division_id: The unique ID associated to the merchant's Bolt Account division; Merchants can have different divisions to suit multiple use cases (storefronts, pay-by-link, phone order processing). You can view and switch between these divisions from the Bolt Merchant Dashboard.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -58,6 +60,8 @@ def get_merchant_callbacks(
accept_header_value="application/json",
http_headers=http_headers,
security=self.sdk_configuration.security,
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -74,13 +78,15 @@ def get_merchant_callbacks(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="getMerchantCallbacks",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Configuration"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "403", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -114,6 +120,8 @@ async def get_merchant_callbacks_async(
Retrieves callbacks URLs for a Bolt merchant division.
+ If set, this operation will use `x_api_key` from the global security.
+
:param division_id: The unique ID associated to the merchant's Bolt Account division; Merchants can have different divisions to suit multiple use cases (storefronts, pay-by-link, phone order processing). You can view and switch between these divisions from the Bolt Merchant Dashboard.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -147,6 +155,8 @@ async def get_merchant_callbacks_async(
accept_header_value="application/json",
http_headers=http_headers,
security=self.sdk_configuration.security,
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -163,13 +173,15 @@ async def get_merchant_callbacks_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="getMerchantCallbacks",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Configuration"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "403", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -205,6 +217,8 @@ def set_merchant_callbacks(
Configure callbacks URLs for a Bolt merchant division. This will store or override only the callback URLs that are specified in the request. Operations are fully transactional.
+ If set, this operation will use `x_api_key` from the global security.
+
:param request: The request object to send.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -241,6 +255,8 @@ def set_merchant_callbacks(
get_serialized_body=lambda: utils.serialize_request_body(
request, False, True, "json", Optional[models.MerchantCallbacksInput]
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -257,13 +273,15 @@ def set_merchant_callbacks(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="setMerchantCallbacks",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Configuration"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "403", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -299,6 +317,8 @@ async def set_merchant_callbacks_async(
Configure callbacks URLs for a Bolt merchant division. This will store or override only the callback URLs that are specified in the request. Operations are fully transactional.
+ If set, this operation will use `x_api_key` from the global security.
+
:param request: The request object to send.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -335,6 +355,8 @@ async def set_merchant_callbacks_async(
get_serialized_body=lambda: utils.serialize_request_body(
request, False, True, "json", Optional[models.MerchantCallbacksInput]
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -351,13 +373,15 @@ async def set_merchant_callbacks_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="setMerchantCallbacks",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Configuration"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "403", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -390,6 +414,8 @@ def get_merchant_identifiers(
This endpoint returns the merchant's public ID and the [publishable key](https://help.bolt.com/developers/tools/api-keys/) related to the merchant division.
+ If set, this operation will use `x_api_key` from the global security.
+
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -417,6 +443,8 @@ def get_merchant_identifiers(
accept_header_value="application/json",
http_headers=http_headers,
security=self.sdk_configuration.security,
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -433,13 +461,15 @@ def get_merchant_identifiers(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="getMerchantIdentifiers",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Configuration"],
+ extensions=None,
),
request=req,
- error_status_codes=["403", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -472,6 +502,8 @@ async def get_merchant_identifiers_async(
This endpoint returns the merchant's public ID and the [publishable key](https://help.bolt.com/developers/tools/api-keys/) related to the merchant division.
+ If set, this operation will use `x_api_key` from the global security.
+
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -499,6 +531,8 @@ async def get_merchant_identifiers_async(
accept_header_value="application/json",
http_headers=http_headers,
security=self.sdk_configuration.security,
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -515,13 +549,15 @@ async def get_merchant_identifiers_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="getMerchantIdentifiers",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Configuration"],
+ extensions=None,
),
request=req,
- error_status_codes=["403", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
diff --git a/src/bolt_api_sdk/errors/__init__.py b/src/bolt_api_sdk/errors/__init__.py
index 74978a79..f0468dcd 100644
--- a/src/bolt_api_sdk/errors/__init__.py
+++ b/src/bolt_api_sdk/errors/__init__.py
@@ -1,10 +1,9 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from .bolterror import BoltError
-from typing import TYPE_CHECKING
-from importlib import import_module
-import builtins
-import sys
+from typing import Any, TYPE_CHECKING
+
+from bolt_api_sdk.utils.dynamic_imports import lazy_getattr, lazy_dir
if TYPE_CHECKING:
from .apierror import APIError
@@ -49,39 +48,11 @@
}
-def dynamic_import(modname, retries=3):
- for attempt in range(retries):
- try:
- return import_module(modname, __package__)
- except KeyError:
- # Clear any half-initialized module and retry
- sys.modules.pop(modname, None)
- if attempt == retries - 1:
- break
- raise KeyError(f"Failed to import module '{modname}' after {retries} attempts")
-
-
-def __getattr__(attr_name: str) -> object:
- module_name = _dynamic_imports.get(attr_name)
- if module_name is None:
- raise AttributeError(
- f"No {attr_name} found in _dynamic_imports for module name -> {__name__} "
- )
-
- try:
- module = dynamic_import(module_name)
- result = getattr(module, attr_name)
- return result
- except ImportError as e:
- raise ImportError(
- f"Failed to import {attr_name} from {module_name}: {e}"
- ) from e
- except AttributeError as e:
- raise AttributeError(
- f"Failed to get {attr_name} from {module_name}: {e}"
- ) from e
+def __getattr__(attr_name: str) -> Any:
+ return lazy_getattr(
+ attr_name, package=__package__, dynamic_imports=_dynamic_imports
+ )
def __dir__():
- lazy_attrs = builtins.list(_dynamic_imports.keys())
- return builtins.sorted(lazy_attrs)
+ return lazy_dir(dynamic_imports=_dynamic_imports)
diff --git a/src/bolt_api_sdk/errors/apierror.py b/src/bolt_api_sdk/errors/apierror.py
index 66e602d1..7e1eda9c 100644
--- a/src/bolt_api_sdk/errors/apierror.py
+++ b/src/bolt_api_sdk/errors/apierror.py
@@ -9,7 +9,7 @@
MAX_MESSAGE_LEN = 10_000
-@dataclass(frozen=True)
+@dataclass(unsafe_hash=True)
class APIError(BoltError):
"""The fallback error class if no more specific error class is matched."""
diff --git a/src/bolt_api_sdk/errors/bolterror.py b/src/bolt_api_sdk/errors/bolterror.py
index c010edc9..971369cc 100644
--- a/src/bolt_api_sdk/errors/bolterror.py
+++ b/src/bolt_api_sdk/errors/bolterror.py
@@ -5,7 +5,7 @@
from dataclasses import dataclass, field
-@dataclass(frozen=True)
+@dataclass(unsafe_hash=True)
class BoltError(Exception):
"""The base class for all HTTP error responses."""
diff --git a/src/bolt_api_sdk/errors/capturetransactionop.py b/src/bolt_api_sdk/errors/capturetransactionop.py
index fdc7fda8..dd974949 100644
--- a/src/bolt_api_sdk/errors/capturetransactionop.py
+++ b/src/bolt_api_sdk/errors/capturetransactionop.py
@@ -11,11 +11,10 @@
class UnprocessableEntityErrorData(BaseModel):
errors: Optional[List[models_capturetransactionop.Error]] = None
-
result: Optional[models_capturetransactionop.Result] = None
-@dataclass(frozen=True)
+@dataclass(unsafe_hash=True)
class UnprocessableEntityError(BoltError):
r"""Unprocessable Entity"""
diff --git a/src/bolt_api_sdk/errors/errors_bolt_api_response.py b/src/bolt_api_sdk/errors/errors_bolt_api_response.py
index a3a25609..a62ed5eb 100644
--- a/src/bolt_api_sdk/errors/errors_bolt_api_response.py
+++ b/src/bolt_api_sdk/errors/errors_bolt_api_response.py
@@ -14,12 +14,11 @@
class ErrorsBoltAPIResponseData(BaseModel):
errors: Optional[List[models_error_bolt_api.ErrorBoltAPI]] = None
-
result: Optional[models_request_result.RequestResult] = None
r"""Custom-defined Bolt result object."""
-@dataclass(frozen=True)
+@dataclass(unsafe_hash=True)
class ErrorsBoltAPIResponse(BoltError):
data: ErrorsBoltAPIResponseData = field(hash=False)
diff --git a/src/bolt_api_sdk/errors/errors_oauth_server_response.py b/src/bolt_api_sdk/errors/errors_oauth_server_response.py
index 7b03b01a..44f5b48e 100644
--- a/src/bolt_api_sdk/errors/errors_oauth_server_response.py
+++ b/src/bolt_api_sdk/errors/errors_oauth_server_response.py
@@ -10,11 +10,10 @@
class ErrorsOauthServerResponseData(BaseModel):
error: Optional[str] = None
-
error_description: Optional[str] = None
-@dataclass(frozen=True)
+@dataclass(unsafe_hash=True)
class ErrorsOauthServerResponse(BoltError):
r"""Invalid request to OAuth Token."""
diff --git a/src/bolt_api_sdk/errors/no_response_error.py b/src/bolt_api_sdk/errors/no_response_error.py
index b710ea2b..1deab64b 100644
--- a/src/bolt_api_sdk/errors/no_response_error.py
+++ b/src/bolt_api_sdk/errors/no_response_error.py
@@ -3,7 +3,7 @@
from dataclasses import dataclass
-@dataclass(frozen=True)
+@dataclass(unsafe_hash=True)
class NoResponseError(Exception):
"""Error raised when no HTTP response is received from the server."""
diff --git a/src/bolt_api_sdk/errors/responsevalidationerror.py b/src/bolt_api_sdk/errors/responsevalidationerror.py
index 6f748bf2..0149d6ec 100644
--- a/src/bolt_api_sdk/errors/responsevalidationerror.py
+++ b/src/bolt_api_sdk/errors/responsevalidationerror.py
@@ -7,7 +7,7 @@
from bolt_api_sdk.errors import BoltError
-@dataclass(frozen=True)
+@dataclass(unsafe_hash=True)
class ResponseValidationError(BoltError):
"""Error raised when there is a type mismatch between the response data and the expected Pydantic model."""
diff --git a/src/bolt_api_sdk/httpclient.py b/src/bolt_api_sdk/httpclient.py
index 47b052cb..89560b56 100644
--- a/src/bolt_api_sdk/httpclient.py
+++ b/src/bolt_api_sdk/httpclient.py
@@ -107,7 +107,6 @@ def close_clients(
# to them from the owning SDK instance and they can be reaped.
owner.client = None
owner.async_client = None
-
if sync_client is not None and not sync_client_supplied:
try:
sync_client.close()
diff --git a/src/bolt_api_sdk/models/__init__.py b/src/bolt_api_sdk/models/__init__.py
index 7a575fe6..ab2363bc 100644
--- a/src/bolt_api_sdk/models/__init__.py
+++ b/src/bolt_api_sdk/models/__init__.py
@@ -1,9 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
-from typing import TYPE_CHECKING
-from importlib import import_module
-import builtins
-import sys
+from typing import Any, TYPE_CHECKING
+
+from bolt_api_sdk.utils.dynamic_imports import lazy_getattr, lazy_dir
if TYPE_CHECKING:
from .account_details import (
@@ -1676,39 +1675,11 @@
}
-def dynamic_import(modname, retries=3):
- for attempt in range(retries):
- try:
- return import_module(modname, __package__)
- except KeyError:
- # Clear any half-initialized module and retry
- sys.modules.pop(modname, None)
- if attempt == retries - 1:
- break
- raise KeyError(f"Failed to import module '{modname}' after {retries} attempts")
-
-
-def __getattr__(attr_name: str) -> object:
- module_name = _dynamic_imports.get(attr_name)
- if module_name is None:
- raise AttributeError(
- f"No {attr_name} found in _dynamic_imports for module name -> {__name__} "
- )
-
- try:
- module = dynamic_import(module_name)
- result = getattr(module, attr_name)
- return result
- except ImportError as e:
- raise ImportError(
- f"Failed to import {attr_name} from {module_name}: {e}"
- ) from e
- except AttributeError as e:
- raise AttributeError(
- f"Failed to get {attr_name} from {module_name}: {e}"
- ) from e
+def __getattr__(attr_name: str) -> Any:
+ return lazy_getattr(
+ attr_name, package=__package__, dynamic_imports=_dynamic_imports
+ )
def __dir__():
- lazy_attrs = builtins.list(_dynamic_imports.keys())
- return builtins.sorted(lazy_attrs)
+ return lazy_dir(dynamic_imports=_dynamic_imports)
diff --git a/src/bolt_api_sdk/models/account_details.py b/src/bolt_api_sdk/models/account_details.py
index 32787dc7..225c2dc1 100644
--- a/src/bolt_api_sdk/models/account_details.py
+++ b/src/bolt_api_sdk/models/account_details.py
@@ -11,7 +11,8 @@
SavedPaypalAccountView,
SavedPaypalAccountViewTypedDict,
)
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import List, Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict
@@ -50,3 +51,21 @@ class AccountDetails(BaseModel):
profile: Optional[ProfileView] = None
r"""The shopper's account profile."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ ["addresses", "has_bolt_account", "payment_methods", "profile"]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/account_details_address_view.py b/src/bolt_api_sdk/models/account_details_address_view.py
index 3932d277..7ac072c0 100644
--- a/src/bolt_api_sdk/models/account_details_address_view.py
+++ b/src/bolt_api_sdk/models/account_details_address_view.py
@@ -141,59 +141,58 @@ class AccountDetailsAddressView(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = [
- "company",
- "country",
- "country_code",
- "door_code",
- "email_address",
- "first_name",
- "id",
- "last_name",
- "locality",
- "name",
- "phone_number",
- "postal_code",
- "priority",
- "region",
- "region_code",
- "street_address1",
- "street_address2",
- "street_address3",
- "street_address4",
- "default",
- "metadata",
- ]
- nullable_fields = [
- "door_code",
- "priority",
- "region_code",
- "street_address3",
- "street_address4",
- "metadata",
- ]
- null_default_fields = []
-
+ optional_fields = set(
+ [
+ "company",
+ "country",
+ "country_code",
+ "door_code",
+ "email_address",
+ "first_name",
+ "id",
+ "last_name",
+ "locality",
+ "name",
+ "phone_number",
+ "postal_code",
+ "priority",
+ "region",
+ "region_code",
+ "street_address1",
+ "street_address2",
+ "street_address3",
+ "street_address4",
+ "default",
+ "metadata",
+ ]
+ )
+ nullable_fields = set(
+ [
+ "door_code",
+ "priority",
+ "region_code",
+ "street_address3",
+ "street_address4",
+ "metadata",
+ ]
+ )
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/addaddressop.py b/src/bolt_api_sdk/models/addaddressop.py
index 6c383e5e..b129b4e8 100644
--- a/src/bolt_api_sdk/models/addaddressop.py
+++ b/src/bolt_api_sdk/models/addaddressop.py
@@ -33,7 +33,10 @@ class AddAddressSecurity(BaseModel):
str,
FieldMetadata(
security=SecurityMetadata(
- scheme=True, scheme_type="oauth2", field_name="Authorization"
+ scheme=True,
+ scheme_type="oauth2",
+ composite=True,
+ field_name="Authorization",
)
),
]
@@ -45,6 +48,7 @@ class AddAddressSecurity(BaseModel):
scheme=True,
scheme_type="apiKey",
sub_type="header",
+ composite=True,
field_name="X-API-Key",
)
),
@@ -79,6 +83,24 @@ class AddAddressRequest(BaseModel):
FieldMetadata(request=RequestMetadata(media_type="application/json")),
] = None
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ ["X-Publishable-Key", "Idempotency-Key", "address_account"]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
class AddAddressPriority(str, Enum):
r"""The shopper-indicated priority of this address compared to other addresses on their account."""
@@ -204,59 +226,58 @@ class AddAddressResponse(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = [
- "company",
- "country",
- "country_code",
- "door_code",
- "email_address",
- "first_name",
- "id",
- "last_name",
- "locality",
- "name",
- "phone_number",
- "postal_code",
- "priority",
- "region",
- "region_code",
- "street_address1",
- "street_address2",
- "street_address3",
- "street_address4",
- "metadata",
- "default",
- ]
- nullable_fields = [
- "door_code",
- "priority",
- "region_code",
- "street_address3",
- "street_address4",
- "metadata",
- ]
- null_default_fields = []
-
+ optional_fields = set(
+ [
+ "company",
+ "country",
+ "country_code",
+ "door_code",
+ "email_address",
+ "first_name",
+ "id",
+ "last_name",
+ "locality",
+ "name",
+ "phone_number",
+ "postal_code",
+ "priority",
+ "region",
+ "region_code",
+ "street_address1",
+ "street_address2",
+ "street_address3",
+ "street_address4",
+ "metadata",
+ "default",
+ ]
+ )
+ nullable_fields = set(
+ [
+ "door_code",
+ "priority",
+ "region_code",
+ "street_address3",
+ "street_address4",
+ "metadata",
+ ]
+ )
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/addpaymentmethodop.py b/src/bolt_api_sdk/models/addpaymentmethodop.py
index eb657052..773a059d 100644
--- a/src/bolt_api_sdk/models/addpaymentmethodop.py
+++ b/src/bolt_api_sdk/models/addpaymentmethodop.py
@@ -33,7 +33,10 @@ class AddPaymentMethodSecurity(BaseModel):
str,
FieldMetadata(
security=SecurityMetadata(
- scheme=True, scheme_type="oauth2", field_name="Authorization"
+ scheme=True,
+ scheme_type="oauth2",
+ composite=True,
+ field_name="Authorization",
)
),
]
@@ -45,6 +48,7 @@ class AddPaymentMethodSecurity(BaseModel):
scheme=True,
scheme_type="apiKey",
sub_type="header",
+ composite=True,
field_name="X-API-Key",
)
),
@@ -185,45 +189,42 @@ class AddPaymentMethodRequestBody(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = [
- "billing_address_id",
- "bin",
- "cryptogram",
- "eci",
- "last4",
- "metadata",
- "network",
- "number",
- "postal_code",
- "priority",
- "save",
- "token_type",
- "currency",
- ]
- nullable_fields = ["billing_address_id", "metadata"]
- null_default_fields = []
-
+ optional_fields = set(
+ [
+ "billing_address_id",
+ "bin",
+ "cryptogram",
+ "eci",
+ "last4",
+ "metadata",
+ "network",
+ "number",
+ "postal_code",
+ "priority",
+ "save",
+ "token_type",
+ "currency",
+ ]
+ )
+ nullable_fields = set(["billing_address_id", "metadata"])
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
@@ -255,3 +256,19 @@ class AddPaymentMethodRequest(BaseModel):
Optional[AddPaymentMethodRequestBody],
FieldMetadata(request=RequestMetadata(media_type="application/json")),
] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["X-Publishable-Key", "Idempotency-Key", "RequestBody"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/address.py b/src/bolt_api_sdk/models/address.py
index 33a91249..b5a955bf 100644
--- a/src/bolt_api_sdk/models/address.py
+++ b/src/bolt_api_sdk/models/address.py
@@ -121,46 +121,40 @@ class Address(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = [
- "company",
- "country",
- "default",
- "door_code",
- "name",
- "phone",
- "region_code",
- "street_address2",
- "street_address3",
- "street_address4",
- ]
- nullable_fields = [
- "door_code",
- "region_code",
- "street_address3",
- "street_address4",
- ]
- null_default_fields = []
-
+ optional_fields = set(
+ [
+ "company",
+ "country",
+ "default",
+ "door_code",
+ "name",
+ "phone",
+ "region_code",
+ "street_address2",
+ "street_address3",
+ "street_address4",
+ ]
+ )
+ nullable_fields = set(
+ ["door_code", "region_code", "street_address3", "street_address4"]
+ )
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/address_account.py b/src/bolt_api_sdk/models/address_account.py
index dce2c43e..036b80b3 100644
--- a/src/bolt_api_sdk/models/address_account.py
+++ b/src/bolt_api_sdk/models/address_account.py
@@ -131,48 +131,47 @@ class AddressAccount(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = [
- "company",
- "country",
- "default",
- "door_code",
- "name",
- "phone",
- "region_code",
- "street_address2",
- "street_address3",
- "street_address4",
- "metadata",
- ]
- nullable_fields = [
- "door_code",
- "region_code",
- "street_address3",
- "street_address4",
- "metadata",
- ]
- null_default_fields = []
-
+ optional_fields = set(
+ [
+ "company",
+ "country",
+ "default",
+ "door_code",
+ "name",
+ "phone",
+ "region_code",
+ "street_address2",
+ "street_address3",
+ "street_address4",
+ "metadata",
+ ]
+ )
+ nullable_fields = set(
+ [
+ "door_code",
+ "region_code",
+ "street_address3",
+ "street_address4",
+ "metadata",
+ ]
+ )
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/address_change_request_metadata_view.py b/src/bolt_api_sdk/models/address_change_request_metadata_view.py
index 8e6bcba5..d8055473 100644
--- a/src/bolt_api_sdk/models/address_change_request_metadata_view.py
+++ b/src/bolt_api_sdk/models/address_change_request_metadata_view.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -24,3 +25,27 @@ class AddressChangeRequestMetadataView(BaseModel):
ticket_id: Optional[str] = None
ticket_status: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "can_change_shipping_address",
+ "id",
+ "status",
+ "ticket_id",
+ "ticket_status",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/address_change_view.py b/src/bolt_api_sdk/models/address_change_view.py
index 9ddce578..cc32fb77 100644
--- a/src/bolt_api_sdk/models/address_change_view.py
+++ b/src/bolt_api_sdk/models/address_change_view.py
@@ -2,7 +2,8 @@
from __future__ import annotations
from .address_view import AddressView, AddressViewTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -29,3 +30,21 @@ class AddressChangeView(BaseModel):
to_address: Optional[AddressView] = None
r"""The address object returned in the response."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ ["from_address", "status", "ticket_id", "timestamp", "to_address"]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/address_view.py b/src/bolt_api_sdk/models/address_view.py
index 9ca3ced2..4c084b8d 100644
--- a/src/bolt_api_sdk/models/address_view.py
+++ b/src/bolt_api_sdk/models/address_view.py
@@ -126,56 +126,55 @@ class AddressView(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = [
- "company",
- "country",
- "country_code",
- "door_code",
- "email_address",
- "first_name",
- "id",
- "last_name",
- "locality",
- "name",
- "phone_number",
- "postal_code",
- "priority",
- "region",
- "region_code",
- "street_address1",
- "street_address2",
- "street_address3",
- "street_address4",
- ]
- nullable_fields = [
- "door_code",
- "priority",
- "region_code",
- "street_address3",
- "street_address4",
- ]
- null_default_fields = []
-
+ optional_fields = set(
+ [
+ "company",
+ "country",
+ "country_code",
+ "door_code",
+ "email_address",
+ "first_name",
+ "id",
+ "last_name",
+ "locality",
+ "name",
+ "phone_number",
+ "postal_code",
+ "priority",
+ "region",
+ "region_code",
+ "street_address1",
+ "street_address2",
+ "street_address3",
+ "street_address4",
+ ]
+ )
+ nullable_fields = set(
+ [
+ "door_code",
+ "priority",
+ "region_code",
+ "street_address3",
+ "street_address4",
+ ]
+ )
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/amount_view.py b/src/bolt_api_sdk/models/amount_view.py
index 3f927f63..1648694b 100644
--- a/src/bolt_api_sdk/models/amount_view.py
+++ b/src/bolt_api_sdk/models/amount_view.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -18,3 +19,19 @@ class AmountView(BaseModel):
currency: Optional[str] = None
currency_symbol: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["amount", "currency", "currency_symbol"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/auth_rejection_details.py b/src/bolt_api_sdk/models/auth_rejection_details.py
index 3d28799f..6ca25190 100644
--- a/src/bolt_api_sdk/models/auth_rejection_details.py
+++ b/src/bolt_api_sdk/models/auth_rejection_details.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -15,3 +16,19 @@ class AuthRejectionDetails(BaseModel):
reason_code: Optional[str] = None
reason_description: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["reason_code", "reason_description"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/auth_rejection_details_view.py b/src/bolt_api_sdk/models/auth_rejection_details_view.py
index 67dade2a..97349132 100644
--- a/src/bolt_api_sdk/models/auth_rejection_details_view.py
+++ b/src/bolt_api_sdk/models/auth_rejection_details_view.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -15,3 +16,19 @@ class AuthRejectionDetailsView(BaseModel):
reason_description: str
reason_code: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["reason_code"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/authorizetransactionop.py b/src/bolt_api_sdk/models/authorizetransactionop.py
index 3d9932fc..29e272e9 100644
--- a/src/bolt_api_sdk/models/authorizetransactionop.py
+++ b/src/bolt_api_sdk/models/authorizetransactionop.py
@@ -9,7 +9,7 @@
MerchantCreditCardAuthorizationRecharge,
MerchantCreditCardAuthorizationRechargeTypedDict,
)
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from bolt_api_sdk.utils import (
FieldMetadata,
HeaderMetadata,
@@ -17,6 +17,7 @@
SecurityMetadata,
)
import pydantic
+from pydantic import model_serializer
from typing import Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
@@ -31,7 +32,10 @@ class AuthorizeTransactionSecurity(BaseModel):
str,
FieldMetadata(
security=SecurityMetadata(
- scheme=True, scheme_type="oauth2", field_name="Authorization"
+ scheme=True,
+ scheme_type="oauth2",
+ composite=True,
+ field_name="Authorization",
)
),
]
@@ -43,6 +47,7 @@ class AuthorizeTransactionSecurity(BaseModel):
scheme=True,
scheme_type="apiKey",
sub_type="header",
+ composite=True,
field_name="X-API-Key",
)
),
@@ -115,3 +120,19 @@ class AuthorizeTransactionRequest(BaseModel):
* • **Anytime the shopper is paying while logged-in attach their OAuth `access_token` to the request.**
"""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["X-Publishable-Key", "Idempotency-Key", "RequestBody"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/capture_transaction_with_reference.py b/src/bolt_api_sdk/models/capture_transaction_with_reference.py
index 7c63f435..d966561e 100644
--- a/src/bolt_api_sdk/models/capture_transaction_with_reference.py
+++ b/src/bolt_api_sdk/models/capture_transaction_with_reference.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -38,3 +39,19 @@ class CaptureTransactionWithReference(BaseModel):
skip_hook_notification: Optional[bool] = None
r"""Set to `true` to skip receiving a webhook notification from Bolt that is triggered by this update to the transaction."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["merchant_event_id", "skip_hook_notification"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/capture_view.py b/src/bolt_api_sdk/models/capture_view.py
index 94fcc873..174ba492 100644
--- a/src/bolt_api_sdk/models/capture_view.py
+++ b/src/bolt_api_sdk/models/capture_view.py
@@ -3,8 +3,9 @@
from __future__ import annotations
from .amount_view import AmountView, AmountViewTypedDict
from .capture_status import CaptureStatus
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import Dict, List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -41,6 +42,22 @@ class Split(BaseModel):
"""
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["amount", "type"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
class CaptureViewTypedDict(TypedDict):
r"""Deprecated. Use `captures`."""
@@ -77,3 +94,21 @@ class CaptureView(BaseModel):
status: Optional[CaptureStatus] = None
r"""The status of the capture. **Nullable** for Transactions Details."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ ["amount", "id", "merchant_event_id", "metadata", "splits", "status"]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/capturetransactionop.py b/src/bolt_api_sdk/models/capturetransactionop.py
index 426e2077..1e4ef77a 100644
--- a/src/bolt_api_sdk/models/capturetransactionop.py
+++ b/src/bolt_api_sdk/models/capturetransactionop.py
@@ -5,9 +5,10 @@
CaptureTransactionWithReference,
CaptureTransactionWithReferenceTypedDict,
)
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from bolt_api_sdk.utils import FieldMetadata, HeaderMetadata, RequestMetadata
import pydantic
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -35,6 +36,22 @@ class CaptureTransactionRequest(BaseModel):
] = None
r"""Capture a Transaction"""
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["Idempotency-Key", "capture_transaction_with_reference"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
class ErrorTypedDict(TypedDict):
code: NotRequired[float]
@@ -49,6 +66,22 @@ class Error(BaseModel):
message: Optional[str] = None
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["code", "field", "message"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
class ResultTypedDict(TypedDict):
pass
diff --git a/src/bolt_api_sdk/models/cart_add_on.py b/src/bolt_api_sdk/models/cart_add_on.py
index 954eda36..1e082f05 100644
--- a/src/bolt_api_sdk/models/cart_add_on.py
+++ b/src/bolt_api_sdk/models/cart_add_on.py
@@ -1,8 +1,9 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
import pydantic
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -46,3 +47,25 @@ class CartAddOn(BaseModel):
Optional[str], pydantic.Field(alias="productPageUrl")
] = None
r"""The URL to the product page of the product being displayed as an add on."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["description", "imageUrl", "productPageUrl"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
+
+try:
+ CartAddOn.model_rebuild()
+except NameError:
+ pass
diff --git a/src/bolt_api_sdk/models/cart_create.py b/src/bolt_api_sdk/models/cart_create.py
index dd7dfc79..cbfa0a44 100644
--- a/src/bolt_api_sdk/models/cart_create.py
+++ b/src/bolt_api_sdk/models/cart_create.py
@@ -10,7 +10,8 @@
from .cart_shipment import CartShipment, CartShipmentTypedDict
from .fulfillment import Fulfillment, FulfillmentTypedDict
from .in_store_cart_shipment import InStoreCartShipment, InStoreCartShipmentTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Dict, List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -91,3 +92,36 @@ class CartCreate(BaseModel):
order_description: Optional[str] = None
r"""Used optionally to pass additional information like order numbers or other IDs as needed."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "add_ons",
+ "billing_address",
+ "discounts",
+ "fees",
+ "fulfillments",
+ "in_store_cart_shipments",
+ "items",
+ "loyalty_rewards",
+ "shipments",
+ "tax_amount",
+ "cart_url",
+ "display_id",
+ "metadata",
+ "order_description",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/cart_discount.py b/src/bolt_api_sdk/models/cart_discount.py
index 9afe2d87..4cf46e14 100644
--- a/src/bolt_api_sdk/models/cart_discount.py
+++ b/src/bolt_api_sdk/models/cart_discount.py
@@ -1,8 +1,9 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -17,6 +18,7 @@ class CartDiscountDiscountCategory(str, Enum):
MEMBERSHIP_GIFTCARD = "membership_giftcard"
SUBSCRIPTION_DISCOUNT = "subscription_discount"
REWARDS_DISCOUNT = "rewards_discount"
+ SHIPPING_DISCOUNT = "shipping_discount"
UNKNOWN = "unknown"
@@ -60,3 +62,29 @@ class CartDiscount(BaseModel):
type: Optional[CartDiscountType] = None
r"""The type of discount."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "amount",
+ "code",
+ "description",
+ "details_url",
+ "discount_category",
+ "reference",
+ "type",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/cart_fee.py b/src/bolt_api_sdk/models/cart_fee.py
index 41e382df..0cb1d2f0 100644
--- a/src/bolt_api_sdk/models/cart_fee.py
+++ b/src/bolt_api_sdk/models/cart_fee.py
@@ -42,30 +42,25 @@ class CartFee(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = ["description"]
- nullable_fields = ["name", "description"]
- null_default_fields = []
-
+ optional_fields = set(["description"])
+ nullable_fields = set(["name", "description"])
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/cart_item.py b/src/bolt_api_sdk/models/cart_item.py
index 72cd50da..3259b3ea 100644
--- a/src/bolt_api_sdk/models/cart_item.py
+++ b/src/bolt_api_sdk/models/cart_item.py
@@ -197,86 +197,85 @@ class CartItem(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = [
- "brand",
- "category",
- "collections",
- "color",
- "customizations",
- "description",
- "details_url",
- "external_inputs",
- "gift_option",
- "image_url",
- "isbn",
- "item_group",
- "manufacturer",
- "merchant_product_id",
- "merchant_variant_id",
- "msrp",
- "options",
- "properties",
- "shipment",
- "shipment_type",
- "size",
- "sku",
- "source",
- "seller_id",
- "tags",
- "tax_amount",
- "tax_code",
- "taxable",
- "type",
- "uom",
- "upc",
- "weight",
- "weight_unit",
- ]
- nullable_fields = [
- "brand",
- "category",
- "color",
- "description",
- "isbn",
- "item_group",
- "manufacturer",
- "msrp",
- "options",
- "size",
- "sku",
- "source",
- "seller_id",
- "tags",
- "tax_amount",
- "tax_code",
- "taxable",
- "uom",
- "upc",
- "weight",
- "weight_unit",
- ]
- null_default_fields = []
-
+ optional_fields = set(
+ [
+ "brand",
+ "category",
+ "collections",
+ "color",
+ "customizations",
+ "description",
+ "details_url",
+ "external_inputs",
+ "gift_option",
+ "image_url",
+ "isbn",
+ "item_group",
+ "manufacturer",
+ "merchant_product_id",
+ "merchant_variant_id",
+ "msrp",
+ "options",
+ "properties",
+ "shipment",
+ "shipment_type",
+ "size",
+ "sku",
+ "source",
+ "seller_id",
+ "tags",
+ "tax_amount",
+ "tax_code",
+ "taxable",
+ "type",
+ "uom",
+ "upc",
+ "weight",
+ "weight_unit",
+ ]
+ )
+ nullable_fields = set(
+ [
+ "brand",
+ "category",
+ "color",
+ "description",
+ "isbn",
+ "item_group",
+ "manufacturer",
+ "msrp",
+ "options",
+ "size",
+ "sku",
+ "source",
+ "seller_id",
+ "tags",
+ "tax_amount",
+ "tax_code",
+ "taxable",
+ "uom",
+ "upc",
+ "weight",
+ "weight_unit",
+ ]
+ )
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/cart_item_customization.py b/src/bolt_api_sdk/models/cart_item_customization.py
index 9f442339..081dcb82 100644
--- a/src/bolt_api_sdk/models/cart_item_customization.py
+++ b/src/bolt_api_sdk/models/cart_item_customization.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Dict, Optional
from typing_extensions import NotRequired, TypedDict
@@ -18,3 +19,19 @@ class CartItemCustomization(BaseModel):
name: Optional[str] = None
price: Optional[float] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["attributes", "name", "price"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/cart_item_gift_option.py b/src/bolt_api_sdk/models/cart_item_gift_option.py
index ed2738b7..19492611 100644
--- a/src/bolt_api_sdk/models/cart_item_gift_option.py
+++ b/src/bolt_api_sdk/models/cart_item_gift_option.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -33,3 +34,19 @@ class CartItemGiftOption(BaseModel):
wrap: Optional[bool] = None
r"""Defines whether gift wrapping was requested."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["cost", "merchant_product_id", "message", "wrap"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/cart_item_property.py b/src/bolt_api_sdk/models/cart_item_property.py
index 637ead42..96474444 100644
--- a/src/bolt_api_sdk/models/cart_item_property.py
+++ b/src/bolt_api_sdk/models/cart_item_property.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -27,3 +28,21 @@ class CartItemProperty(BaseModel):
value: Optional[str] = None
value_id: Optional[float] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ ["color", "display", "name", "name_id", "value", "value_id"]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/cart_item_property_view.py b/src/bolt_api_sdk/models/cart_item_property_view.py
index 9250b864..01dceee7 100644
--- a/src/bolt_api_sdk/models/cart_item_property_view.py
+++ b/src/bolt_api_sdk/models/cart_item_property_view.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -21,3 +22,19 @@ class CartItemPropertyView(BaseModel):
name: Optional[str] = None
value: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["color", "display", "name", "value"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/cart_loyalty_rewards.py b/src/bolt_api_sdk/models/cart_loyalty_rewards.py
index 396fbcd8..487418de 100644
--- a/src/bolt_api_sdk/models/cart_loyalty_rewards.py
+++ b/src/bolt_api_sdk/models/cart_loyalty_rewards.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -44,3 +45,29 @@ class CartLoyaltyRewards(BaseModel):
type: Optional[str] = None
r"""The type of loyalty reward."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "amount",
+ "coupon_code",
+ "description",
+ "details",
+ "points",
+ "source",
+ "type",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/cart_loyalty_rewards_view.py b/src/bolt_api_sdk/models/cart_loyalty_rewards_view.py
index 7d921388..8b2c704f 100644
--- a/src/bolt_api_sdk/models/cart_loyalty_rewards_view.py
+++ b/src/bolt_api_sdk/models/cart_loyalty_rewards_view.py
@@ -2,7 +2,8 @@
from __future__ import annotations
from .amount_view import AmountView, AmountViewTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -31,3 +32,29 @@ class CartLoyaltyRewardsView(BaseModel):
source: Optional[str] = None
type: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "amount",
+ "coupon_code",
+ "description",
+ "details",
+ "points",
+ "source",
+ "type",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/cart_shipment.py b/src/bolt_api_sdk/models/cart_shipment.py
index d94ee7b1..031bf538 100644
--- a/src/bolt_api_sdk/models/cart_shipment.py
+++ b/src/bolt_api_sdk/models/cart_shipment.py
@@ -3,7 +3,8 @@
from __future__ import annotations
from .address import Address, AddressTypedDict
from .cart_shipment_type import CartShipmentType
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -120,3 +121,43 @@ class CartShipment(BaseModel):
type: Optional[CartShipmentType] = None
r"""The type corresponding to this shipment, if applicable."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "carrier",
+ "cost",
+ "discounted_by_membership",
+ "estimated_delivery_date",
+ "expedited",
+ "package_depth",
+ "package_dimension_unit",
+ "package_height",
+ "package_type",
+ "package_weight_unit",
+ "package_width",
+ "service",
+ "shipping_address",
+ "shipping_address_id",
+ "shipping_method",
+ "signature",
+ "tax_amount",
+ "tax_code",
+ "total_weight",
+ "total_weight_unit",
+ "type",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/cart_view.py b/src/bolt_api_sdk/models/cart_view.py
index a0b0171a..350b72b5 100644
--- a/src/bolt_api_sdk/models/cart_view.py
+++ b/src/bolt_api_sdk/models/cart_view.py
@@ -13,7 +13,8 @@
from .i_cart_shipment_view import ICartShipmentView, ICartShipmentViewTypedDict
from .i_currency import ICurrency, ICurrencyTypedDict
from .in_store_shipment2 import InStoreShipment2, InStoreShipment2TypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Dict, List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -109,3 +110,46 @@ class CartView(BaseModel):
transaction_reference: Optional[str] = None
r"""The 12 digit reference ID associated to a given transaction webhook for an order."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "billing_address",
+ "cart_url",
+ "currency",
+ "discount_amount",
+ "discounts",
+ "display_id",
+ "fee_amount",
+ "fees",
+ "fulfillments",
+ "in_store_shipments",
+ "items",
+ "loyalty_rewards",
+ "loyalty_rewards_amount",
+ "merchant_order_url",
+ "metadata",
+ "msrp",
+ "order_description",
+ "order_reference",
+ "shipments",
+ "shipping_amount",
+ "subtotal_amount",
+ "tax_amount",
+ "total_amount",
+ "transaction_reference",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/chargeback_details.py b/src/bolt_api_sdk/models/chargeback_details.py
index 3f69997f..f2c27f3a 100644
--- a/src/bolt_api_sdk/models/chargeback_details.py
+++ b/src/bolt_api_sdk/models/chargeback_details.py
@@ -5,7 +5,8 @@
from .chargeback_event_view import ChargebackEventView, ChargebackEventViewTypedDict
from .chargeback_reason_code import ChargebackReasonCode
from .chargeback_representment_result import ChargebackRepresentmentResult
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -53,3 +54,32 @@ class ChargebackDetails(BaseModel):
representment_result: Optional[ChargebackRepresentmentResult] = None
r"""The result of the chargeback representment."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "amt_won",
+ "chargeback_amt",
+ "chargeback_fee",
+ "chargeback_id",
+ "event_views",
+ "net_amt",
+ "reason",
+ "reason_code",
+ "representment_reply_by_date",
+ "representment_result",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/chargeback_details_view.py b/src/bolt_api_sdk/models/chargeback_details_view.py
index 665329b3..d153d282 100644
--- a/src/bolt_api_sdk/models/chargeback_details_view.py
+++ b/src/bolt_api_sdk/models/chargeback_details_view.py
@@ -3,8 +3,9 @@
from __future__ import annotations
from .amount_view import AmountView, AmountViewTypedDict
from .chargeback_event_view import ChargebackEventView, ChargebackEventViewTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -51,3 +52,32 @@ class ChargebackDetailsView(BaseModel):
r"""The reply-by date of the dispute in UnixMillis format."""
representment_result: Optional[RepresentmentResult] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "amt_won",
+ "chargeback_amt",
+ "chargeback_fee",
+ "chargeback_id",
+ "event_views",
+ "net_amt",
+ "reason",
+ "reason_code",
+ "representment_reply_by_date",
+ "representment_result",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/chargeback_event_view.py b/src/bolt_api_sdk/models/chargeback_event_view.py
index 1741e77b..b36bc5ad 100644
--- a/src/bolt_api_sdk/models/chargeback_event_view.py
+++ b/src/bolt_api_sdk/models/chargeback_event_view.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -15,3 +16,19 @@ class ChargebackEventView(BaseModel):
content: Optional[str] = None
time: Optional[float] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["content", "time"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/consumer_billing_address.py b/src/bolt_api_sdk/models/consumer_billing_address.py
index 68b4e918..b7aad48d 100644
--- a/src/bolt_api_sdk/models/consumer_billing_address.py
+++ b/src/bolt_api_sdk/models/consumer_billing_address.py
@@ -99,43 +99,40 @@ class ConsumerBillingAddress(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = [
- "company",
- "country",
- "country_code",
- "email_address",
- "first_name",
- "id",
- "last_name",
- "name",
- "phone_number",
- "street_address2",
- "street_address3",
- "street_address4",
- ]
- nullable_fields = ["id"]
- null_default_fields = []
-
+ optional_fields = set(
+ [
+ "company",
+ "country",
+ "country_code",
+ "email_address",
+ "first_name",
+ "id",
+ "last_name",
+ "name",
+ "phone_number",
+ "street_address2",
+ "street_address3",
+ "street_address4",
+ ]
+ )
+ nullable_fields = set(["id"])
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/consumer_self_view.py b/src/bolt_api_sdk/models/consumer_self_view.py
index 0eb99b78..eb78c911 100644
--- a/src/bolt_api_sdk/models/consumer_self_view.py
+++ b/src/bolt_api_sdk/models/consumer_self_view.py
@@ -4,8 +4,9 @@
from .email_view import EmailView, EmailViewTypedDict
from .login_view import LoginView, LoginViewTypedDict
from .phone_view import PhoneView, PhoneViewTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -43,3 +44,30 @@ class ConsumerSelfView(BaseModel):
phones: Optional[List[PhoneView]] = None
platform_account_status: Optional[PlatformAccountStatus] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "first_name",
+ "id",
+ "last_name",
+ "authentication",
+ "email_verified",
+ "emails",
+ "phones",
+ "platform_account_status",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/consumer_summary_view.py b/src/bolt_api_sdk/models/consumer_summary_view.py
index 5c9832a7..1715ed38 100644
--- a/src/bolt_api_sdk/models/consumer_summary_view.py
+++ b/src/bolt_api_sdk/models/consumer_summary_view.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -22,3 +23,19 @@ class ConsumerSummaryView(BaseModel):
last_name: Optional[str] = None
r"""The surname of the person associated with this record."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["first_name", "id", "last_name"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/create_account_input.py b/src/bolt_api_sdk/models/create_account_input.py
index 689e2a1e..0bc9e2e4 100644
--- a/src/bolt_api_sdk/models/create_account_input.py
+++ b/src/bolt_api_sdk/models/create_account_input.py
@@ -4,7 +4,8 @@
from .address_account import AddressAccount, AddressAccountTypedDict
from .payment_method_account import PaymentMethodAccount, PaymentMethodAccountTypedDict
from .profile import Profile, ProfileTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -31,3 +32,19 @@ class CreateAccountInput(BaseModel):
payment_methods: Optional[List[PaymentMethodAccount]] = None
r"""A list of payment methods associated with this account."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["addresses", "payment_methods"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/createaccountop.py b/src/bolt_api_sdk/models/createaccountop.py
index eb537023..6167c9a6 100644
--- a/src/bolt_api_sdk/models/createaccountop.py
+++ b/src/bolt_api_sdk/models/createaccountop.py
@@ -2,9 +2,10 @@
from __future__ import annotations
from .create_account_input import CreateAccountInput, CreateAccountInputTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from bolt_api_sdk.utils import FieldMetadata, HeaderMetadata, RequestMetadata
import pydantic
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -36,3 +37,21 @@ class CreateAccountRequest(BaseModel):
Optional[CreateAccountInput],
FieldMetadata(request=RequestMetadata(media_type="application/json")),
] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ ["X-Publishable-Key", "Idempotency-Key", "create_account_input"]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/createtestingshopperaccountop.py b/src/bolt_api_sdk/models/createtestingshopperaccountop.py
index b038aead..f0c2331b 100644
--- a/src/bolt_api_sdk/models/createtestingshopperaccountop.py
+++ b/src/bolt_api_sdk/models/createtestingshopperaccountop.py
@@ -5,9 +5,10 @@
TestingAccountRequest,
TestingAccountRequestTypedDict,
)
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from bolt_api_sdk.utils import FieldMetadata, HeaderMetadata, RequestMetadata
import pydantic
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -30,3 +31,19 @@ class CreateTestingShopperAccountRequest(BaseModel):
Optional[TestingAccountRequest],
FieldMetadata(request=RequestMetadata(media_type="application/json")),
] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["X-Publishable-Key", "testing_account_request"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/credit.py b/src/bolt_api_sdk/models/credit.py
index 696e17b1..7e969846 100644
--- a/src/bolt_api_sdk/models/credit.py
+++ b/src/bolt_api_sdk/models/credit.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -12,3 +13,19 @@ class CreditTypedDict(TypedDict):
class Credit(BaseModel):
status: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["status"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/credit_card.py b/src/bolt_api_sdk/models/credit_card.py
index 2f15b0ca..d45c8be7 100644
--- a/src/bolt_api_sdk/models/credit_card.py
+++ b/src/bolt_api_sdk/models/credit_card.py
@@ -2,8 +2,15 @@
from __future__ import annotations
from .address import Address, AddressTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import (
+ BaseModel,
+ Nullable,
+ OptionalNullable,
+ UNSET,
+ UNSET_SENTINEL,
+)
from enum import Enum
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -42,6 +49,8 @@ class CreditCardTypedDict(TypedDict):
r"""Used to indicate the card's priority. '1' indicates primary, while '2' indicates a secondary card."""
save: NotRequired[bool]
r"""Determines whether or not the credit card will be saved to the shopper's account. Defaults to `true`."""
+ affirm_vcn_token: NotRequired[Nullable[str]]
+ r"""The checkout token associated with Affirm VCN credit cards."""
class CreditCard(BaseModel):
@@ -73,3 +82,33 @@ class CreditCard(BaseModel):
save: Optional[bool] = None
r"""Determines whether or not the credit card will be saved to the shopper's account. Defaults to `true`."""
+
+ affirm_vcn_token: OptionalNullable[str] = UNSET
+ r"""The checkout token associated with Affirm VCN credit cards."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ ["billing_address", "priority", "save", "affirm_vcn_token"]
+ )
+ nullable_fields = set(["affirm_vcn_token"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/credit_card_authorization_view.py b/src/bolt_api_sdk/models/credit_card_authorization_view.py
index 236a8c31..67441585 100644
--- a/src/bolt_api_sdk/models/credit_card_authorization_view.py
+++ b/src/bolt_api_sdk/models/credit_card_authorization_view.py
@@ -3,8 +3,9 @@
from __future__ import annotations
from .credit_card_authorization_reason import CreditCardAuthorizationReason
from .credit_card_authorization_status import CreditCardAuthorizationStatus
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import Dict, Optional
from typing_extensions import NotRequired, TypedDict
@@ -154,3 +155,30 @@ class CreditCardAuthorizationView(BaseModel):
* `3` - error
"""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "auth",
+ "avs_response",
+ "cvv_response",
+ "merchant_event_id",
+ "metadata",
+ "processor",
+ "reason",
+ "status",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/credit_card_capture_view.py b/src/bolt_api_sdk/models/credit_card_capture_view.py
index b4804b59..5f84fd54 100644
--- a/src/bolt_api_sdk/models/credit_card_capture_view.py
+++ b/src/bolt_api_sdk/models/credit_card_capture_view.py
@@ -7,7 +7,8 @@
TransactionSplitsView,
TransactionSplitsViewTypedDict,
)
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Dict, Optional
from typing_extensions import NotRequired, TypedDict
@@ -39,3 +40,21 @@ class CreditCardCaptureView(BaseModel):
status: Optional[CaptureStatus] = None
r"""The status of the capture. **Nullable** for Transactions Details."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ ["amount", "id", "merchant_event_id", "metadata", "splits", "status"]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/credit_card_credit_view.py b/src/bolt_api_sdk/models/credit_card_credit_view.py
index d58d3816..34ec5fd0 100644
--- a/src/bolt_api_sdk/models/credit_card_credit_view.py
+++ b/src/bolt_api_sdk/models/credit_card_credit_view.py
@@ -1,8 +1,9 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -30,3 +31,19 @@ class CreditCardCreditView(BaseModel):
merchant_event_id: Optional[str] = None
r"""The reference ID associated with a transaction event (auth, capture, refund, void). This is an arbitrary identifier created by the merchant. Bolt does not enforce any uniqueness constraints on this ID. It is up to the merchant to generate identifiers that properly fulfill its needs."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["status", "merchant_event_id"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/credit_card_user.py b/src/bolt_api_sdk/models/credit_card_user.py
index 17fa5f99..9a718c6f 100644
--- a/src/bolt_api_sdk/models/credit_card_user.py
+++ b/src/bolt_api_sdk/models/credit_card_user.py
@@ -6,7 +6,8 @@
PhonesWithCountryCode,
PhonesWithCountryCodeTypedDict,
)
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -43,3 +44,19 @@ class CreditCardUser(BaseModel):
phones: Optional[List[PhonesWithCountryCode]] = None
r"""A list of phone numbers."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["emails", "first_name", "id", "last_name", "phones"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/credit_card_view.py b/src/bolt_api_sdk/models/credit_card_view.py
index fb867088..370ed27a 100644
--- a/src/bolt_api_sdk/models/credit_card_view.py
+++ b/src/bolt_api_sdk/models/credit_card_view.py
@@ -7,7 +7,8 @@
from .card_status import CardStatus
from .card_token_type import CardTokenType
from .priority import Priority
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -91,3 +92,34 @@ class CreditCardView(BaseModel):
r"""Used to define which payment processor generated the token for this credit card.
"""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "billing_address",
+ "bin",
+ "display_network",
+ "expiration",
+ "icon_asset_path",
+ "id",
+ "last4",
+ "network",
+ "priority",
+ "status",
+ "token",
+ "token_type",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/credit_card_void.py b/src/bolt_api_sdk/models/credit_card_void.py
index 6d6520f4..e66cdd43 100644
--- a/src/bolt_api_sdk/models/credit_card_void.py
+++ b/src/bolt_api_sdk/models/credit_card_void.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -24,3 +25,19 @@ class CreditCardVoid(BaseModel):
skip_hook_notification: Optional[bool] = None
r"""Set to `true` to skip receiving a webhook notification from Bolt that is triggered by this update to the transaction."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["merchant_event_id", "skip_hook_notification"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/credit_card_void_view.py b/src/bolt_api_sdk/models/credit_card_void_view.py
index 09713695..8487f0fa 100644
--- a/src/bolt_api_sdk/models/credit_card_void_view.py
+++ b/src/bolt_api_sdk/models/credit_card_void_view.py
@@ -3,7 +3,8 @@
from __future__ import annotations
from .credit_card_void_cause import CreditCardVoidCause
from .credit_card_void_status import CreditCardVoidStatus
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -31,3 +32,19 @@ class CreditCardVoidView(BaseModel):
void: Optional[str] = None
r"""The void ID returned from the payment processor."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["cause", "merchant_event_id", "status", "void"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/custom_field_full_response_view.py b/src/bolt_api_sdk/models/custom_field_full_response_view.py
index 9058a6f9..f7ac9e2e 100644
--- a/src/bolt_api_sdk/models/custom_field_full_response_view.py
+++ b/src/bolt_api_sdk/models/custom_field_full_response_view.py
@@ -6,7 +6,8 @@
CustomFieldResponseViewTypedDict,
)
from .custom_field_view import CustomFieldView, CustomFieldViewTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -20,3 +21,19 @@ class CustomFieldFullResponseView(BaseModel):
field: Optional[CustomFieldView] = None
response: Optional[CustomFieldResponseView] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["field", "response"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/custom_field_response_view.py b/src/bolt_api_sdk/models/custom_field_response_view.py
index 240bec5d..468ee75a 100644
--- a/src/bolt_api_sdk/models/custom_field_response_view.py
+++ b/src/bolt_api_sdk/models/custom_field_response_view.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional, Union
from typing_extensions import NotRequired, TypeAliasType, TypedDict
@@ -18,3 +19,19 @@ class CustomFieldResponseViewTypedDict(TypedDict):
class CustomFieldResponseView(BaseModel):
response: Optional[Response] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["response"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/custom_field_view.py b/src/bolt_api_sdk/models/custom_field_view.py
index ad0e051b..8b1ea454 100644
--- a/src/bolt_api_sdk/models/custom_field_view.py
+++ b/src/bolt_api_sdk/models/custom_field_view.py
@@ -1,9 +1,10 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
import pydantic
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -55,3 +56,38 @@ class CustomFieldView(BaseModel):
subscribe_to_newsletter: Annotated[
Optional[bool], pydantic.Field(alias="subscribeToNewsletter")
] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "checkout_step",
+ "dynamic",
+ "context",
+ "external_id",
+ "field_setup",
+ "label",
+ "position",
+ "public_id",
+ "required",
+ "subscribeToNewsletter",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
+
+try:
+ CustomFieldView.model_rebuild()
+except NameError:
+ pass
diff --git a/src/bolt_api_sdk/models/custom_fields.py b/src/bolt_api_sdk/models/custom_fields.py
index 7a8c9d27..294ac5c1 100644
--- a/src/bolt_api_sdk/models/custom_fields.py
+++ b/src/bolt_api_sdk/models/custom_fields.py
@@ -1,8 +1,9 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -68,3 +69,32 @@ class CustomFields(BaseModel):
subscribe_to_newsletter: Optional[bool] = None
r"""Defines whether the shopper is opted into a newsletter or not."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "checkout_setup",
+ "dynamic",
+ "context",
+ "external_id",
+ "field_setup",
+ "label",
+ "position",
+ "public_id",
+ "required",
+ "subscribe_to_newsletter",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/customer_list_status.py b/src/bolt_api_sdk/models/customer_list_status.py
index 8c0259e3..0411d9d9 100644
--- a/src/bolt_api_sdk/models/customer_list_status.py
+++ b/src/bolt_api_sdk/models/customer_list_status.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -15,3 +16,19 @@ class CustomerListStatus(BaseModel):
auto_approved: Optional[bool] = None
block_listed: Optional[bool] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["auto_approved", "block_listed"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/deleteaddressop.py b/src/bolt_api_sdk/models/deleteaddressop.py
index d5a1d788..16a7f42c 100644
--- a/src/bolt_api_sdk/models/deleteaddressop.py
+++ b/src/bolt_api_sdk/models/deleteaddressop.py
@@ -1,7 +1,7 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from bolt_api_sdk.utils import (
FieldMetadata,
HeaderMetadata,
@@ -9,6 +9,7 @@
SecurityMetadata,
)
import pydantic
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -23,7 +24,10 @@ class DeleteAddressSecurity(BaseModel):
str,
FieldMetadata(
security=SecurityMetadata(
- scheme=True, scheme_type="oauth2", field_name="Authorization"
+ scheme=True,
+ scheme_type="oauth2",
+ composite=True,
+ field_name="Authorization",
)
),
]
@@ -35,6 +39,7 @@ class DeleteAddressSecurity(BaseModel):
scheme=True,
scheme_type="apiKey",
sub_type="header",
+ composite=True,
field_name="X-API-Key",
)
),
@@ -60,3 +65,19 @@ class DeleteAddressRequest(BaseModel):
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
] = None
r"""The publicly viewable identifier used to identify a merchant division. This key is found in the Developer > API section of the Bolt Merchant Dashboard [RECOMMENDED]."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["X-Publishable-Key"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/deletepaymentmethodop.py b/src/bolt_api_sdk/models/deletepaymentmethodop.py
index feafd7b5..05c75a79 100644
--- a/src/bolt_api_sdk/models/deletepaymentmethodop.py
+++ b/src/bolt_api_sdk/models/deletepaymentmethodop.py
@@ -1,7 +1,7 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from bolt_api_sdk.utils import (
FieldMetadata,
HeaderMetadata,
@@ -9,6 +9,7 @@
SecurityMetadata,
)
import pydantic
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -23,7 +24,10 @@ class DeletePaymentMethodSecurity(BaseModel):
str,
FieldMetadata(
security=SecurityMetadata(
- scheme=True, scheme_type="oauth2", field_name="Authorization"
+ scheme=True,
+ scheme_type="oauth2",
+ composite=True,
+ field_name="Authorization",
)
),
]
@@ -35,6 +39,7 @@ class DeletePaymentMethodSecurity(BaseModel):
scheme=True,
scheme_type="apiKey",
sub_type="header",
+ composite=True,
field_name="X-API-Key",
)
),
@@ -60,3 +65,19 @@ class DeletePaymentMethodRequest(BaseModel):
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
] = None
r"""The publicly viewable identifier used to identify a merchant division. This key is found in the Developer > API section of the Bolt Merchant Dashboard [RECOMMENDED]."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["X-Publishable-Key"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/detectaccountop.py b/src/bolt_api_sdk/models/detectaccountop.py
index 80c48989..fe9986c5 100644
--- a/src/bolt_api_sdk/models/detectaccountop.py
+++ b/src/bolt_api_sdk/models/detectaccountop.py
@@ -1,9 +1,10 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from bolt_api_sdk.utils import FieldMetadata, HeaderMetadata, QueryParamMetadata
import pydantic
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -44,3 +45,19 @@ class DetectAccountRequest(BaseModel):
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
] = None
r"""The shopper's phone number. Includes country code (e.g. +1); does not include dashes or spaces. Can be used to detect an account instead of `sha256_email` or `email`."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["email", "sha256_email", "phone"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/digital_delivery.py b/src/bolt_api_sdk/models/digital_delivery.py
index ca44e08c..c94c15e9 100644
--- a/src/bolt_api_sdk/models/digital_delivery.py
+++ b/src/bolt_api_sdk/models/digital_delivery.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -15,3 +16,19 @@ class DigitalDelivery(BaseModel):
email: Optional[str] = None
phone: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["email", "phone"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/editaddressop.py b/src/bolt_api_sdk/models/editaddressop.py
index 7bc73e97..081e7b77 100644
--- a/src/bolt_api_sdk/models/editaddressop.py
+++ b/src/bolt_api_sdk/models/editaddressop.py
@@ -34,7 +34,10 @@ class EditAddressSecurity(BaseModel):
str,
FieldMetadata(
security=SecurityMetadata(
- scheme=True, scheme_type="oauth2", field_name="Authorization"
+ scheme=True,
+ scheme_type="oauth2",
+ composite=True,
+ field_name="Authorization",
)
),
]
@@ -46,6 +49,7 @@ class EditAddressSecurity(BaseModel):
scheme=True,
scheme_type="apiKey",
sub_type="header",
+ composite=True,
field_name="X-API-Key",
)
),
@@ -78,6 +82,22 @@ class EditAddressRequest(BaseModel):
FieldMetadata(request=RequestMetadata(media_type="application/json")),
] = None
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["X-Publishable-Key", "address_account"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
class EditAddressPriority(str, Enum):
r"""The shopper-indicated priority of this address compared to other addresses on their account."""
@@ -203,59 +223,58 @@ class EditAddressResponse(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = [
- "company",
- "country",
- "country_code",
- "door_code",
- "email_address",
- "first_name",
- "id",
- "last_name",
- "locality",
- "name",
- "phone_number",
- "postal_code",
- "priority",
- "region",
- "region_code",
- "street_address1",
- "street_address2",
- "street_address3",
- "street_address4",
- "metadata",
- "default",
- ]
- nullable_fields = [
- "door_code",
- "priority",
- "region_code",
- "street_address3",
- "street_address4",
- "metadata",
- ]
- null_default_fields = []
-
+ optional_fields = set(
+ [
+ "company",
+ "country",
+ "country_code",
+ "door_code",
+ "email_address",
+ "first_name",
+ "id",
+ "last_name",
+ "locality",
+ "name",
+ "phone_number",
+ "postal_code",
+ "priority",
+ "region",
+ "region_code",
+ "street_address1",
+ "street_address2",
+ "street_address3",
+ "street_address4",
+ "metadata",
+ "default",
+ ]
+ )
+ nullable_fields = set(
+ [
+ "door_code",
+ "priority",
+ "region_code",
+ "street_address3",
+ "street_address4",
+ "metadata",
+ ]
+ )
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/eligible_payment_method.py b/src/bolt_api_sdk/models/eligible_payment_method.py
index 91b89c52..f41c5fdd 100644
--- a/src/bolt_api_sdk/models/eligible_payment_method.py
+++ b/src/bolt_api_sdk/models/eligible_payment_method.py
@@ -2,7 +2,8 @@
from __future__ import annotations
from .payment_service import PaymentService
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -16,3 +17,19 @@ class EligiblePaymentMethod(BaseModel):
eligible: Optional[bool] = None
transaction_processor_type: Optional[PaymentService] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["eligible", "transaction_processor_type"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/email_view.py b/src/bolt_api_sdk/models/email_view.py
index 58888043..8e020b76 100644
--- a/src/bolt_api_sdk/models/email_view.py
+++ b/src/bolt_api_sdk/models/email_view.py
@@ -2,7 +2,8 @@
from __future__ import annotations
from .priority import Priority
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -28,3 +29,19 @@ class EmailView(BaseModel):
"""
status: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["address", "id", "priority", "status"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/emails.py b/src/bolt_api_sdk/models/emails.py
index 75e30b03..a6491768 100644
--- a/src/bolt_api_sdk/models/emails.py
+++ b/src/bolt_api_sdk/models/emails.py
@@ -3,7 +3,8 @@
from __future__ import annotations
from .email_priority import EmailPriority
from .email_status import EmailStatus
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -35,3 +36,19 @@ class Emails(BaseModel):
status: Optional[EmailStatus] = None
r"""This is the status of the contact method."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["address", "id", "priority", "status"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/error_bolt_api.py b/src/bolt_api_sdk/models/error_bolt_api.py
index 04828cd9..6cf361af 100644
--- a/src/bolt_api_sdk/models/error_bolt_api.py
+++ b/src/bolt_api_sdk/models/error_bolt_api.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -23,3 +24,19 @@ class ErrorBoltAPI(BaseModel):
message: Optional[str] = None
r"""Human-readable description of the error for developers. Should not be shown to users and is not localized."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["code", "message"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/event_group_create_webhook.py b/src/bolt_api_sdk/models/event_group_create_webhook.py
index fa3203e0..e7aede52 100644
--- a/src/bolt_api_sdk/models/event_group_create_webhook.py
+++ b/src/bolt_api_sdk/models/event_group_create_webhook.py
@@ -40,30 +40,25 @@ class EventGroupCreateWebhook(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = ["event_group"]
- nullable_fields = ["event_group"]
- null_default_fields = []
-
+ optional_fields = set(["event_group"])
+ nullable_fields = set(["event_group"])
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/events_array_create_webhook.py b/src/bolt_api_sdk/models/events_array_create_webhook.py
index 1191aef7..782ae454 100644
--- a/src/bolt_api_sdk/models/events_array_create_webhook.py
+++ b/src/bolt_api_sdk/models/events_array_create_webhook.py
@@ -2,7 +2,8 @@
from __future__ import annotations
from .webhooks_type import WebhooksType
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -29,3 +30,19 @@ class EventsArrayCreateWebhook(BaseModel):
r"""If `webhook_event_group` is null, pick a list of notification events to subscribe to.
"""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["events"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/fulfillment.py b/src/bolt_api_sdk/models/fulfillment.py
index 8f582bcf..102d8561 100644
--- a/src/bolt_api_sdk/models/fulfillment.py
+++ b/src/bolt_api_sdk/models/fulfillment.py
@@ -5,8 +5,9 @@
from .cart_shipment import CartShipment, CartShipmentTypedDict
from .digital_delivery import DigitalDelivery, DigitalDeliveryTypedDict
from .in_store_cart_shipment import InStoreCartShipment, InStoreCartShipmentTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -43,3 +44,27 @@ class Fulfillment(BaseModel):
in_store_cart_shipment: Optional[InStoreCartShipment] = None
type: Optional[FulfillmentType] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "cart_items",
+ "cart_shipment",
+ "digital_delivery",
+ "in_store_cart_shipment",
+ "type",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/fulfillment_view.py b/src/bolt_api_sdk/models/fulfillment_view.py
index e3d81e1e..6229291c 100644
--- a/src/bolt_api_sdk/models/fulfillment_view.py
+++ b/src/bolt_api_sdk/models/fulfillment_view.py
@@ -4,7 +4,8 @@
from .i_cart_item_view import ICartItemView, ICartItemViewTypedDict
from .i_cart_shipment_view import ICartShipmentView, ICartShipmentViewTypedDict
from .in_store_shipment2 import InStoreShipment2, InStoreShipment2TypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -29,3 +30,27 @@ class FulfillmentView(BaseModel):
r"""A cart that is being prepared for shipment"""
items: Optional[List[ICartItemView]] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "cart_shipment",
+ "fulfillment_type",
+ "id",
+ "in_store_cart_shipment",
+ "items",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/getaccountop.py b/src/bolt_api_sdk/models/getaccountop.py
index 95166990..2ed788d4 100644
--- a/src/bolt_api_sdk/models/getaccountop.py
+++ b/src/bolt_api_sdk/models/getaccountop.py
@@ -1,9 +1,10 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from bolt_api_sdk.utils import FieldMetadata, HeaderMetadata, SecurityMetadata
import pydantic
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -18,7 +19,10 @@ class GetAccountSecurity(BaseModel):
str,
FieldMetadata(
security=SecurityMetadata(
- scheme=True, scheme_type="oauth2", field_name="Authorization"
+ scheme=True,
+ scheme_type="oauth2",
+ composite=True,
+ field_name="Authorization",
)
),
]
@@ -30,6 +34,7 @@ class GetAccountSecurity(BaseModel):
scheme=True,
scheme_type="apiKey",
sub_type="header",
+ composite=True,
field_name="X-API-Key",
)
),
@@ -48,3 +53,19 @@ class GetAccountRequest(BaseModel):
FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
] = None
r"""The publicly viewable identifier used to identify a merchant division. This key is found in the Developer > API section of the Bolt Merchant Dashboard [RECOMMENDED]."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["X-Publishable-Key"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/gettestcreditcardtokenop.py b/src/bolt_api_sdk/models/gettestcreditcardtokenop.py
index 61020f50..4f76f281 100644
--- a/src/bolt_api_sdk/models/gettestcreditcardtokenop.py
+++ b/src/bolt_api_sdk/models/gettestcreditcardtokenop.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -38,3 +39,19 @@ class GetTestCreditCardTokenResponse(BaseModel):
network: Optional[str] = None
r"""The credit card network."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["token", "expiry", "last4", "bin", "network"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/gift_option_view.py b/src/bolt_api_sdk/models/gift_option_view.py
index c48ffd01..18e2d7f6 100644
--- a/src/bolt_api_sdk/models/gift_option_view.py
+++ b/src/bolt_api_sdk/models/gift_option_view.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -19,3 +20,19 @@ class GiftOptionView(BaseModel):
hide_gift_message: Optional[bool] = None
hide_gift_wrap: Optional[bool] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["hide_gift_message", "hide_gift_wrap"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/gift_options.py b/src/bolt_api_sdk/models/gift_options.py
index b0a0d295..320f9e5f 100644
--- a/src/bolt_api_sdk/models/gift_options.py
+++ b/src/bolt_api_sdk/models/gift_options.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -23,3 +24,19 @@ class GiftOptions(BaseModel):
wrap: Optional[bool] = None
r"""Defines whether gift wrapping was requested."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["message", "wrap"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/i_authorize_result_view.py b/src/bolt_api_sdk/models/i_authorize_result_view.py
index 47f3f26c..8dd70ba6 100644
--- a/src/bolt_api_sdk/models/i_authorize_result_view.py
+++ b/src/bolt_api_sdk/models/i_authorize_result_view.py
@@ -2,7 +2,8 @@
from __future__ import annotations
from .transaction_view import TransactionView, TransactionViewTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -19,3 +20,21 @@ class IAuthorizeResultView(BaseModel):
order_number: Optional[str] = None
transaction: Optional[TransactionView] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ ["did_create_bolt_account", "order_number", "transaction"]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/i_cart_discount_view.py b/src/bolt_api_sdk/models/i_cart_discount_view.py
index 77b1f010..56dece8e 100644
--- a/src/bolt_api_sdk/models/i_cart_discount_view.py
+++ b/src/bolt_api_sdk/models/i_cart_discount_view.py
@@ -6,8 +6,9 @@
IFreeShippingDiscountView,
IFreeShippingDiscountViewTypedDict,
)
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -22,6 +23,7 @@ class ICartDiscountViewDiscountCategory(str, Enum):
MEMBERSHIP_GIFTCARD = "membership_giftcard"
SUBSCRIPTION_DISCOUNT = "subscription_discount"
REWARDS_DISCOUNT = "rewards_discount"
+ SHIPPING_DISCOUNT = "shipping_discount"
UNKNOWN = "unknown"
@@ -57,3 +59,29 @@ class ICartDiscountView(BaseModel):
reference: Optional[str] = None
r"""Used to define the reference ID associated with the discount available."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "amount",
+ "code",
+ "description",
+ "details_url",
+ "discount_category",
+ "free_shipping",
+ "reference",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/i_cart_fee_view.py b/src/bolt_api_sdk/models/i_cart_fee_view.py
index 3c4d16ec..0ec85c57 100644
--- a/src/bolt_api_sdk/models/i_cart_fee_view.py
+++ b/src/bolt_api_sdk/models/i_cart_fee_view.py
@@ -44,37 +44,34 @@ class ICartFeeView(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = [
- "reference",
- "name",
- "description",
- "unit_price",
- "unit_tax_amount",
- "quantity",
- ]
- nullable_fields = ["name", "description"]
- null_default_fields = []
-
+ optional_fields = set(
+ [
+ "reference",
+ "name",
+ "description",
+ "unit_price",
+ "unit_tax_amount",
+ "quantity",
+ ]
+ )
+ nullable_fields = set(["name", "description"])
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/i_cart_item_external_inputs.py b/src/bolt_api_sdk/models/i_cart_item_external_inputs.py
index e00a6fde..d3797909 100644
--- a/src/bolt_api_sdk/models/i_cart_item_external_inputs.py
+++ b/src/bolt_api_sdk/models/i_cart_item_external_inputs.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -18,3 +19,25 @@ class ICartItemExternalInputs(BaseModel):
shopify_product_reference: Optional[float] = None
shopify_product_variant_reference: Optional[float] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "shopify_line_item_reference",
+ "shopify_product_reference",
+ "shopify_product_variant_reference",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/i_cart_item_view.py b/src/bolt_api_sdk/models/i_cart_item_view.py
index d9c3ce4e..b72ccdc5 100644
--- a/src/bolt_api_sdk/models/i_cart_item_view.py
+++ b/src/bolt_api_sdk/models/i_cart_item_view.py
@@ -187,70 +187,67 @@ class ICartItemView(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = [
- "bolt_product_id",
- "brand",
- "category",
- "collections",
- "color",
- "customizations",
- "description",
- "details_url",
- "gift_option",
- "hide",
- "image_url",
- "isbn",
- "item_group",
- "manufacturer",
- "merchant_product_id",
- "merchant_variant_id",
- "msrp",
- "name",
- "options",
- "properties",
- "quantity",
- "reference",
- "shipment_id",
- "shipment_type",
- "shopify_line_item_reference",
- "shopify_product_reference",
- "shopify_product_variant_reference",
- "size",
- "sku",
- "subscription",
- "tags",
- "tax_amount",
- "taxable",
- "total_amount",
- "type",
- "unit_price",
- "uom",
- "upc",
- "weight",
- ]
- nullable_fields = ["category", "isbn", "manufacturer", "sku", "uom", "upc"]
- null_default_fields = []
-
+ optional_fields = set(
+ [
+ "bolt_product_id",
+ "brand",
+ "category",
+ "collections",
+ "color",
+ "customizations",
+ "description",
+ "details_url",
+ "gift_option",
+ "hide",
+ "image_url",
+ "isbn",
+ "item_group",
+ "manufacturer",
+ "merchant_product_id",
+ "merchant_variant_id",
+ "msrp",
+ "name",
+ "options",
+ "properties",
+ "quantity",
+ "reference",
+ "shipment_id",
+ "shipment_type",
+ "shopify_line_item_reference",
+ "shopify_product_reference",
+ "shopify_product_variant_reference",
+ "size",
+ "sku",
+ "subscription",
+ "tags",
+ "tax_amount",
+ "taxable",
+ "total_amount",
+ "type",
+ "unit_price",
+ "uom",
+ "upc",
+ "weight",
+ ]
+ )
+ nullable_fields = set(["category", "isbn", "manufacturer", "sku", "uom", "upc"])
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/i_cart_shipment_view.py b/src/bolt_api_sdk/models/i_cart_shipment_view.py
index ad63cb7e..b3f441c4 100644
--- a/src/bolt_api_sdk/models/i_cart_shipment_view.py
+++ b/src/bolt_api_sdk/models/i_cart_shipment_view.py
@@ -7,8 +7,9 @@
from .i_description_part import IDescriptionPart, IDescriptionPartTypedDict
from .i_description_tooltip import IDescriptionTooltip, IDescriptionTooltipTypedDict
from .i_weight import IWeight, IWeightTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from datetime import datetime
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -29,6 +30,22 @@ class ICartShipmentViewPackageDimension(BaseModel):
width: Optional[float] = None
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["depth", "height", "unit", "width"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
class ICartShipmentViewTypedDict(TypedDict):
carrier: NotRequired[str]
@@ -101,3 +118,42 @@ class ICartShipmentView(BaseModel):
total_weight: Optional[IWeight] = None
type: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "carrier",
+ "cost",
+ "default",
+ "description",
+ "description_tooltips",
+ "estimated_delivery_date",
+ "expedited",
+ "gift_options",
+ "id",
+ "package_dimension",
+ "package_type",
+ "package_weight",
+ "reference",
+ "service",
+ "shipping_address",
+ "shipping_method",
+ "signature",
+ "tax_amount",
+ "total_weight",
+ "type",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/i_cart_view.py b/src/bolt_api_sdk/models/i_cart_view.py
index 07beb286..71437fa0 100644
--- a/src/bolt_api_sdk/models/i_cart_view.py
+++ b/src/bolt_api_sdk/models/i_cart_view.py
@@ -8,7 +8,8 @@
from .i_cart_item_view import ICartItemView, ICartItemViewTypedDict
from .i_cart_shipment_view import ICartShipmentView, ICartShipmentViewTypedDict
from .i_currency import ICurrency, ICurrencyTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -84,3 +85,40 @@ class ICartView(BaseModel):
transaction_reference: Optional[str] = None
r"""The 12 digit reference ID associated to a given transaction webhook for an order."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "billing_address",
+ "cart_url",
+ "currency",
+ "discount_amount",
+ "discounts",
+ "display_id",
+ "fee_amount",
+ "fees",
+ "items",
+ "merchant_order_url",
+ "order_description",
+ "order_reference",
+ "shipments",
+ "shipping_amount",
+ "subtotal_amount",
+ "tax_amount",
+ "total_amount",
+ "transaction_reference",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/i_currency.py b/src/bolt_api_sdk/models/i_currency.py
index 0429884a..f0bb6669 100644
--- a/src/bolt_api_sdk/models/i_currency.py
+++ b/src/bolt_api_sdk/models/i_currency.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -15,3 +16,19 @@ class ICurrency(BaseModel):
currency: Optional[str] = None
currency_symbol: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["currency", "currency_symbol"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/i_custom_field_view.py b/src/bolt_api_sdk/models/i_custom_field_view.py
index 3cb65232..0a9e81c1 100644
--- a/src/bolt_api_sdk/models/i_custom_field_view.py
+++ b/src/bolt_api_sdk/models/i_custom_field_view.py
@@ -1,9 +1,10 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
import pydantic
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -58,3 +59,39 @@ class ICustomFieldView(BaseModel):
subscribe_to_newsletter: Annotated[
Optional[bool], pydantic.Field(alias="subscribeToNewsletter")
] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "checkout_step",
+ "dynamic",
+ "context",
+ "external_id",
+ "field_setup",
+ "helper_text",
+ "label",
+ "position",
+ "public_id",
+ "required",
+ "subscribeToNewsletter",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
+
+try:
+ ICustomFieldView.model_rebuild()
+except NameError:
+ pass
diff --git a/src/bolt_api_sdk/models/i_description_part.py b/src/bolt_api_sdk/models/i_description_part.py
index 8bc6d9db..3edffe82 100644
--- a/src/bolt_api_sdk/models/i_description_part.py
+++ b/src/bolt_api_sdk/models/i_description_part.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -15,3 +16,19 @@ class IDescriptionPart(BaseModel):
content: Optional[str] = None
is_html: Optional[bool] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["content", "is_html"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/i_description_tooltip.py b/src/bolt_api_sdk/models/i_description_tooltip.py
index 01705f04..95487e49 100644
--- a/src/bolt_api_sdk/models/i_description_tooltip.py
+++ b/src/bolt_api_sdk/models/i_description_tooltip.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -15,3 +16,19 @@ class IDescriptionTooltip(BaseModel):
html_content: Optional[str] = None
target: Optional[float] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["html_content", "target"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/i_free_shipping_discount_view.py b/src/bolt_api_sdk/models/i_free_shipping_discount_view.py
index 21f0da9d..5bc5252a 100644
--- a/src/bolt_api_sdk/models/i_free_shipping_discount_view.py
+++ b/src/bolt_api_sdk/models/i_free_shipping_discount_view.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -15,3 +16,19 @@ class IFreeShippingDiscountView(BaseModel):
is_free_shipping: Optional[bool] = None
maximum_cost_allowed: Optional[float] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["is_free_shipping", "maximum_cost_allowed"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/i_gift_option_view.py b/src/bolt_api_sdk/models/i_gift_option_view.py
index a0f17a27..b4a24ca6 100644
--- a/src/bolt_api_sdk/models/i_gift_option_view.py
+++ b/src/bolt_api_sdk/models/i_gift_option_view.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -15,3 +16,19 @@ class IGiftOptionView(BaseModel):
hide_gift_message: Optional[bool] = None
hide_gift_wrap: Optional[bool] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["hide_gift_message", "hide_gift_wrap"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/i_order_dynamic_content.py b/src/bolt_api_sdk/models/i_order_dynamic_content.py
index d829853c..71789bcb 100644
--- a/src/bolt_api_sdk/models/i_order_dynamic_content.py
+++ b/src/bolt_api_sdk/models/i_order_dynamic_content.py
@@ -7,8 +7,9 @@
)
from .i_custom_field_view import ICustomFieldView, ICustomFieldViewTypedDict
from .i_gift_option_view import IGiftOptionView, IGiftOptionViewTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -53,3 +54,30 @@ class IOrderDynamicContent(BaseModel):
shipping_info_notice: Optional[str] = None
shipping_notice: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "custom_fields",
+ "eligible_payment_methods",
+ "gift_option_view",
+ "hide_apm",
+ "order_notice",
+ "payment_notice",
+ "shipping_info_notice",
+ "shipping_notice",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/i_order_external_data.py b/src/bolt_api_sdk/models/i_order_external_data.py
index 8fdb2fc4..bd3d7542 100644
--- a/src/bolt_api_sdk/models/i_order_external_data.py
+++ b/src/bolt_api_sdk/models/i_order_external_data.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -12,3 +13,19 @@ class IOrderExternalDataTypedDict(TypedDict):
class IOrderExternalData(BaseModel):
steam_id: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["steam_id"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/i_order_metadata.py b/src/bolt_api_sdk/models/i_order_metadata.py
index e86fa2a4..5116f67e 100644
--- a/src/bolt_api_sdk/models/i_order_metadata.py
+++ b/src/bolt_api_sdk/models/i_order_metadata.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -12,3 +13,19 @@ class IOrderMetadataTypedDict(TypedDict):
class IOrderMetadata(BaseModel):
encrypted_user_id: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["encrypted_user_id"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/i_order_view.py b/src/bolt_api_sdk/models/i_order_view.py
index 5a9bfa74..94442441 100644
--- a/src/bolt_api_sdk/models/i_order_view.py
+++ b/src/bolt_api_sdk/models/i_order_view.py
@@ -4,7 +4,8 @@
from .i_cart_view import ICartView, ICartViewTypedDict
from .i_order_dynamic_content import IOrderDynamicContent, IOrderDynamicContentTypedDict
from .i_order_external_data import IOrderExternalData, IOrderExternalDataTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -31,3 +32,21 @@ class IOrderView(BaseModel):
user_note: Optional[str] = None
r"""Used by shoppers to make extra requests or provide details for gift messages."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ ["cart", "dynamic_content", "external_data", "token", "user_note"]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/i_weight.py b/src/bolt_api_sdk/models/i_weight.py
index e96f213f..cfe2408d 100644
--- a/src/bolt_api_sdk/models/i_weight.py
+++ b/src/bolt_api_sdk/models/i_weight.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -15,3 +16,19 @@ class IWeight(BaseModel):
unit: Optional[str] = None
weight: Optional[float] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["unit", "weight"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/in_store_cart_shipment.py b/src/bolt_api_sdk/models/in_store_cart_shipment.py
index 72f3c53c..e0a397d1 100644
--- a/src/bolt_api_sdk/models/in_store_cart_shipment.py
+++ b/src/bolt_api_sdk/models/in_store_cart_shipment.py
@@ -3,8 +3,9 @@
from __future__ import annotations
from .address import Address, AddressTypedDict
from .cart_shipment import CartShipment, CartShipmentTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -49,3 +50,30 @@ class InStoreCartShipment(BaseModel):
store_name: Optional[str] = None
r"""The local store's name where the item can be picked up."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "cart_shipment",
+ "description",
+ "distance",
+ "distance_unit",
+ "in_store_pickup_address",
+ "pickup_window_close",
+ "pickup_window_open",
+ "store_name",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/in_store_shipment.py b/src/bolt_api_sdk/models/in_store_shipment.py
index e9ec6e2d..705ef307 100644
--- a/src/bolt_api_sdk/models/in_store_shipment.py
+++ b/src/bolt_api_sdk/models/in_store_shipment.py
@@ -10,7 +10,8 @@
from .package_dimension import PackageDimension, PackageDimensionTypedDict
from .package_weights import PackageWeights, PackageWeightsTypedDict
from .total_weight import TotalWeight, TotalWeightTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -99,3 +100,39 @@ class InStoreShipment(BaseModel):
r"""The amount. **Nullable** for Transactions Details."""
total_weight: Optional[TotalWeight] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "carrier",
+ "cost",
+ "default",
+ "estimated_delivery_date",
+ "expedited",
+ "gift_options",
+ "id",
+ "package_dimension",
+ "package_type",
+ "package_weights",
+ "reference",
+ "service",
+ "shipping_address",
+ "shipping_method",
+ "signature",
+ "tax_amount",
+ "total_weight",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/in_store_shipment2.py b/src/bolt_api_sdk/models/in_store_shipment2.py
index a2dd60d7..61023644 100644
--- a/src/bolt_api_sdk/models/in_store_shipment2.py
+++ b/src/bolt_api_sdk/models/in_store_shipment2.py
@@ -3,8 +3,9 @@
from __future__ import annotations
from .address_view import AddressView, AddressViewTypedDict
from .in_store_shipment import InStoreShipment, InStoreShipmentTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -40,3 +41,21 @@ class InStoreShipment2(BaseModel):
r"""A cart that is being prepared for shipment"""
store_name: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ ["address", "distance", "distance_unit", "shipment", "store_name"]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/item.py b/src/bolt_api_sdk/models/item.py
index 6a89827e..6055c691 100644
--- a/src/bolt_api_sdk/models/item.py
+++ b/src/bolt_api_sdk/models/item.py
@@ -7,7 +7,8 @@
from .metadata_component import MetadataComponent, MetadataComponentTypedDict
from .total_weight import TotalWeight, TotalWeightTypedDict
from .type import Type
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -168,3 +169,46 @@ class Item(BaseModel):
upc: Optional[str] = None
weight: Optional[TotalWeight] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "bolt_product_id",
+ "brand",
+ "category",
+ "collections",
+ "color",
+ "customizations",
+ "description",
+ "details_url",
+ "image_url",
+ "isbn",
+ "item_group",
+ "manufacturer",
+ "options",
+ "properties",
+ "shipment_type",
+ "size",
+ "sku",
+ "tags",
+ "tax_amount",
+ "taxable",
+ "type",
+ "uom",
+ "upc",
+ "weight",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/item_property.py b/src/bolt_api_sdk/models/item_property.py
index 82e251ad..53dc346a 100644
--- a/src/bolt_api_sdk/models/item_property.py
+++ b/src/bolt_api_sdk/models/item_property.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -15,3 +16,19 @@ class ItemProperty(BaseModel):
name: Optional[str] = None
value: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["name", "value"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/login_view.py b/src/bolt_api_sdk/models/login_view.py
index d0f9869b..290a6c5e 100644
--- a/src/bolt_api_sdk/models/login_view.py
+++ b/src/bolt_api_sdk/models/login_view.py
@@ -1,8 +1,9 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -31,3 +32,19 @@ class LoginView(BaseModel):
methods: Optional[List[Method]] = None
sso_authorization_url: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["actions", "methods", "sso_authorization_url"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/manual_dispute_view.py b/src/bolt_api_sdk/models/manual_dispute_view.py
index 0b5e490e..acfe881f 100644
--- a/src/bolt_api_sdk/models/manual_dispute_view.py
+++ b/src/bolt_api_sdk/models/manual_dispute_view.py
@@ -1,8 +1,9 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -46,3 +47,32 @@ class ManualDisputeView(BaseModel):
reason: Optional[str] = None
status: Optional[ManualDisputeViewStatus] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "amount",
+ "currency",
+ "delivery_evidence",
+ "delivery_link",
+ "dispute_evidence",
+ "dispute_link",
+ "other_evidence",
+ "other_link",
+ "reason",
+ "status",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/manual_disputes.py b/src/bolt_api_sdk/models/manual_disputes.py
index e338d3ed..0eaacbb6 100644
--- a/src/bolt_api_sdk/models/manual_disputes.py
+++ b/src/bolt_api_sdk/models/manual_disputes.py
@@ -1,8 +1,9 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -50,3 +51,32 @@ class ManualDisputes(BaseModel):
reason: Optional[str] = None
status: Optional[ManualDisputesStatus] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "amount",
+ "currency",
+ "delivery_evidence",
+ "delivery_link",
+ "dispute_evidence",
+ "dispute_link",
+ "other_evidence",
+ "other_link",
+ "reason",
+ "status",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/marketplace_commission_fee.py b/src/bolt_api_sdk/models/marketplace_commission_fee.py
index 8eca18cb..e7e9ff6e 100644
--- a/src/bolt_api_sdk/models/marketplace_commission_fee.py
+++ b/src/bolt_api_sdk/models/marketplace_commission_fee.py
@@ -38,30 +38,25 @@ class MarketplaceCommissionFee(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = ["metadata"]
- nullable_fields = ["metadata"]
- null_default_fields = []
-
+ optional_fields = set(["metadata"])
+ nullable_fields = set(["metadata"])
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/merchant.py b/src/bolt_api_sdk/models/merchant.py
index 1df533ce..97ede3d5 100644
--- a/src/bolt_api_sdk/models/merchant.py
+++ b/src/bolt_api_sdk/models/merchant.py
@@ -8,7 +8,8 @@
TransactionOperationalProcessorTypedDict,
)
from .transaction_processor import TransactionProcessor
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -68,3 +69,19 @@ class Merchant(BaseModel):
* `3` - Offboarding
"""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["onboarding_status", "public_id", "status"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/merchant_callbacks_view.py b/src/bolt_api_sdk/models/merchant_callbacks_view.py
index 6dcb9b1e..e2f3d266 100644
--- a/src/bolt_api_sdk/models/merchant_callbacks_view.py
+++ b/src/bolt_api_sdk/models/merchant_callbacks_view.py
@@ -2,7 +2,8 @@
from __future__ import annotations
from .merchant_callback_url_type import MerchantCallbackURLType
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -21,6 +22,22 @@ class MerchantCallbacksViewCallbackURL(BaseModel):
url: Optional[str] = None
r"""The full callback URL."""
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["type", "url"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
class MerchantCallbacksViewTypedDict(TypedDict):
callback_urls: NotRequired[List[MerchantCallbacksViewCallbackURLTypedDict]]
@@ -30,3 +47,19 @@ class MerchantCallbacksViewTypedDict(TypedDict):
class MerchantCallbacksView(BaseModel):
callback_urls: Optional[List[MerchantCallbacksViewCallbackURL]] = None
r"""List of callback URLs retrieved"""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["callback_urls"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/merchant_credit_card_authorization.py b/src/bolt_api_sdk/models/merchant_credit_card_authorization.py
index 6a204c9e..c5ef3856 100644
--- a/src/bolt_api_sdk/models/merchant_credit_card_authorization.py
+++ b/src/bolt_api_sdk/models/merchant_credit_card_authorization.py
@@ -133,36 +133,33 @@ class MerchantCreditCardAuthorization(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = [
- "auto_capture",
- "merchant_event_id",
- "previous_transaction_id",
- "processing_initiator",
- "shipping_address",
- ]
- nullable_fields = ["previous_transaction_id"]
- null_default_fields = []
-
+ optional_fields = set(
+ [
+ "auto_capture",
+ "merchant_event_id",
+ "previous_transaction_id",
+ "processing_initiator",
+ "shipping_address",
+ ]
+ )
+ nullable_fields = set(["previous_transaction_id"])
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/merchant_credit_card_authorization_recharge.py b/src/bolt_api_sdk/models/merchant_credit_card_authorization_recharge.py
index c8cc4405..a8230bf6 100644
--- a/src/bolt_api_sdk/models/merchant_credit_card_authorization_recharge.py
+++ b/src/bolt_api_sdk/models/merchant_credit_card_authorization_recharge.py
@@ -82,36 +82,33 @@ class MerchantCreditCardAuthorizationRecharge(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = [
- "auto_capture",
- "merchant_event_id",
- "previous_transaction_id",
- "processing_initiator",
- "shipping_address",
- ]
- nullable_fields = ["previous_transaction_id"]
- null_default_fields = []
-
+ optional_fields = set(
+ [
+ "auto_capture",
+ "merchant_event_id",
+ "previous_transaction_id",
+ "processing_initiator",
+ "shipping_address",
+ ]
+ )
+ nullable_fields = set(["previous_transaction_id"])
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/merchant_division.py b/src/bolt_api_sdk/models/merchant_division.py
index 6a5a9830..6d8f09a6 100644
--- a/src/bolt_api_sdk/models/merchant_division.py
+++ b/src/bolt_api_sdk/models/merchant_division.py
@@ -4,7 +4,8 @@
from .merchant_logo import MerchantLogo, MerchantLogoTypedDict
from .merchant_platform import MerchantPlatform
from .webhooks_type import WebhooksType
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -152,3 +153,44 @@ class MerchantDivision(BaseModel):
validate_additional_account_data_url: Optional[str] = None
r"""The endpoint URL provided by the merchant for validating additional account data."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "account_page_url",
+ "api_base_domain_url",
+ "create_order_url",
+ "debug_url",
+ "get_account_url",
+ "shopper_custom_fields_updated_url",
+ "hook_type",
+ "hook_url",
+ "id",
+ "logo",
+ "oauth_logout_url",
+ "oauth_redirect_url",
+ "platform",
+ "plugin_config_url",
+ "privacy_policy_url",
+ "product_info_url",
+ "public_id",
+ "shipping_and_tax_url",
+ "terms_of_service_url",
+ "universal_merchant_api_url",
+ "update_cart_url",
+ "validate_additional_account_data_url",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/merchant_division_logo_view.py b/src/bolt_api_sdk/models/merchant_division_logo_view.py
index c0ed7358..55a42344 100644
--- a/src/bolt_api_sdk/models/merchant_division_logo_view.py
+++ b/src/bolt_api_sdk/models/merchant_division_logo_view.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -15,3 +16,19 @@ class MerchantDivisionLogoView(BaseModel):
domain: Optional[str] = None
resource: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["domain", "resource"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/merchant_division_summary_view.py b/src/bolt_api_sdk/models/merchant_division_summary_view.py
index bfe86ca1..cb2df814 100644
--- a/src/bolt_api_sdk/models/merchant_division_summary_view.py
+++ b/src/bolt_api_sdk/models/merchant_division_summary_view.py
@@ -5,8 +5,9 @@
MerchantDivisionLogoView,
MerchantDivisionLogoViewTypedDict,
)
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -139,3 +140,60 @@ class MerchantDivisionSummaryView(BaseModel):
merchant_password_login_url: Optional[str] = None
r"""(Optional) Link shoppers can use to log into a merchant store via the Bolt SSO modal."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "account_page_url",
+ "api_base_domain_url",
+ "base_domain_url",
+ "confirmation_redirect_url",
+ "create_order_url",
+ "debug_url",
+ "description",
+ "display_name",
+ "get_account_url",
+ "shopper_custom_fields_updated_url",
+ "hook_type",
+ "hook_url",
+ "id",
+ "is_universal_merchant_api",
+ "is_webhooks_v2",
+ "logo",
+ "logo_dashboard",
+ "merchant_id",
+ "mobile_app_domain_url",
+ "oauth_logout_url",
+ "oauth_redirect_url",
+ "platform",
+ "plugin_config_url",
+ "privacy_policy_url",
+ "product_info_url",
+ "public_id",
+ "remote_apiurl",
+ "shipping_and_tax_url",
+ "shipping_url",
+ "status",
+ "tax_url",
+ "terms_of_service_url",
+ "universal_merchant_api_url",
+ "update_cart_url",
+ "use_async_refunds_amazon_pay",
+ "use_async_refunds_paypal",
+ "validate_additional_account_data_url",
+ "merchant_password_login_url",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/merchant_divisions_identifiers_view.py b/src/bolt_api_sdk/models/merchant_divisions_identifiers_view.py
index 9d61d803..515ea28e 100644
--- a/src/bolt_api_sdk/models/merchant_divisions_identifiers_view.py
+++ b/src/bolt_api_sdk/models/merchant_divisions_identifiers_view.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -19,3 +20,19 @@ class MerchantDivisionsIdentifiersView(BaseModel):
publishable_key: Optional[str] = None
r"""The publishable key tied to this division."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["division_id", "publishable_key"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/merchant_identifiers_view.py b/src/bolt_api_sdk/models/merchant_identifiers_view.py
index 25e133b1..ed75cc9b 100644
--- a/src/bolt_api_sdk/models/merchant_identifiers_view.py
+++ b/src/bolt_api_sdk/models/merchant_identifiers_view.py
@@ -5,7 +5,8 @@
MerchantDivisionsIdentifiersView,
MerchantDivisionsIdentifiersViewTypedDict,
)
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -26,3 +27,19 @@ class MerchantIdentifiersView(BaseModel):
signing_secret: Optional[str] = None
r"""Bolt generates one secret key per merchant and uses it to securely sign requests."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["merchant_divisions", "merchant_id", "signing_secret"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/merchant_logo.py b/src/bolt_api_sdk/models/merchant_logo.py
index 5ff1b93f..8677b8c7 100644
--- a/src/bolt_api_sdk/models/merchant_logo.py
+++ b/src/bolt_api_sdk/models/merchant_logo.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -19,3 +20,19 @@ class MerchantLogo(BaseModel):
resource: Optional[str] = None
r"""The logo image file for the merchant division."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["domain", "resource"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/metadata_component.py b/src/bolt_api_sdk/models/metadata_component.py
index 2415b90f..54e03433 100644
--- a/src/bolt_api_sdk/models/metadata_component.py
+++ b/src/bolt_api_sdk/models/metadata_component.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -15,3 +16,19 @@ class MetadataComponent(BaseModel):
key1: Optional[str] = None
key2: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["key1", "key2"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/o_auth_token_input.py b/src/bolt_api_sdk/models/o_auth_token_input.py
index b054ed55..e005927b 100644
--- a/src/bolt_api_sdk/models/o_auth_token_input.py
+++ b/src/bolt_api_sdk/models/o_auth_token_input.py
@@ -1,9 +1,10 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from bolt_api_sdk.utils import FieldMetadata
from enum import Enum
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -67,3 +68,19 @@ class OAuthTokenInput(BaseModel):
state: Annotated[Optional[str], FieldMetadata(form=True)] = None
r"""A randomly generated string issued to the merchant when receiving an authorization code used to prevent CSRF attacks"""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["state"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/o_auth_token_input_refresh.py b/src/bolt_api_sdk/models/o_auth_token_input_refresh.py
index 6b81ad85..116fecb3 100644
--- a/src/bolt_api_sdk/models/o_auth_token_input_refresh.py
+++ b/src/bolt_api_sdk/models/o_auth_token_input_refresh.py
@@ -1,9 +1,10 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from bolt_api_sdk.utils import FieldMetadata
from enum import Enum
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -59,3 +60,19 @@ class OAuthTokenInputRefresh(BaseModel):
state: Annotated[Optional[str], FieldMetadata(form=True)] = None
r"""A randomly generated string issued to the merchant when receiving an authorization code used to prevent CSRF attacks"""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["state"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/o_auth_token_response.py b/src/bolt_api_sdk/models/o_auth_token_response.py
index 5f9ba3a6..55f5ffc0 100644
--- a/src/bolt_api_sdk/models/o_auth_token_response.py
+++ b/src/bolt_api_sdk/models/o_auth_token_response.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -44,3 +45,29 @@ class OAuthTokenResponse(BaseModel):
token_type: Optional[str] = None
r"""The token_type will always be bearer."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "access_token",
+ "expires_in",
+ "id_token",
+ "refresh_token",
+ "refresh_token_scope",
+ "scope",
+ "token_type",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/oauthtokenop.py b/src/bolt_api_sdk/models/oauthtokenop.py
index a5bc8fd6..72d34bae 100644
--- a/src/bolt_api_sdk/models/oauthtokenop.py
+++ b/src/bolt_api_sdk/models/oauthtokenop.py
@@ -6,9 +6,15 @@
OAuthTokenInputRefresh,
OAuthTokenInputRefreshTypedDict,
)
-from bolt_api_sdk.types import BaseModel
-from bolt_api_sdk.utils import FieldMetadata, HeaderMetadata, RequestMetadata
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from bolt_api_sdk.utils import (
+ FieldMetadata,
+ HeaderMetadata,
+ RequestMetadata,
+ get_discriminator,
+)
import pydantic
+from pydantic import Discriminator, Tag, model_serializer
from typing import Optional, Union
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict
@@ -19,9 +25,13 @@
)
-OAuthTokenRequestBody = TypeAliasType(
- "OAuthTokenRequestBody", Union[OAuthTokenInput, OAuthTokenInputRefresh]
-)
+OAuthTokenRequestBody = Annotated[
+ Union[
+ Annotated[OAuthTokenInput, Tag("authorization_code")],
+ Annotated[OAuthTokenInputRefresh, Tag("refresh_token")],
+ ],
+ Discriminator(lambda m: get_discriminator(m, "grant_type", "grant_type")),
+]
class OAuthTokenRequestTypedDict(TypedDict):
@@ -44,3 +54,19 @@ class OAuthTokenRequest(BaseModel):
request=RequestMetadata(media_type="application/x-www-form-urlencoded")
),
] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["X-Publishable-Key", "RequestBody"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/order_create.py b/src/bolt_api_sdk/models/order_create.py
index 736253e0..b91f8bf1 100644
--- a/src/bolt_api_sdk/models/order_create.py
+++ b/src/bolt_api_sdk/models/order_create.py
@@ -102,6 +102,39 @@ class Cart(BaseModel):
order_description: Optional[str] = None
r"""Used optionally to pass additional information like order numbers or other IDs as needed."""
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "add_ons",
+ "billing_address",
+ "discounts",
+ "fees",
+ "fulfillments",
+ "in_store_cart_shipments",
+ "items",
+ "loyalty_rewards",
+ "shipments",
+ "tax_amount",
+ "cart_url",
+ "display_id",
+ "metadata",
+ "order_description",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
class Channel(str, Enum):
r"""Used to determine the channel from which the order was created."""
@@ -142,39 +175,34 @@ class OrderCreate(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = [
- "create_cart_on_merchant_backend",
- "metadata",
- "user_note",
- "seller_splits",
- ]
- nullable_fields = [
- "create_cart_on_merchant_backend",
- "metadata",
- "seller_splits",
- ]
- null_default_fields = []
-
+ optional_fields = set(
+ [
+ "create_cart_on_merchant_backend",
+ "metadata",
+ "user_note",
+ "seller_splits",
+ ]
+ )
+ nullable_fields = set(
+ ["create_cart_on_merchant_backend", "metadata", "seller_splits"]
+ )
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/order_decision.py b/src/bolt_api_sdk/models/order_decision.py
index 39be1bb4..0dec0a25 100644
--- a/src/bolt_api_sdk/models/order_decision.py
+++ b/src/bolt_api_sdk/models/order_decision.py
@@ -2,7 +2,8 @@
from __future__ import annotations
from .risk_decision_factor_yml import RiskDecisionFactorYml
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -24,3 +25,19 @@ class OrderDecision(BaseModel):
score: Optional[int] = None
r"""The total fraud risk score of the order."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["decision_factors", "score"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/order_decision_details_view.py b/src/bolt_api_sdk/models/order_decision_details_view.py
index 5008b500..4fa96f96 100644
--- a/src/bolt_api_sdk/models/order_decision_details_view.py
+++ b/src/bolt_api_sdk/models/order_decision_details_view.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -15,3 +16,19 @@ class OrderDecisionDetailsView(BaseModel):
decision_factors: Optional[List[str]] = None
score: Optional[float] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["decision_factors", "score"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/order_external_data_view.py b/src/bolt_api_sdk/models/order_external_data_view.py
index 2245ee65..f7b29210 100644
--- a/src/bolt_api_sdk/models/order_external_data_view.py
+++ b/src/bolt_api_sdk/models/order_external_data_view.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -12,3 +13,19 @@ class OrderExternalDataViewTypedDict(TypedDict):
class OrderExternalDataView(BaseModel):
shopify: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["shopify"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/order_track_requestbody.py b/src/bolt_api_sdk/models/order_track_requestbody.py
index 503fcd24..e12fc397 100644
--- a/src/bolt_api_sdk/models/order_track_requestbody.py
+++ b/src/bolt_api_sdk/models/order_track_requestbody.py
@@ -2,7 +2,8 @@
from __future__ import annotations
from .item import Item, ItemTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -39,3 +40,19 @@ class OrderTrackRequestBody(BaseModel):
is_non_bolt_order: Optional[bool] = None
r"""Designates if the order was placed outside of Bolt checkout."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["is_non_bolt_order"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/order_view.py b/src/bolt_api_sdk/models/order_view.py
index f13930d5..fb267959 100644
--- a/src/bolt_api_sdk/models/order_view.py
+++ b/src/bolt_api_sdk/models/order_view.py
@@ -7,7 +7,8 @@
OrderExternalDataView,
OrderExternalDataViewTypedDict,
)
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -40,3 +41,29 @@ class OrderView(BaseModel):
user_note: Optional[str] = None
r"""Used by shoppers to make extra requests or provide details for gift messages."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "cart",
+ "dynamic_content",
+ "external_data",
+ "platform_user_id",
+ "requires_action",
+ "token",
+ "user_note",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/package_dimension.py b/src/bolt_api_sdk/models/package_dimension.py
index 15f662a9..d81269b7 100644
--- a/src/bolt_api_sdk/models/package_dimension.py
+++ b/src/bolt_api_sdk/models/package_dimension.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -33,3 +34,19 @@ class PackageDimension(BaseModel):
width: Optional[int] = None
r"""The width."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["depth", "height", "unit", "width"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/package_weights.py b/src/bolt_api_sdk/models/package_weights.py
index 716eee2f..9589cf74 100644
--- a/src/bolt_api_sdk/models/package_weights.py
+++ b/src/bolt_api_sdk/models/package_weights.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -19,3 +20,19 @@ class PackageWeights(BaseModel):
weight: Optional[int] = None
r"""The weight of an item."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["unit", "weight"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/payment_method_account.py b/src/bolt_api_sdk/models/payment_method_account.py
index 406fa745..b8962476 100644
--- a/src/bolt_api_sdk/models/payment_method_account.py
+++ b/src/bolt_api_sdk/models/payment_method_account.py
@@ -150,44 +150,41 @@ class PaymentMethodAccount(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = [
- "billing_address_id",
- "bin",
- "cryptogram",
- "eci",
- "last4",
- "metadata",
- "network",
- "number",
- "postal_code",
- "priority",
- "save",
- "token_type",
- "default",
- ]
- nullable_fields = ["billing_address_id", "metadata"]
- null_default_fields = []
-
+ optional_fields = set(
+ [
+ "billing_address_id",
+ "bin",
+ "cryptogram",
+ "eci",
+ "last4",
+ "metadata",
+ "network",
+ "number",
+ "postal_code",
+ "priority",
+ "save",
+ "token_type",
+ "default",
+ ]
+ )
+ nullable_fields = set(["billing_address_id", "metadata"])
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/phone_view.py b/src/bolt_api_sdk/models/phone_view.py
index 08ffa875..b2e4ee80 100644
--- a/src/bolt_api_sdk/models/phone_view.py
+++ b/src/bolt_api_sdk/models/phone_view.py
@@ -1,8 +1,9 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -32,3 +33,19 @@ class PhoneView(BaseModel):
priority: Optional[PhoneViewPriority] = None
status: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["country_code", "id", "number", "priority", "status"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/phones_with_country_code.py b/src/bolt_api_sdk/models/phones_with_country_code.py
index d102df05..3a1f3da6 100644
--- a/src/bolt_api_sdk/models/phones_with_country_code.py
+++ b/src/bolt_api_sdk/models/phones_with_country_code.py
@@ -3,7 +3,8 @@
from __future__ import annotations
from .phone_priority import PhonePriority
from .phone_status import PhoneStatus
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -40,3 +41,19 @@ class PhonesWithCountryCode(BaseModel):
status: Optional[PhoneStatus] = None
r"""This is the status of the contact method."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["country_code", "id", "number", "priority", "status"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/profile.py b/src/bolt_api_sdk/models/profile.py
index be57f58f..fe2e8a96 100644
--- a/src/bolt_api_sdk/models/profile.py
+++ b/src/bolt_api_sdk/models/profile.py
@@ -53,30 +53,25 @@ class Profile(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = ["metadata", "phone"]
- nullable_fields = ["metadata"]
- null_default_fields = []
-
+ optional_fields = set(["metadata", "phone"])
+ nullable_fields = set(["metadata"])
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/profile_view.py b/src/bolt_api_sdk/models/profile_view.py
index aa772d07..5cc0f42e 100644
--- a/src/bolt_api_sdk/models/profile_view.py
+++ b/src/bolt_api_sdk/models/profile_view.py
@@ -58,37 +58,27 @@ class ProfileView(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = [
- "email",
- "first_name",
- "last_name",
- "metadata",
- "name",
- "phone",
- ]
- nullable_fields = ["metadata"]
- null_default_fields = []
-
+ optional_fields = set(
+ ["email", "first_name", "last_name", "metadata", "name", "phone"]
+ )
+ nullable_fields = set(["metadata"])
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/querywebhooksop.py b/src/bolt_api_sdk/models/querywebhooksop.py
index e65b9ae0..75923928 100644
--- a/src/bolt_api_sdk/models/querywebhooksop.py
+++ b/src/bolt_api_sdk/models/querywebhooksop.py
@@ -2,8 +2,9 @@
from __future__ import annotations
from .webhook import Webhook, WebhookTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from bolt_api_sdk.utils import FieldMetadata, QueryParamMetadata
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -30,3 +31,19 @@ class QueryWebhooksResponse(BaseModel):
r"""Success"""
webhooks: Optional[List[Webhook]] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["webhooks"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/refundtransactionop.py b/src/bolt_api_sdk/models/refundtransactionop.py
index a98e59eb..f13c6015 100644
--- a/src/bolt_api_sdk/models/refundtransactionop.py
+++ b/src/bolt_api_sdk/models/refundtransactionop.py
@@ -2,9 +2,10 @@
from __future__ import annotations
from .transaction_credit import TransactionCredit, TransactionCreditTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from bolt_api_sdk.utils import FieldMetadata, HeaderMetadata, RequestMetadata
import pydantic
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -29,3 +30,19 @@ class RefundTransactionRequest(BaseModel):
FieldMetadata(request=RequestMetadata(media_type="application/json")),
] = None
r"""Refund a Transaction"""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["Idempotency-Key", "transaction_credit"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/replaceaddressop.py b/src/bolt_api_sdk/models/replaceaddressop.py
index 4576f8fe..9581dfc5 100644
--- a/src/bolt_api_sdk/models/replaceaddressop.py
+++ b/src/bolt_api_sdk/models/replaceaddressop.py
@@ -34,7 +34,10 @@ class ReplaceAddressSecurity(BaseModel):
str,
FieldMetadata(
security=SecurityMetadata(
- scheme=True, scheme_type="oauth2", field_name="Authorization"
+ scheme=True,
+ scheme_type="oauth2",
+ composite=True,
+ field_name="Authorization",
)
),
]
@@ -46,6 +49,7 @@ class ReplaceAddressSecurity(BaseModel):
scheme=True,
scheme_type="apiKey",
sub_type="header",
+ composite=True,
field_name="X-API-Key",
)
),
@@ -87,6 +91,24 @@ class ReplaceAddressRequest(BaseModel):
FieldMetadata(request=RequestMetadata(media_type="application/json")),
] = None
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ ["X-Publishable-Key", "Idempotency-Key", "address_account"]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
class ReplaceAddressPriority(str, Enum):
r"""The shopper-indicated priority of this address compared to other addresses on their account."""
@@ -212,59 +234,58 @@ class ReplaceAddressResponse(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = [
- "company",
- "country",
- "country_code",
- "door_code",
- "email_address",
- "first_name",
- "id",
- "last_name",
- "locality",
- "name",
- "phone_number",
- "postal_code",
- "priority",
- "region",
- "region_code",
- "street_address1",
- "street_address2",
- "street_address3",
- "street_address4",
- "metadata",
- "default",
- ]
- nullable_fields = [
- "door_code",
- "priority",
- "region_code",
- "street_address3",
- "street_address4",
- "metadata",
- ]
- null_default_fields = []
-
+ optional_fields = set(
+ [
+ "company",
+ "country",
+ "country_code",
+ "door_code",
+ "email_address",
+ "first_name",
+ "id",
+ "last_name",
+ "locality",
+ "name",
+ "phone_number",
+ "postal_code",
+ "priority",
+ "region",
+ "region_code",
+ "street_address1",
+ "street_address2",
+ "street_address3",
+ "street_address4",
+ "metadata",
+ "default",
+ ]
+ )
+ nullable_fields = set(
+ [
+ "door_code",
+ "priority",
+ "region_code",
+ "street_address3",
+ "street_address4",
+ "metadata",
+ ]
+ )
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/request_result.py b/src/bolt_api_sdk/models/request_result.py
index f439c766..eb94d8d2 100644
--- a/src/bolt_api_sdk/models/request_result.py
+++ b/src/bolt_api_sdk/models/request_result.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -18,3 +19,19 @@ class RequestResult(BaseModel):
success: Optional[bool] = None
r"""Indicates that the request failed. This value is always false."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["success"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/review_ticket.py b/src/bolt_api_sdk/models/review_ticket.py
index 7ab6d10f..6d83bea0 100644
--- a/src/bolt_api_sdk/models/review_ticket.py
+++ b/src/bolt_api_sdk/models/review_ticket.py
@@ -2,7 +2,8 @@
from __future__ import annotations
from .request_status import RequestStatus
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -25,3 +26,19 @@ class ReviewTicket(BaseModel):
request_deadline: Optional[int] = None
status: Optional[RequestStatus] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["id", "request_deadline", "status"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/review_ticket_view.py b/src/bolt_api_sdk/models/review_ticket_view.py
index 22ad6f68..0cc440f5 100644
--- a/src/bolt_api_sdk/models/review_ticket_view.py
+++ b/src/bolt_api_sdk/models/review_ticket_view.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -18,3 +19,19 @@ class ReviewTicketView(BaseModel):
request_deadline: Optional[float] = None
status: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["id", "request_deadline", "status"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/reviewtransactionop.py b/src/bolt_api_sdk/models/reviewtransactionop.py
index c7421b0a..4b61601f 100644
--- a/src/bolt_api_sdk/models/reviewtransactionop.py
+++ b/src/bolt_api_sdk/models/reviewtransactionop.py
@@ -5,9 +5,10 @@
MerchantCreditCardReview,
MerchantCreditCardReviewTypedDict,
)
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from bolt_api_sdk.utils import FieldMetadata, HeaderMetadata, RequestMetadata
import pydantic
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -32,3 +33,19 @@ class ReviewTransactionRequest(BaseModel):
FieldMetadata(request=RequestMetadata(media_type="application/json")),
] = None
r"""Review a Transaction"""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["Idempotency-Key", "merchant_credit_card_review"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/risk_insights_yml.py b/src/bolt_api_sdk/models/risk_insights_yml.py
index 09d440ee..06a49394 100644
--- a/src/bolt_api_sdk/models/risk_insights_yml.py
+++ b/src/bolt_api_sdk/models/risk_insights_yml.py
@@ -2,7 +2,8 @@
from __future__ import annotations
from .risk_decision_factor_yml import RiskDecisionFactorYml
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Dict, List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -36,3 +37,26 @@ class RiskInsightsYml(BaseModel):
"""
payment_instrument_factors: Optional[Dict[str, str]] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "available",
+ "decision_factors",
+ "fraud_probability",
+ "payment_instrument_factors",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/risk_model_external_result_view.py b/src/bolt_api_sdk/models/risk_model_external_result_view.py
index a3fd6904..49c5eb96 100644
--- a/src/bolt_api_sdk/models/risk_model_external_result_view.py
+++ b/src/bolt_api_sdk/models/risk_model_external_result_view.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Dict, List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -23,3 +24,26 @@ class RiskModelExternalResultView(BaseModel):
fraud_probability: Optional[float] = None
payment_instrument_factors: Optional[Dict[str, str]] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "available",
+ "decision_factors",
+ "fraud_probability",
+ "payment_instrument_factors",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/risk_model_resul_contribution_view.py b/src/bolt_api_sdk/models/risk_model_resul_contribution_view.py
index f3a72c55..93f44b8d 100644
--- a/src/bolt_api_sdk/models/risk_model_resul_contribution_view.py
+++ b/src/bolt_api_sdk/models/risk_model_resul_contribution_view.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -15,3 +16,19 @@ class RiskModelResulContributionView(BaseModel):
category: Optional[str] = None
weight: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["category", "weight"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/risk_model_result_view.py b/src/bolt_api_sdk/models/risk_model_result_view.py
index c5dcd0e1..99c1fab3 100644
--- a/src/bolt_api_sdk/models/risk_model_result_view.py
+++ b/src/bolt_api_sdk/models/risk_model_result_view.py
@@ -5,7 +5,8 @@
RiskModelResulContributionView,
RiskModelResulContributionViewTypedDict,
)
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import NotRequired, TypedDict
@@ -16,3 +17,19 @@ class RiskModelResultViewTypedDict(TypedDict):
class RiskModelResultView(BaseModel):
contribution: Optional[List[RiskModelResulContributionView]] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["contribution"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/saved_credit_card_view.py b/src/bolt_api_sdk/models/saved_credit_card_view.py
index 79943453..74567740 100644
--- a/src/bolt_api_sdk/models/saved_credit_card_view.py
+++ b/src/bolt_api_sdk/models/saved_credit_card_view.py
@@ -92,41 +92,38 @@ class SavedCreditCardView(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = [
- "billing_address",
- "id",
- "last4",
- "exp_month",
- "exp_year",
- "network",
- "default",
- "type",
- "description",
- "metadata",
- ]
- nullable_fields = ["metadata"]
- null_default_fields = []
-
+ optional_fields = set(
+ [
+ "billing_address",
+ "id",
+ "last4",
+ "exp_month",
+ "exp_year",
+ "network",
+ "default",
+ "type",
+ "description",
+ "metadata",
+ ]
+ )
+ nullable_fields = set(["metadata"])
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/saved_paypal_account_view.py b/src/bolt_api_sdk/models/saved_paypal_account_view.py
index 69ac86c1..248db8d9 100644
--- a/src/bolt_api_sdk/models/saved_paypal_account_view.py
+++ b/src/bolt_api_sdk/models/saved_paypal_account_view.py
@@ -55,30 +55,25 @@ class SavedPaypalAccountView(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = ["id", "type", "description", "metadata"]
- nullable_fields = ["metadata"]
- null_default_fields = []
-
+ optional_fields = set(["id", "type", "description", "metadata"])
+ nullable_fields = set(["metadata"])
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/security.py b/src/bolt_api_sdk/models/security.py
index 9e469c86..4c845a1a 100644
--- a/src/bolt_api_sdk/models/security.py
+++ b/src/bolt_api_sdk/models/security.py
@@ -1,8 +1,9 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from bolt_api_sdk.utils import FieldMetadata, SecurityMetadata
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -33,3 +34,19 @@ class Security(BaseModel):
)
),
] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["X-API-Key", "OAuth"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/shopper_metadata.py b/src/bolt_api_sdk/models/shopper_metadata.py
index 75ca8c09..96aef853 100644
--- a/src/bolt_api_sdk/models/shopper_metadata.py
+++ b/src/bolt_api_sdk/models/shopper_metadata.py
@@ -1,8 +1,9 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
import pydantic
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -19,3 +20,25 @@ class ShopperMetadata(BaseModel):
additional_properties: Annotated[
Optional[str], pydantic.Field(alias="additionalProperties")
] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["additionalProperties"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
+
+try:
+ ShopperMetadata.model_rebuild()
+except NameError:
+ pass
diff --git a/src/bolt_api_sdk/models/splits_view.py b/src/bolt_api_sdk/models/splits_view.py
index 1b2e78c4..24e6da7a 100644
--- a/src/bolt_api_sdk/models/splits_view.py
+++ b/src/bolt_api_sdk/models/splits_view.py
@@ -2,8 +2,9 @@
from __future__ import annotations
from .amount_view import AmountView, AmountViewTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -38,3 +39,19 @@ class SplitsView(BaseModel):
r"""**Nullable** for Transactions Details.
"""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["amount", "type"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/statements_view_requestbody.py b/src/bolt_api_sdk/models/statements_view_requestbody.py
index 9a773f68..05333890 100644
--- a/src/bolt_api_sdk/models/statements_view_requestbody.py
+++ b/src/bolt_api_sdk/models/statements_view_requestbody.py
@@ -40,3 +40,9 @@ class StatementsViewRequestBody(BaseModel):
* [Dispute statement](https://help.bolt.com/operations/disputes/dispute-statements/#how-to-read-dispute-statements): Use `monthly_dispute`
"""
+
+
+try:
+ StatementsViewRequestBody.model_rebuild()
+except NameError:
+ pass
diff --git a/src/bolt_api_sdk/models/subscription.py b/src/bolt_api_sdk/models/subscription.py
index 8ccd220b..80ebffbe 100644
--- a/src/bolt_api_sdk/models/subscription.py
+++ b/src/bolt_api_sdk/models/subscription.py
@@ -1,8 +1,9 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -34,6 +35,22 @@ class Frequency(BaseModel):
value: Optional[int] = None
r"""The value applied to the unit frequency."""
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["unit", "value"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
class SubscriptionTypedDict(TypedDict):
r"""Describes a product added as a recurring subscription."""
@@ -47,3 +64,19 @@ class Subscription(BaseModel):
frequency: Optional[Frequency] = None
r"""Describes how often the subscription recurs."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["frequency"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/testing_account_details.py b/src/bolt_api_sdk/models/testing_account_details.py
index 1fb4e730..68fd4dfd 100644
--- a/src/bolt_api_sdk/models/testing_account_details.py
+++ b/src/bolt_api_sdk/models/testing_account_details.py
@@ -2,7 +2,8 @@
from __future__ import annotations
from .account_identifier_status import AccountIdentifierStatus
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -54,3 +55,30 @@ class TestingAccountDetails(BaseModel):
oauth_code: Optional[str] = None
r"""OAuth code that is associated with this account and can be used to exchange for an access token"""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "email",
+ "email_state",
+ "phone",
+ "phone_state",
+ "otp_code",
+ "migrated_merchant_owner_id",
+ "will_deactivate_at",
+ "oauth_code",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/testing_account_request.py b/src/bolt_api_sdk/models/testing_account_request.py
index b7ff1e8f..5f4fd1a9 100644
--- a/src/bolt_api_sdk/models/testing_account_request.py
+++ b/src/bolt_api_sdk/models/testing_account_request.py
@@ -2,7 +2,8 @@
from __future__ import annotations
from .account_identifier_status import AccountIdentifierStatus
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -49,3 +50,29 @@ class TestingAccountRequest(BaseModel):
has_address: Optional[bool] = None
r"""Add a random U.S. address to the created account if set to `true`"""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "deactivate_in_days",
+ "email",
+ "email_state",
+ "phone",
+ "phone_state",
+ "migrated",
+ "has_address",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/total_weight.py b/src/bolt_api_sdk/models/total_weight.py
index ac846162..a350cad1 100644
--- a/src/bolt_api_sdk/models/total_weight.py
+++ b/src/bolt_api_sdk/models/total_weight.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -19,3 +20,19 @@ class TotalWeight(BaseModel):
weight: Optional[int] = None
r"""The weight of an item."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["unit", "weight"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/tracking_detail.py b/src/bolt_api_sdk/models/tracking_detail.py
index b1df1c99..a6d40566 100644
--- a/src/bolt_api_sdk/models/tracking_detail.py
+++ b/src/bolt_api_sdk/models/tracking_detail.py
@@ -4,7 +4,8 @@
from bolt_api_sdk.types import BaseModel
from datetime import datetime
from enum import Enum
-from typing_extensions import TypedDict
+import pydantic
+from typing_extensions import Annotated, TypedDict
class TrackingDetailStatus(str, Enum):
@@ -25,7 +26,7 @@ class TrackingDetailStatus(str, Enum):
class TrackingDetailTypedDict(TypedDict):
city: str
country: str
- datetime: datetime
+ datetime_: datetime
message: str
state: str
status: TrackingDetailStatus
@@ -38,7 +39,7 @@ class TrackingDetail(BaseModel):
country: str
- datetime: datetime
+ datetime_: Annotated[datetime, pydantic.Field(alias="datetime")]
message: str
@@ -48,3 +49,9 @@ class TrackingDetail(BaseModel):
r"""The transit status of the order being tracked."""
zip: str
+
+
+try:
+ TrackingDetail.model_rebuild()
+except NameError:
+ pass
diff --git a/src/bolt_api_sdk/models/transaction_credit.py b/src/bolt_api_sdk/models/transaction_credit.py
index e341f7d4..6c95ec2a 100644
--- a/src/bolt_api_sdk/models/transaction_credit.py
+++ b/src/bolt_api_sdk/models/transaction_credit.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -34,3 +35,19 @@ class TransactionCredit(BaseModel):
skip_hook_notification: Optional[bool] = None
r"""Set to `true` to skip receiving a webhook notification from Bolt that is triggered by this update to the transaction."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["merchant_event_id", "skip_hook_notification"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/transaction_details.py b/src/bolt_api_sdk/models/transaction_details.py
index a73e2028..a2941543 100644
--- a/src/bolt_api_sdk/models/transaction_details.py
+++ b/src/bolt_api_sdk/models/transaction_details.py
@@ -47,8 +47,9 @@
)
from .transaction_type import TransactionType
from .transaction_view import TransactionView, TransactionViewTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
import pydantic
+from pydantic import model_serializer
from typing import Dict, List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -291,3 +292,77 @@ class TransactionDetails(BaseModel):
void: Optional[CreditCardVoidView] = None
void_cause: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "address_change_request_metadata",
+ "adjust_transactions",
+ "amount",
+ "auth_verification_status",
+ "authorization",
+ "authorization_id",
+ "capture",
+ "captures",
+ "chargeback_details",
+ "credit",
+ "custom_fields",
+ "customer_list_status",
+ "date",
+ "from_consumer",
+ "from_consumer_membership_users",
+ "from_credit_card",
+ "id",
+ "indemnification_decision",
+ "indemnification_reason",
+ "last_viewed_utc",
+ "last4",
+ "manual_disputes",
+ "merchant",
+ "merchant_division",
+ "merchant_order_number",
+ "order",
+ "order_decision",
+ "platform_metadata",
+ "processor",
+ "reference",
+ "refund_transaction_ids",
+ "refund_transactions",
+ "refunded_amount",
+ "review_ticket",
+ "risk_insights",
+ "risk_review_status",
+ "risk_score",
+ "source_transaction",
+ "splits",
+ "status",
+ "timeline",
+ "to_consumer",
+ "to_credit_card",
+ "transaction_properties",
+ "transaction_rejection_details",
+ "type",
+ "view_status",
+ "void",
+ "void_cause",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
+
+try:
+ TransactionDetails.model_rebuild()
+except NameError:
+ pass
diff --git a/src/bolt_api_sdk/models/transaction_details_view.py b/src/bolt_api_sdk/models/transaction_details_view.py
index 6ea86cfe..7b4045a4 100644
--- a/src/bolt_api_sdk/models/transaction_details_view.py
+++ b/src/bolt_api_sdk/models/transaction_details_view.py
@@ -62,9 +62,10 @@
)
from .transaction_type import TransactionType
from .transaction_view import TransactionView, TransactionViewTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
import pydantic
+from pydantic import model_serializer
from typing import Dict, List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -87,6 +88,22 @@ class TransactionRejectionDetailsTypedDict(TypedDict):
class TransactionRejectionDetails(BaseModel):
auth_rejection_details: Optional[AuthRejectionDetailsView] = None
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["auth_rejection_details"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
class VoidCause(str, Enum):
r"""Determines why the transaction was voided."""
@@ -286,3 +303,74 @@ class TransactionDetailsView(BaseModel):
void_cause: Optional[VoidCause] = None
r"""Determines why the transaction was voided."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "amount",
+ "authorization",
+ "capture",
+ "captures",
+ "credit",
+ "date",
+ "from_consumer",
+ "from_credit_card",
+ "id",
+ "indemnification_decision",
+ "indemnification_reason",
+ "last4",
+ "last_viewed_utc",
+ "merchant_division",
+ "merchant_order_number",
+ "order_decision",
+ "processor",
+ "reference",
+ "review_ticket",
+ "risk_insights",
+ "risk_review_status",
+ "risk_score",
+ "splits",
+ "status",
+ "to_consumer",
+ "to_credit_card",
+ "transaction_properties",
+ "type",
+ "void",
+ "view_status",
+ "address_change_request_metadata",
+ "adjust_transactions",
+ "auth_verification_status",
+ "authorization_id",
+ "chargeback_details",
+ "custom_fields",
+ "customer_list_status",
+ "manual_disputes",
+ "order",
+ "refund_transaction_ids",
+ "refund_transactions",
+ "refunded_amount",
+ "source_transaction",
+ "timeline",
+ "transaction_rejection_details",
+ "void_cause",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
+
+try:
+ TransactionDetailsView.model_rebuild()
+except NameError:
+ pass
diff --git a/src/bolt_api_sdk/models/transaction_rejection_details_view.py b/src/bolt_api_sdk/models/transaction_rejection_details_view.py
index ad89af1c..c46ce21a 100644
--- a/src/bolt_api_sdk/models/transaction_rejection_details_view.py
+++ b/src/bolt_api_sdk/models/transaction_rejection_details_view.py
@@ -2,7 +2,8 @@
from __future__ import annotations
from .auth_rejection_details import AuthRejectionDetails, AuthRejectionDetailsTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -13,3 +14,19 @@ class TransactionRejectionDetailsViewTypedDict(TypedDict):
class TransactionRejectionDetailsView(BaseModel):
auth_rejection_details: Optional[AuthRejectionDetails] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["auth_rejection_details"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/transaction_review_view.py b/src/bolt_api_sdk/models/transaction_review_view.py
index 4b55c4f4..1e9fde43 100644
--- a/src/bolt_api_sdk/models/transaction_review_view.py
+++ b/src/bolt_api_sdk/models/transaction_review_view.py
@@ -2,8 +2,9 @@
from __future__ import annotations
from .risk_model_result_view import RiskModelResultView, RiskModelResultViewTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
import pydantic
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -23,3 +24,25 @@ class TransactionReviewView(BaseModel):
risk_model_result: Optional[RiskModelResultView] = None
source: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["date", "decision", "risk_model_result", "source"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
+
+try:
+ TransactionReviewView.model_rebuild()
+except NameError:
+ pass
diff --git a/src/bolt_api_sdk/models/transaction_splits_view.py b/src/bolt_api_sdk/models/transaction_splits_view.py
index 3ad9c850..f13887fe 100644
--- a/src/bolt_api_sdk/models/transaction_splits_view.py
+++ b/src/bolt_api_sdk/models/transaction_splits_view.py
@@ -2,8 +2,9 @@
from __future__ import annotations
from .amount_view import AmountView, AmountViewTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -26,3 +27,19 @@ class TransactionSplitsView(BaseModel):
amount: Optional[AmountView] = None
type: Optional[TransactionSplitsViewType] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["amount", "type"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/transaction_timeline_view.py b/src/bolt_api_sdk/models/transaction_timeline_view.py
index 379201ad..b59b2e12 100644
--- a/src/bolt_api_sdk/models/transaction_timeline_view.py
+++ b/src/bolt_api_sdk/models/transaction_timeline_view.py
@@ -9,9 +9,10 @@
TransactionReviewViewTypedDict,
)
from .transaction_view import TransactionView, TransactionViewTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
import pydantic
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -57,3 +58,37 @@ class TransactionTimelineView(BaseModel):
type: Optional[TransactionTimelineViewType] = None
visibility: Optional[str] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "address_change",
+ "amount",
+ "consumer",
+ "date",
+ "note",
+ "review",
+ "transaction",
+ "type",
+ "visibility",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
+
+try:
+ TransactionTimelineView.model_rebuild()
+except NameError:
+ pass
diff --git a/src/bolt_api_sdk/models/transaction_update_input.py b/src/bolt_api_sdk/models/transaction_update_input.py
index 2f3be9cb..f790f9d2 100644
--- a/src/bolt_api_sdk/models/transaction_update_input.py
+++ b/src/bolt_api_sdk/models/transaction_update_input.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Dict, Optional
from typing_extensions import NotRequired, TypedDict
@@ -19,3 +20,19 @@ class TransactionUpdateInput(BaseModel):
metadata: Optional[Dict[str, str]] = None
r"""Custom metadata associated with this Bolt transaction."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["display_id", "metadata"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/transaction_view.py b/src/bolt_api_sdk/models/transaction_view.py
index 2ff48189..00804a26 100644
--- a/src/bolt_api_sdk/models/transaction_view.py
+++ b/src/bolt_api_sdk/models/transaction_view.py
@@ -38,9 +38,10 @@
)
from .transaction_status import TransactionStatus
from .transaction_type import TransactionType
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from enum import Enum
import pydantic
+from pydantic import model_serializer
from typing import Dict, List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -178,3 +179,58 @@ class TransactionView(BaseModel):
void: Optional[CreditCardVoidView] = None
view_status: Optional[TransactionViewViewStatus] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(
+ [
+ "amount",
+ "authorization",
+ "capture",
+ "captures",
+ "credit",
+ "date",
+ "from_consumer",
+ "from_credit_card",
+ "id",
+ "indemnification_decision",
+ "indemnification_reason",
+ "last4",
+ "last_viewed_utc",
+ "merchant_division",
+ "merchant_order_number",
+ "order_decision",
+ "processor",
+ "reference",
+ "review_ticket",
+ "risk_insights",
+ "risk_review_status",
+ "risk_score",
+ "splits",
+ "status",
+ "to_consumer",
+ "to_credit_card",
+ "transaction_properties",
+ "type",
+ "void",
+ "view_status",
+ ]
+ )
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
+
+
+try:
+ TransactionView.model_rebuild()
+except NameError:
+ pass
diff --git a/src/bolt_api_sdk/models/update_profile.py b/src/bolt_api_sdk/models/update_profile.py
index 8a9a6c84..ee79ab6e 100644
--- a/src/bolt_api_sdk/models/update_profile.py
+++ b/src/bolt_api_sdk/models/update_profile.py
@@ -43,30 +43,25 @@ class UpdateProfile(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = ["first_name", "last_name", "metadata"]
- nullable_fields = ["metadata"]
- null_default_fields = []
-
+ optional_fields = set(["first_name", "last_name", "metadata"])
+ nullable_fields = set(["metadata"])
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/models/updateaccountprofileop.py b/src/bolt_api_sdk/models/updateaccountprofileop.py
index a9b87626..c707ba04 100644
--- a/src/bolt_api_sdk/models/updateaccountprofileop.py
+++ b/src/bolt_api_sdk/models/updateaccountprofileop.py
@@ -2,7 +2,7 @@
from __future__ import annotations
from .update_profile import UpdateProfile, UpdateProfileTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from bolt_api_sdk.utils import (
FieldMetadata,
HeaderMetadata,
@@ -10,6 +10,7 @@
SecurityMetadata,
)
import pydantic
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -24,7 +25,10 @@ class UpdateAccountProfileSecurity(BaseModel):
str,
FieldMetadata(
security=SecurityMetadata(
- scheme=True, scheme_type="oauth2", field_name="Authorization"
+ scheme=True,
+ scheme_type="oauth2",
+ composite=True,
+ field_name="Authorization",
)
),
]
@@ -36,6 +40,7 @@ class UpdateAccountProfileSecurity(BaseModel):
scheme=True,
scheme_type="apiKey",
sub_type="header",
+ composite=True,
field_name="X-API-Key",
)
),
@@ -60,3 +65,19 @@ class UpdateAccountProfileRequest(BaseModel):
Optional[UpdateProfile],
FieldMetadata(request=RequestMetadata(media_type="application/json")),
] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["X-Publishable-Key", "update_profile"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/updatetransactionop.py b/src/bolt_api_sdk/models/updatetransactionop.py
index 6d968fc0..1acd6ed2 100644
--- a/src/bolt_api_sdk/models/updatetransactionop.py
+++ b/src/bolt_api_sdk/models/updatetransactionop.py
@@ -5,7 +5,7 @@
TransactionUpdateInput,
TransactionUpdateInputTypedDict,
)
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from bolt_api_sdk.utils import (
FieldMetadata,
HeaderMetadata,
@@ -13,6 +13,7 @@
RequestMetadata,
)
import pydantic
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -44,3 +45,19 @@ class UpdateTransactionRequest(BaseModel):
Optional[TransactionUpdateInput],
FieldMetadata(request=RequestMetadata(media_type="application/json")),
] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["Idempotency-Key", "transaction_update_input"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/user_identifier.py b/src/bolt_api_sdk/models/user_identifier.py
index 0e722df0..6f80aa35 100644
--- a/src/bolt_api_sdk/models/user_identifier.py
+++ b/src/bolt_api_sdk/models/user_identifier.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -36,3 +37,19 @@ class UserIdentifier(BaseModel):
phone_id: Optional[str] = None
r"""The ID associated with the identifying phone number for this account."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["artifact", "email", "email_id", "phone_id"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/user_identity.py b/src/bolt_api_sdk/models/user_identity.py
index 33bcf467..76d24158 100644
--- a/src/bolt_api_sdk/models/user_identity.py
+++ b/src/bolt_api_sdk/models/user_identity.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -19,3 +20,19 @@ class UserIdentity(BaseModel):
last_name: Optional[str] = None
r"""The person's last name."""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["first_name", "last_name"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/v1_accounts_view.py b/src/bolt_api_sdk/models/v1_accounts_view.py
index 51ca5cce..19c543e3 100644
--- a/src/bolt_api_sdk/models/v1_accounts_view.py
+++ b/src/bolt_api_sdk/models/v1_accounts_view.py
@@ -1,7 +1,8 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
from __future__ import annotations
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import NotRequired, TypedDict
@@ -12,3 +13,19 @@ class V1AccountsViewTypedDict(TypedDict):
class V1AccountsView(BaseModel):
has_bolt_account: Optional[bool] = None
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["has_bolt_account"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/voidtransactionop.py b/src/bolt_api_sdk/models/voidtransactionop.py
index 386a32d3..123160ea 100644
--- a/src/bolt_api_sdk/models/voidtransactionop.py
+++ b/src/bolt_api_sdk/models/voidtransactionop.py
@@ -2,9 +2,10 @@
from __future__ import annotations
from .credit_card_void import CreditCardVoid, CreditCardVoidTypedDict
-from bolt_api_sdk.types import BaseModel
+from bolt_api_sdk.types import BaseModel, UNSET_SENTINEL
from bolt_api_sdk.utils import FieldMetadata, HeaderMetadata, RequestMetadata
import pydantic
+from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict
@@ -29,3 +30,19 @@ class VoidTransactionRequest(BaseModel):
FieldMetadata(request=RequestMetadata(media_type="application/json")),
] = None
r"""Void a Transaction"""
+
+ @model_serializer(mode="wrap")
+ def serialize_model(self, handler):
+ optional_fields = set(["Idempotency-Key", "credit_card_void"])
+ serialized = handler(self)
+ m = {}
+
+ for n, f in type(self).model_fields.items():
+ k = f.alias or n
+ val = serialized.get(k, serialized.get(n))
+
+ if val != UNSET_SENTINEL:
+ if val is not None or k not in optional_fields:
+ m[k] = val
+
+ return m
diff --git a/src/bolt_api_sdk/models/webhook.py b/src/bolt_api_sdk/models/webhook.py
index 2f2810d7..961390d7 100644
--- a/src/bolt_api_sdk/models/webhook.py
+++ b/src/bolt_api_sdk/models/webhook.py
@@ -56,30 +56,25 @@ class Webhook(BaseModel):
@model_serializer(mode="wrap")
def serialize_model(self, handler):
- optional_fields = ["event_group", "events"]
- nullable_fields = ["event_group", "events"]
- null_default_fields = []
-
+ optional_fields = set(["event_group", "events"])
+ nullable_fields = set(["event_group", "events"])
serialized = handler(self)
-
m = {}
for n, f in type(self).model_fields.items():
k = f.alias or n
- val = serialized.get(k)
- serialized.pop(k, None)
-
- optional_nullable = k in optional_fields and k in nullable_fields
- is_set = (
- self.__pydantic_fields_set__.intersection({n})
- or k in null_default_fields
- ) # pylint: disable=no-member
-
- if val is not None and val != UNSET_SENTINEL:
- m[k] = val
- elif val != UNSET_SENTINEL and (
- not k in optional_fields or (optional_nullable and is_set)
- ):
- m[k] = val
+ val = serialized.get(k, serialized.get(n))
+ is_nullable_and_explicitly_set = (
+ k in nullable_fields
+ and (self.__pydantic_fields_set__.intersection({n})) # pylint: disable=no-member
+ )
+
+ if val != UNSET_SENTINEL:
+ if (
+ val is not None
+ or k not in optional_fields
+ or is_nullable_and_explicitly_set
+ ):
+ m[k] = val
return m
diff --git a/src/bolt_api_sdk/oauth.py b/src/bolt_api_sdk/oauth.py
index 3af90003..4b34b0ef 100644
--- a/src/bolt_api_sdk/oauth.py
+++ b/src/bolt_api_sdk/oauth.py
@@ -71,12 +71,13 @@ def o_auth_token(
http_headers=http_headers,
security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body(
- request.request_body,
+ request.request_body if request is not None else None,
False,
True,
"form",
Optional[models.OAuthTokenRequestBody],
),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -93,13 +94,15 @@ def o_auth_token(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="OAuthToken",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["OAuth"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "403", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -179,12 +182,13 @@ async def o_auth_token_async(
http_headers=http_headers,
security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body(
- request.request_body,
+ request.request_body if request is not None else None,
False,
True,
"form",
Optional[models.OAuthTokenRequestBody],
),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -201,13 +205,15 @@ async def o_auth_token_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="OAuthToken",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["OAuth"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "403", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
diff --git a/src/bolt_api_sdk/orders.py b/src/bolt_api_sdk/orders.py
index f0283ab1..165e3bd7 100644
--- a/src/bolt_api_sdk/orders.py
+++ b/src/bolt_api_sdk/orders.py
@@ -27,6 +27,8 @@ def create_order_token(
Make a request to this endpoint to create a Bolt order, generate a Bolt order token, and initiate the checkout process. A Bolt order token is required for Bolt orders; see Non-Bolt orders for alternative use cases.
+ If set, this operation will use `x_api_key` from the global security.
+
:param request: The request object to send.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -63,6 +65,8 @@ def create_order_token(
get_serialized_body=lambda: utils.serialize_request_body(
request, False, True, "json", Optional[models.OrderCreate]
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -79,13 +83,15 @@ def create_order_token(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="createOrderToken",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Orders"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "403", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -121,6 +127,8 @@ async def create_order_token_async(
Make a request to this endpoint to create a Bolt order, generate a Bolt order token, and initiate the checkout process. A Bolt order token is required for Bolt orders; see Non-Bolt orders for alternative use cases.
+ If set, this operation will use `x_api_key` from the global security.
+
:param request: The request object to send.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -157,6 +165,8 @@ async def create_order_token_async(
get_serialized_body=lambda: utils.serialize_request_body(
request, False, True, "json", Optional[models.OrderCreate]
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -173,13 +183,15 @@ async def create_order_token_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="createOrderToken",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Orders"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "403", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -216,6 +228,8 @@ def track_order(
Send the carrier and order tracking number to Bolt (after a label has been printed). Bolt then uses EasyPost to forward ongoing tracking event updates to the shopper. This request must include **all** items included in the shipment; their references must also match those found in the original cart generation.
+ If set, this operation will use `x_api_key` from the global security.
+
:param request: The request object to send.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -252,6 +266,8 @@ def track_order(
get_serialized_body=lambda: utils.serialize_request_body(
request, False, True, "json", Optional[models.OrderTrackRequestBody]
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -268,13 +284,15 @@ def track_order(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="trackOrder",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Orders"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -311,6 +329,8 @@ async def track_order_async(
Send the carrier and order tracking number to Bolt (after a label has been printed). Bolt then uses EasyPost to forward ongoing tracking event updates to the shopper. This request must include **all** items included in the shipment; their references must also match those found in the original cart generation.
+ If set, this operation will use `x_api_key` from the global security.
+
:param request: The request object to send.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -347,6 +367,8 @@ async def track_order_async(
get_serialized_body=lambda: utils.serialize_request_body(
request, False, True, "json", Optional[models.OrderTrackRequestBody]
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -363,13 +385,15 @@ async def track_order_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="trackOrder",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Orders"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
diff --git a/src/bolt_api_sdk/sdk.py b/src/bolt_api_sdk/sdk.py
index 3402349c..9998e652 100644
--- a/src/bolt_api_sdk/sdk.py
+++ b/src/bolt_api_sdk/sdk.py
@@ -86,8 +86,8 @@ def __init__(
Union[models.Security, Callable[[], models.Security]]
] = None,
server_idx: Optional[int] = None,
- server_url: Optional[str] = None,
url_params: Optional[Dict[str, str]] = None,
+ server_url: Optional[str] = None,
client: Optional[HttpClient] = None,
async_client: Optional[AsyncHttpClient] = None,
retry_config: OptionalNullable[RetryConfig] = UNSET,
diff --git a/src/bolt_api_sdk/statements.py b/src/bolt_api_sdk/statements.py
index 92eb57c1..5833b6fa 100644
--- a/src/bolt_api_sdk/statements.py
+++ b/src/bolt_api_sdk/statements.py
@@ -30,6 +30,8 @@ def get_statements(
Get a pre-signed URL for the requested statement file.
+ If set, this operation will use `x_api_key` from the global security.
+
:param request: The request object to send.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -68,6 +70,8 @@ def get_statements(
get_serialized_body=lambda: utils.serialize_request_body(
request, False, True, "json", Optional[models.StatementsViewRequestBody]
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -84,13 +88,15 @@ def get_statements(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="getStatements",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Statements"],
+ extensions=None,
),
request=req,
- error_status_codes=["403", "404", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -129,6 +135,8 @@ async def get_statements_async(
Get a pre-signed URL for the requested statement file.
+ If set, this operation will use `x_api_key` from the global security.
+
:param request: The request object to send.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -167,6 +175,8 @@ async def get_statements_async(
get_serialized_body=lambda: utils.serialize_request_body(
request, False, True, "json", Optional[models.StatementsViewRequestBody]
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -183,13 +193,15 @@ async def get_statements_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="getStatements",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Statements"],
+ extensions=None,
),
request=req,
- error_status_codes=["403", "404", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
diff --git a/src/bolt_api_sdk/testing.py b/src/bolt_api_sdk/testing.py
index f9fc62f4..e88ff250 100644
--- a/src/bolt_api_sdk/testing.py
+++ b/src/bolt_api_sdk/testing.py
@@ -27,6 +27,8 @@ def test_shipping(
This endpoint simulates tracking an order's shipment and is for testing purposes only.
+ If set, this operation will use `x_api_key` from the global security.
+
:param request: The request object to send.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -63,6 +65,8 @@ def test_shipping(
get_serialized_body=lambda: utils.serialize_request_body(
request, False, True, "json", Optional[models.MockTrackingInput]
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -79,13 +83,15 @@ def test_shipping(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="testShipping",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Testing"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -121,6 +127,8 @@ async def test_shipping_async(
This endpoint simulates tracking an order's shipment and is for testing purposes only.
+ If set, this operation will use `x_api_key` from the global security.
+
:param request: The request object to send.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -157,6 +165,8 @@ async def test_shipping_async(
get_serialized_body=lambda: utils.serialize_request_body(
request, False, True, "json", Optional[models.MockTrackingInput]
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -173,13 +183,15 @@ async def test_shipping_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="testShipping",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Testing"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -216,6 +228,8 @@ def create_testing_shopper_account(
Create a Bolt shopper account for testing purposes. Available for sandbox use only and the created account will be recycled after a certain time.
+ If set, this operation will use `x_api_key` from the global security.
+
:param x_publishable_key: The publicly viewable identifier used to identify a merchant division. This key is found in the Developer > API section of the Bolt Merchant Dashboard [RECOMMENDED].
:param testing_account_request:
:param retries: Override the default retry configuration for this method
@@ -254,12 +268,14 @@ def create_testing_shopper_account(
http_headers=http_headers,
security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body(
- request.testing_account_request,
+ request.testing_account_request if request is not None else None,
False,
True,
"json",
Optional[models.TestingAccountRequest],
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -276,13 +292,15 @@ def create_testing_shopper_account(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="createTestingShopperAccount",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Testing"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -313,6 +331,8 @@ async def create_testing_shopper_account_async(
Create a Bolt shopper account for testing purposes. Available for sandbox use only and the created account will be recycled after a certain time.
+ If set, this operation will use `x_api_key` from the global security.
+
:param x_publishable_key: The publicly viewable identifier used to identify a merchant division. This key is found in the Developer > API section of the Bolt Merchant Dashboard [RECOMMENDED].
:param testing_account_request:
:param retries: Override the default retry configuration for this method
@@ -351,12 +371,14 @@ async def create_testing_shopper_account_async(
http_headers=http_headers,
security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body(
- request.testing_account_request,
+ request.testing_account_request if request is not None else None,
False,
True,
"json",
Optional[models.TestingAccountRequest],
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -373,13 +395,15 @@ async def create_testing_shopper_account_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="createTestingShopperAccount",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Testing"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -406,6 +430,8 @@ def get_test_credit_card_token(
This endpoint fetches a new credit card token for Bolt's universal test credit card number `4111 1111 1111 1004`. This is for testing and is available only in sandbox.
+ If set, this operation will use `x_api_key` from the global security.
+
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -433,6 +459,8 @@ def get_test_credit_card_token(
accept_header_value="application/json",
http_headers=http_headers,
security=self.sdk_configuration.security,
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -449,13 +477,15 @@ def get_test_credit_card_token(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="getTestCreditCardToken",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Testing"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -484,6 +514,8 @@ async def get_test_credit_card_token_async(
This endpoint fetches a new credit card token for Bolt's universal test credit card number `4111 1111 1111 1004`. This is for testing and is available only in sandbox.
+ If set, this operation will use `x_api_key` from the global security.
+
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -511,6 +543,8 @@ async def get_test_credit_card_token_async(
accept_header_value="application/json",
http_headers=http_headers,
security=self.sdk_configuration.security,
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -527,13 +561,15 @@ async def get_test_credit_card_token_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="getTestCreditCardToken",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Testing"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
diff --git a/src/bolt_api_sdk/transactions.py b/src/bolt_api_sdk/transactions.py
index 150f7388..0fe7daff 100644
--- a/src/bolt_api_sdk/transactions.py
+++ b/src/bolt_api_sdk/transactions.py
@@ -43,7 +43,11 @@ def authorize_transaction(
:param security:
:param x_publishable_key: The publicly viewable identifier used to identify a merchant division. This key is found in the Developer > API section of the Bolt Merchant Dashboard [RECOMMENDED].
:param idempotency_key: A key created by merchants that ensures `POST` and `PATCH` requests are only performed once. [Read more about Idempotent Requests here](/developers/references/idempotency/).
- :param request_body: **Authorize a Transaction** * • `merchant_credit_card_authorization`: For authorizing with a new, unsaved card. This can be for a guest checkout flow, one-time payment, or an existing Bolt shopper. * • `merchant_credit_card_authorization_recharge`: For authorizing a card using a shoppers saved payment methods. * • **Anytime the shopper is paying while logged-in attach their OAuth `access_token` to the request.**
+ :param request_body: **Authorize a Transaction**
+ * • `merchant_credit_card_authorization`: For authorizing with a new, unsaved card. This can be for a guest checkout flow, one-time payment, or an existing Bolt shopper.
+ * • `merchant_credit_card_authorization_recharge`: For authorizing a card using a shoppers saved payment methods.
+ * • **Anytime the shopper is paying while logged-in attach their OAuth `access_token` to the request.**
+
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -83,12 +87,13 @@ def authorize_transaction(
security, models.AuthorizeTransactionSecurity
),
get_serialized_body=lambda: utils.serialize_request_body(
- request.request_body,
+ request.request_body if request is not None else None,
False,
True,
"json",
Optional[models.AuthorizeTransactionRequestBody],
),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -107,9 +112,11 @@ def authorize_transaction(
operation_id="authorizeTransaction",
oauth2_scopes=None,
security_source=get_security_from_env(security, models.Security),
+ tags=["Transactions"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -155,7 +162,11 @@ async def authorize_transaction_async(
:param security:
:param x_publishable_key: The publicly viewable identifier used to identify a merchant division. This key is found in the Developer > API section of the Bolt Merchant Dashboard [RECOMMENDED].
:param idempotency_key: A key created by merchants that ensures `POST` and `PATCH` requests are only performed once. [Read more about Idempotent Requests here](/developers/references/idempotency/).
- :param request_body: **Authorize a Transaction** * • `merchant_credit_card_authorization`: For authorizing with a new, unsaved card. This can be for a guest checkout flow, one-time payment, or an existing Bolt shopper. * • `merchant_credit_card_authorization_recharge`: For authorizing a card using a shoppers saved payment methods. * • **Anytime the shopper is paying while logged-in attach their OAuth `access_token` to the request.**
+ :param request_body: **Authorize a Transaction**
+ * • `merchant_credit_card_authorization`: For authorizing with a new, unsaved card. This can be for a guest checkout flow, one-time payment, or an existing Bolt shopper.
+ * • `merchant_credit_card_authorization_recharge`: For authorizing a card using a shoppers saved payment methods.
+ * • **Anytime the shopper is paying while logged-in attach their OAuth `access_token` to the request.**
+
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
@@ -195,12 +206,13 @@ async def authorize_transaction_async(
security, models.AuthorizeTransactionSecurity
),
get_serialized_body=lambda: utils.serialize_request_body(
- request.request_body,
+ request.request_body if request is not None else None,
False,
True,
"json",
Optional[models.AuthorizeTransactionRequestBody],
),
+ allow_empty_value=None,
timeout_ms=timeout_ms,
)
@@ -219,9 +231,11 @@ async def authorize_transaction_async(
operation_id="authorizeTransaction",
oauth2_scopes=None,
security_source=get_security_from_env(security, models.Security),
+ tags=["Transactions"],
+ extensions=None,
),
request=req,
- error_status_codes=["4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -258,6 +272,8 @@ def capture_transaction(
Although the response returns the standard `transaction_view` object, only `captures` and either `id` or `reference` are needed.
+ If set, this operation will use `x_api_key` from the global security.
+
:param idempotency_key: A key created by merchants that ensures `POST` and `PATCH` requests are only performed once. [Read more about Idempotent Requests here](/developers/references/idempotency/).
:param capture_transaction_with_reference: Capture a Transaction
:param retries: Override the default retry configuration for this method
@@ -297,12 +313,16 @@ def capture_transaction(
http_headers=http_headers,
security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body(
- request.capture_transaction_with_reference,
+ request.capture_transaction_with_reference
+ if request is not None
+ else None,
False,
True,
"json",
Optional[models.CaptureTransactionWithReference],
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -319,13 +339,15 @@ def capture_transaction(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="captureTransaction",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Transactions"],
+ extensions=None,
),
request=req,
- error_status_codes=["403", "404", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -373,6 +395,8 @@ async def capture_transaction_async(
Although the response returns the standard `transaction_view` object, only `captures` and either `id` or `reference` are needed.
+ If set, this operation will use `x_api_key` from the global security.
+
:param idempotency_key: A key created by merchants that ensures `POST` and `PATCH` requests are only performed once. [Read more about Idempotent Requests here](/developers/references/idempotency/).
:param capture_transaction_with_reference: Capture a Transaction
:param retries: Override the default retry configuration for this method
@@ -412,12 +436,16 @@ async def capture_transaction_async(
http_headers=http_headers,
security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body(
- request.capture_transaction_with_reference,
+ request.capture_transaction_with_reference
+ if request is not None
+ else None,
False,
True,
"json",
Optional[models.CaptureTransactionWithReference],
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -434,13 +462,15 @@ async def capture_transaction_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="captureTransaction",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Transactions"],
+ extensions=None,
),
request=req,
- error_status_codes=["403", "404", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -482,6 +512,8 @@ def refund_transaction(
This refunds a captured transaction. Refunds can be done for any partial amount or for the total authorized amount. These refunds are processed synchronously and return information about the refunded transaction in the standard `transaction_view` object.
+ If set, this operation will use `x_api_key` from the global security.
+
:param idempotency_key: A key created by merchants that ensures `POST` and `PATCH` requests are only performed once. [Read more about Idempotent Requests here](/developers/references/idempotency/).
:param transaction_credit: Refund a Transaction
:param retries: Override the default retry configuration for this method
@@ -520,12 +552,14 @@ def refund_transaction(
http_headers=http_headers,
security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body(
- request.transaction_credit,
+ request.transaction_credit if request is not None else None,
False,
True,
"json",
Optional[models.TransactionCredit],
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -542,13 +576,15 @@ def refund_transaction(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="refundTransaction",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Transactions"],
+ extensions=None,
),
request=req,
- error_status_codes=["422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -585,6 +621,8 @@ async def refund_transaction_async(
This refunds a captured transaction. Refunds can be done for any partial amount or for the total authorized amount. These refunds are processed synchronously and return information about the refunded transaction in the standard `transaction_view` object.
+ If set, this operation will use `x_api_key` from the global security.
+
:param idempotency_key: A key created by merchants that ensures `POST` and `PATCH` requests are only performed once. [Read more about Idempotent Requests here](/developers/references/idempotency/).
:param transaction_credit: Refund a Transaction
:param retries: Override the default retry configuration for this method
@@ -623,12 +661,14 @@ async def refund_transaction_async(
http_headers=http_headers,
security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body(
- request.transaction_credit,
+ request.transaction_credit if request is not None else None,
False,
True,
"json",
Optional[models.TransactionCredit],
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -645,13 +685,15 @@ async def refund_transaction_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="refundTransaction",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Transactions"],
+ extensions=None,
),
request=req,
- error_status_codes=["422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -691,6 +733,8 @@ def review_transaction(
This endpoint is used to manually approve or reject orders for a specified transaction.
+ If set, this operation will use `x_api_key` from the global security.
+
:param idempotency_key: A key created by merchants that ensures `POST` and `PATCH` requests are only performed once. [Read more about Idempotent Requests here](/developers/references/idempotency/).
:param merchant_credit_card_review: Review a Transaction
:param retries: Override the default retry configuration for this method
@@ -729,12 +773,14 @@ def review_transaction(
http_headers=http_headers,
security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body(
- request.merchant_credit_card_review,
+ request.merchant_credit_card_review if request is not None else None,
False,
True,
"json",
Optional[models.MerchantCreditCardReview],
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -751,13 +797,15 @@ def review_transaction(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="reviewTransaction",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Transactions"],
+ extensions=None,
),
request=req,
- error_status_codes=["403", "404", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -797,6 +845,8 @@ async def review_transaction_async(
This endpoint is used to manually approve or reject orders for a specified transaction.
+ If set, this operation will use `x_api_key` from the global security.
+
:param idempotency_key: A key created by merchants that ensures `POST` and `PATCH` requests are only performed once. [Read more about Idempotent Requests here](/developers/references/idempotency/).
:param merchant_credit_card_review: Review a Transaction
:param retries: Override the default retry configuration for this method
@@ -835,12 +885,14 @@ async def review_transaction_async(
http_headers=http_headers,
security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body(
- request.merchant_credit_card_review,
+ request.merchant_credit_card_review if request is not None else None,
False,
True,
"json",
Optional[models.MerchantCreditCardReview],
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -857,13 +909,15 @@ async def review_transaction_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="reviewTransaction",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Transactions"],
+ extensions=None,
),
request=req,
- error_status_codes=["403", "404", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -903,6 +957,8 @@ def void_transaction(
Although the response returns the standard `transaction_view` object, only `status` and either `id` or `reference` are needed.
+ If set, this operation will use `x_api_key` from the global security.
+
:param idempotency_key: A key created by merchants that ensures `POST` and `PATCH` requests are only performed once. [Read more about Idempotent Requests here](/developers/references/idempotency/).
:param credit_card_void: Void a Transaction
:param retries: Override the default retry configuration for this method
@@ -941,12 +997,14 @@ def void_transaction(
http_headers=http_headers,
security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body(
- request.credit_card_void,
+ request.credit_card_void if request is not None else None,
False,
True,
"json",
Optional[models.CreditCardVoid],
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -963,13 +1021,15 @@ def void_transaction(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="voidTransaction",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Transactions"],
+ extensions=None,
),
request=req,
- error_status_codes=["403", "404", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -1009,6 +1069,8 @@ async def void_transaction_async(
Although the response returns the standard `transaction_view` object, only `status` and either `id` or `reference` are needed.
+ If set, this operation will use `x_api_key` from the global security.
+
:param idempotency_key: A key created by merchants that ensures `POST` and `PATCH` requests are only performed once. [Read more about Idempotent Requests here](/developers/references/idempotency/).
:param credit_card_void: Void a Transaction
:param retries: Override the default retry configuration for this method
@@ -1047,12 +1109,14 @@ async def void_transaction_async(
http_headers=http_headers,
security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body(
- request.credit_card_void,
+ request.credit_card_void if request is not None else None,
False,
True,
"json",
Optional[models.CreditCardVoid],
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -1069,13 +1133,15 @@ async def void_transaction_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="voidTransaction",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Transactions"],
+ extensions=None,
),
request=req,
- error_status_codes=["403", "404", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -1112,6 +1178,8 @@ def get_transaction_details(
**Note**: All objects and fields marked `required` in the Transaction Details response are also **nullable**. This includes any sub-components (objects or fields) also marked `required`.
+ If set, this operation will use `x_api_key` from the global security.
+
:param reference: This is the Bolt transaction reference. (ex. N7Y3-NFKC-VFRF)
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -1145,6 +1213,8 @@ def get_transaction_details(
accept_header_value="application/json",
http_headers=http_headers,
security=self.sdk_configuration.security,
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -1161,13 +1231,15 @@ def get_transaction_details(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="getTransactionDetails",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Transactions"],
+ extensions=None,
),
request=req,
- error_status_codes=["403", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -1204,6 +1276,8 @@ async def get_transaction_details_async(
**Note**: All objects and fields marked `required` in the Transaction Details response are also **nullable**. This includes any sub-components (objects or fields) also marked `required`.
+ If set, this operation will use `x_api_key` from the global security.
+
:param reference: This is the Bolt transaction reference. (ex. N7Y3-NFKC-VFRF)
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -1237,6 +1311,8 @@ async def get_transaction_details_async(
accept_header_value="application/json",
http_headers=http_headers,
security=self.sdk_configuration.security,
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -1253,13 +1329,15 @@ async def get_transaction_details_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="getTransactionDetails",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Transactions"],
+ extensions=None,
),
request=req,
- error_status_codes=["403", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -1286,7 +1364,7 @@ def update_transaction(
reference: str,
idempotency_key: Optional[str] = None,
display_id: Optional[str] = None,
- metadata: Optional[Dict[str, str]] = None,
+ metadata: Optional[Mapping[str, str]] = None,
retries: OptionalNullable[utils.RetryConfig] = UNSET,
server_url: Optional[str] = None,
timeout_ms: Optional[int] = None,
@@ -1296,6 +1374,8 @@ def update_transaction(
This allows you to update certain transaction properties post-authorization.
+ If set, this operation will use `x_api_key` from the global security.
+
:param reference: This is the Bolt transaction reference. (ex. N7Y3-NFKC-VFRF)
:param idempotency_key: A key created by merchants that ensures `POST` and `PATCH` requests are only performed once. [Read more about Idempotent Requests here](/developers/references/idempotency/).
:param display_id: This field corresponds to the merchant's order reference associated with this Bolt transaction.
@@ -1320,7 +1400,7 @@ def update_transaction(
idempotency_key=idempotency_key,
transaction_update_input=models.TransactionUpdateInput(
display_id=display_id,
- metadata=metadata,
+ metadata=utils.unmarshal(metadata, Optional[Dict[str, str]]),
),
)
@@ -1338,12 +1418,14 @@ def update_transaction(
http_headers=http_headers,
security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body(
- request.transaction_update_input,
+ request.transaction_update_input if request is not None else None,
False,
True,
"json",
Optional[models.TransactionUpdateInput],
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -1360,13 +1442,15 @@ def update_transaction(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="updateTransaction",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Transactions"],
+ extensions=None,
),
request=req,
- error_status_codes=["403", "404", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -1393,7 +1477,7 @@ async def update_transaction_async(
reference: str,
idempotency_key: Optional[str] = None,
display_id: Optional[str] = None,
- metadata: Optional[Dict[str, str]] = None,
+ metadata: Optional[Mapping[str, str]] = None,
retries: OptionalNullable[utils.RetryConfig] = UNSET,
server_url: Optional[str] = None,
timeout_ms: Optional[int] = None,
@@ -1403,6 +1487,8 @@ async def update_transaction_async(
This allows you to update certain transaction properties post-authorization.
+ If set, this operation will use `x_api_key` from the global security.
+
:param reference: This is the Bolt transaction reference. (ex. N7Y3-NFKC-VFRF)
:param idempotency_key: A key created by merchants that ensures `POST` and `PATCH` requests are only performed once. [Read more about Idempotent Requests here](/developers/references/idempotency/).
:param display_id: This field corresponds to the merchant's order reference associated with this Bolt transaction.
@@ -1427,7 +1513,7 @@ async def update_transaction_async(
idempotency_key=idempotency_key,
transaction_update_input=models.TransactionUpdateInput(
display_id=display_id,
- metadata=metadata,
+ metadata=utils.unmarshal(metadata, Optional[Dict[str, str]]),
),
)
@@ -1445,12 +1531,14 @@ async def update_transaction_async(
http_headers=http_headers,
security=self.sdk_configuration.security,
get_serialized_body=lambda: utils.serialize_request_body(
- request.transaction_update_input,
+ request.transaction_update_input if request is not None else None,
False,
True,
"json",
Optional[models.TransactionUpdateInput],
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -1467,13 +1555,15 @@ async def update_transaction_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="updateTransaction",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Transactions"],
+ extensions=None,
),
request=req,
- error_status_codes=["403", "404", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
diff --git a/src/bolt_api_sdk/types/__init__.py b/src/bolt_api_sdk/types/__init__.py
index fc76fe0c..faa26813 100644
--- a/src/bolt_api_sdk/types/__init__.py
+++ b/src/bolt_api_sdk/types/__init__.py
@@ -1,5 +1,6 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
+from .base64fileinput import Base64EncodedString, Base64FileInput
from .basemodel import (
BaseModel,
Nullable,
@@ -11,6 +12,8 @@
)
__all__ = [
+ "Base64EncodedString",
+ "Base64FileInput",
"BaseModel",
"Nullable",
"OptionalNullable",
diff --git a/src/bolt_api_sdk/types/base64fileinput.py b/src/bolt_api_sdk/types/base64fileinput.py
new file mode 100644
index 00000000..862566fe
--- /dev/null
+++ b/src/bolt_api_sdk/types/base64fileinput.py
@@ -0,0 +1,43 @@
+"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
+
+from __future__ import annotations
+
+import base64
+import io
+from os import PathLike
+from typing import IO, Any, Union
+
+from pydantic.functional_validators import BeforeValidator
+from typing_extensions import Annotated
+
+
+Base64FileInput = Union[IO[bytes], PathLike[str]]
+
+
+def encode_base64_file_input(value: Any) -> Any:
+ """Convert PathLike or IO[bytes] inputs to a base64 string. All standard binary streams
+ that inherit from io.IOBase are handled. Other values pass through.
+ """
+ if isinstance(value, (PathLike, io.IOBase)):
+ if isinstance(value, PathLike):
+ with open(value, "rb") as fh:
+ binary = fh.read()
+ else:
+ # Restore position after reading: pydantic may validate the same stream more than once.
+ position = value.tell() if value.seekable() else None
+ binary = value.read()
+ if position is not None:
+ value.seek(position)
+ if isinstance(binary, str):
+ binary = binary.encode()
+ if not isinstance(binary, (bytes, bytearray)):
+ raise TypeError(
+ f"Base64FileInput expected binary IO returning bytes; got {type(binary).__name__}"
+ )
+ return base64.b64encode(binary).decode("ascii")
+ return value
+
+
+# Non-str inputs are converted to base64 by the BeforeValidator at construction time.
+# Callers can also pass a pre-encoded base64 str.
+Base64EncodedString = Annotated[str, BeforeValidator(encode_base64_file_input)]
diff --git a/src/bolt_api_sdk/types/basemodel.py b/src/bolt_api_sdk/types/basemodel.py
index 231c2e37..a9a640a1 100644
--- a/src/bolt_api_sdk/types/basemodel.py
+++ b/src/bolt_api_sdk/types/basemodel.py
@@ -2,7 +2,8 @@
from pydantic import ConfigDict, model_serializer
from pydantic import BaseModel as PydanticBaseModel
-from typing import TYPE_CHECKING, Literal, Optional, TypeVar, Union
+from pydantic_core import core_schema
+from typing import TYPE_CHECKING, Any, Literal, Optional, TypeVar, Union
from typing_extensions import TypeAliasType, TypeAlias
@@ -35,5 +36,42 @@ def __bool__(self) -> Literal[False]:
"OptionalNullable", Union[Optional[Nullable[T]], Unset], type_params=(T,)
)
-UnrecognizedInt: TypeAlias = int
-UnrecognizedStr: TypeAlias = str
+
+class UnrecognizedStr(str):
+ @classmethod
+ def __get_pydantic_core_schema__(cls, _source_type: Any, _handler: Any) -> core_schema.CoreSchema:
+ # Make UnrecognizedStr only work in lax mode, not strict mode
+ # This makes it a "fallback" option when more specific types (like Literals) don't match
+ def validate_lax(v: Any) -> 'UnrecognizedStr':
+ if isinstance(v, cls):
+ return v
+ return cls(str(v))
+
+ # Use lax_or_strict_schema where strict always fails
+ # This forces Pydantic to prefer other union members in strict mode
+ # and only fall back to UnrecognizedStr in lax mode
+ return core_schema.lax_or_strict_schema(
+ lax_schema=core_schema.chain_schema([
+ core_schema.str_schema(),
+ core_schema.no_info_plain_validator_function(validate_lax)
+ ]),
+ strict_schema=core_schema.none_schema(), # Always fails in strict mode
+ )
+
+
+class UnrecognizedInt(int):
+ @classmethod
+ def __get_pydantic_core_schema__(cls, _source_type: Any, _handler: Any) -> core_schema.CoreSchema:
+ # Make UnrecognizedInt only work in lax mode, not strict mode
+ # This makes it a "fallback" option when more specific types (like Literals) don't match
+ def validate_lax(v: Any) -> 'UnrecognizedInt':
+ if isinstance(v, cls):
+ return v
+ return cls(int(v))
+ return core_schema.lax_or_strict_schema(
+ lax_schema=core_schema.chain_schema([
+ core_schema.int_schema(),
+ core_schema.no_info_plain_validator_function(validate_lax)
+ ]),
+ strict_schema=core_schema.none_schema(), # Always fails in strict mode
+ )
diff --git a/src/bolt_api_sdk/utils/__init__.py b/src/bolt_api_sdk/utils/__init__.py
index 87192dde..c48a36ca 100644
--- a/src/bolt_api_sdk/utils/__init__.py
+++ b/src/bolt_api_sdk/utils/__init__.py
@@ -1,13 +1,21 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
-from typing import TYPE_CHECKING
-from importlib import import_module
-import builtins
-import sys
+from typing import Any, TYPE_CHECKING, Callable, TypeVar
+import asyncio
+
+from .dynamic_imports import lazy_getattr, lazy_dir
+
+_T = TypeVar("_T")
+
+
+async def run_sync_in_thread(func: Callable[..., _T], *args) -> _T:
+ """Run a synchronous function in a thread pool to avoid blocking the event loop."""
+ return await asyncio.to_thread(func, *args)
+
if TYPE_CHECKING:
from .annotations import get_discriminator
- from .datetimes import parse_datetime
+ from .datetimes import parse_datetime, parse_duration
from .enums import OpenEnumMeta
from .headers import get_headers, get_response_headers
from .metadata import (
@@ -42,7 +50,6 @@
validate_decimal,
validate_float,
validate_int,
- validate_open_enum,
)
from .url import generate_url, template_url, remove_suffix
from .values import (
@@ -64,6 +71,7 @@
"get_default_logger",
"get_discriminator",
"parse_datetime",
+ "parse_duration",
"get_global_from_env",
"get_headers",
"get_pydantic_model",
@@ -104,7 +112,6 @@
"validate_const",
"validate_float",
"validate_int",
- "validate_open_enum",
"cast_partial",
]
@@ -118,6 +125,7 @@
"get_default_logger": ".logger",
"get_discriminator": ".annotations",
"parse_datetime": ".datetimes",
+ "parse_duration": ".datetimes",
"get_global_from_env": ".values",
"get_headers": ".headers",
"get_pydantic_model": ".serializers",
@@ -158,43 +166,15 @@
"validate_const": ".serializers",
"validate_float": ".serializers",
"validate_int": ".serializers",
- "validate_open_enum": ".serializers",
"cast_partial": ".values",
}
-def dynamic_import(modname, retries=3):
- for attempt in range(retries):
- try:
- return import_module(modname, __package__)
- except KeyError:
- # Clear any half-initialized module and retry
- sys.modules.pop(modname, None)
- if attempt == retries - 1:
- break
- raise KeyError(f"Failed to import module '{modname}' after {retries} attempts")
-
-
-def __getattr__(attr_name: str) -> object:
- module_name = _dynamic_imports.get(attr_name)
- if module_name is None:
- raise AttributeError(
- f"no {attr_name} found in _dynamic_imports, module name -> {__name__} "
- )
-
- try:
- module = dynamic_import(module_name)
- return getattr(module, attr_name)
- except ImportError as e:
- raise ImportError(
- f"Failed to import {attr_name} from {module_name}: {e}"
- ) from e
- except AttributeError as e:
- raise AttributeError(
- f"Failed to get {attr_name} from {module_name}: {e}"
- ) from e
+def __getattr__(attr_name: str) -> Any:
+ return lazy_getattr(
+ attr_name, package=__package__, dynamic_imports=_dynamic_imports
+ )
def __dir__():
- lazy_attrs = builtins.list(_dynamic_imports.keys())
- return builtins.sorted(lazy_attrs)
+ return lazy_dir(dynamic_imports=_dynamic_imports)
diff --git a/src/bolt_api_sdk/utils/datetimes.py b/src/bolt_api_sdk/utils/datetimes.py
index a6c52cd6..adad2476 100644
--- a/src/bolt_api_sdk/utils/datetimes.py
+++ b/src/bolt_api_sdk/utils/datetimes.py
@@ -1,8 +1,10 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
-from datetime import datetime
+from datetime import datetime, timedelta
import sys
+from pydantic import TypeAdapter
+
def parse_datetime(datetime_string: str) -> datetime:
"""
@@ -21,3 +23,15 @@ def parse_datetime(datetime_string: str) -> datetime:
datetime_string = datetime_string[:-1] + "+00:00"
return datetime.fromisoformat(datetime_string)
+
+
+_DURATION_ADAPTER = TypeAdapter(timedelta)
+
+
+def parse_duration(duration_string: str) -> timedelta:
+ """
+ Convert an ISO 8601 duration string (e.g. "PT1H30M") into a timedelta.
+ The standard library has no ISO 8601 duration parser, so this delegates to
+ pydantic, which is already a runtime dependency of the SDK.
+ """
+ return _DURATION_ADAPTER.validate_python(duration_string)
diff --git a/src/bolt_api_sdk/utils/dynamic_imports.py b/src/bolt_api_sdk/utils/dynamic_imports.py
new file mode 100644
index 00000000..673edf82
--- /dev/null
+++ b/src/bolt_api_sdk/utils/dynamic_imports.py
@@ -0,0 +1,54 @@
+"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
+
+from importlib import import_module
+import builtins
+import sys
+
+
+def dynamic_import(package, modname, retries=3):
+ """Import a module relative to package, retrying on KeyError from half-initialized modules."""
+ for attempt in range(retries):
+ try:
+ return import_module(modname, package)
+ except KeyError:
+ sys.modules.pop(modname, None)
+ if attempt == retries - 1:
+ break
+ raise KeyError(f"Failed to import module '{modname}' after {retries} attempts")
+
+
+def lazy_getattr(attr_name, *, package, dynamic_imports, sub_packages=None):
+ """Module-level __getattr__ that lazily loads from a dynamic_imports mapping.
+
+ Args:
+ attr_name: The attribute being looked up.
+ package: The caller's __package__ (for relative imports).
+ dynamic_imports: Dict mapping attribute names to relative module paths.
+ sub_packages: Optional list of subpackage names to lazy-load.
+ """
+ module_name = dynamic_imports.get(attr_name)
+ if module_name is not None:
+ try:
+ module = dynamic_import(package, module_name)
+ return getattr(module, attr_name)
+ except ImportError as e:
+ raise ImportError(
+ f"Failed to import {attr_name} from {module_name}: {e}"
+ ) from e
+ except AttributeError as e:
+ raise AttributeError(
+ f"Failed to get {attr_name} from {module_name}: {e}"
+ ) from e
+
+ if sub_packages and attr_name in sub_packages:
+ return import_module(f".{attr_name}", package)
+
+ raise AttributeError(f"module '{package}' has no attribute '{attr_name}'")
+
+
+def lazy_dir(*, dynamic_imports, sub_packages=None):
+ """Module-level __dir__ that lists lazily-loadable attributes."""
+ lazy_attrs = builtins.list(dynamic_imports.keys())
+ if sub_packages:
+ lazy_attrs.extend(sub_packages)
+ return builtins.sorted(lazy_attrs)
diff --git a/src/bolt_api_sdk/utils/enums.py b/src/bolt_api_sdk/utils/enums.py
index c3bc13cf..3324e1bc 100644
--- a/src/bolt_api_sdk/utils/enums.py
+++ b/src/bolt_api_sdk/utils/enums.py
@@ -2,6 +2,10 @@
import enum
import sys
+from typing import Any
+
+from pydantic_core import core_schema
+
class OpenEnumMeta(enum.EnumMeta):
# The __call__ method `boundary` kwarg was added in 3.11 and must be present
@@ -72,3 +76,59 @@ def __call__(
)
except ValueError:
return value
+
+ def __new__(mcs, name, bases, namespace, **kwargs):
+ cls = super().__new__(mcs, name, bases, namespace, **kwargs)
+
+ # Add __get_pydantic_core_schema__ to make open enums work correctly
+ # in union discrimination. In strict mode (used by Pydantic for unions),
+ # only known enum values match. In lax mode, unknown values are accepted.
+ def __get_pydantic_core_schema__(
+ cls_inner: Any, _source_type: Any, _handler: Any
+ ) -> core_schema.CoreSchema:
+ # Create a validator that only accepts known enum values (for strict mode)
+ def validate_strict(v: Any) -> Any:
+ if isinstance(v, cls_inner):
+ return v
+ # Use the parent EnumMeta's __call__ which raises ValueError for unknown values
+ return enum.EnumMeta.__call__(cls_inner, v)
+
+ # Create a lax validator that accepts unknown values
+ def validate_lax(v: Any) -> Any:
+ if isinstance(v, cls_inner):
+ return v
+ try:
+ return enum.EnumMeta.__call__(cls_inner, v)
+ except ValueError:
+ # Return the raw value for unknown enum values
+ return v
+
+ # Determine the base type schema (str or int)
+ is_int_enum = False
+ for base in cls_inner.__mro__:
+ if base is int:
+ is_int_enum = True
+ break
+ if base is str:
+ break
+
+ base_schema = (
+ core_schema.int_schema()
+ if is_int_enum
+ else core_schema.str_schema()
+ )
+
+ # Use lax_or_strict_schema:
+ # - strict mode: only known enum values match (raises ValueError for unknown)
+ # - lax mode: accept any value, return enum member or raw value
+ return core_schema.lax_or_strict_schema(
+ lax_schema=core_schema.chain_schema(
+ [base_schema, core_schema.no_info_plain_validator_function(validate_lax)]
+ ),
+ strict_schema=core_schema.chain_schema(
+ [base_schema, core_schema.no_info_plain_validator_function(validate_strict)]
+ ),
+ )
+
+ setattr(cls, "__get_pydantic_core_schema__", classmethod(__get_pydantic_core_schema__))
+ return cls
diff --git a/src/bolt_api_sdk/utils/eventstreaming.py b/src/bolt_api_sdk/utils/eventstreaming.py
index 0969899b..a8d4fe5c 100644
--- a/src/bolt_api_sdk/utils/eventstreaming.py
+++ b/src/bolt_api_sdk/utils/eventstreaming.py
@@ -2,9 +2,12 @@
import re
import json
+from dataclasses import dataclass, asdict
from typing import (
+ Any,
Callable,
Generic,
+ List,
TypeVar,
Optional,
Generator,
@@ -22,6 +25,7 @@ class EventStream(Generic[T]):
client_ref: Optional[object]
response: httpx.Response
generator: Generator[T, None, None]
+ _closed: bool
def __init__(
self,
@@ -29,21 +33,31 @@ def __init__(
decoder: Callable[[str], T],
sentinel: Optional[str] = None,
client_ref: Optional[object] = None,
+ data_required: bool = True,
):
self.response = response
- self.generator = stream_events(response, decoder, sentinel)
+ self.generator = stream_events(
+ response, decoder, sentinel, data_required=data_required
+ )
self.client_ref = client_ref
+ self._closed = False
def __iter__(self):
return self
def __next__(self):
+ if self._closed:
+ raise StopIteration
return next(self.generator)
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
+ self.close()
+
+ def close(self):
+ self._closed = True
self.response.close()
@@ -53,6 +67,7 @@ class EventStreamAsync(Generic[T]):
client_ref: Optional[object]
response: httpx.Response
generator: AsyncGenerator[T, None]
+ _closed: bool
def __init__(
self,
@@ -60,181 +75,244 @@ def __init__(
decoder: Callable[[str], T],
sentinel: Optional[str] = None,
client_ref: Optional[object] = None,
+ data_required: bool = True,
):
self.response = response
- self.generator = stream_events_async(response, decoder, sentinel)
+ self.generator = stream_events_async(
+ response, decoder, sentinel, data_required=data_required
+ )
self.client_ref = client_ref
+ self._closed = False
def __aiter__(self):
return self
async def __anext__(self):
+ if self._closed:
+ raise StopAsyncIteration
return await self.generator.__anext__()
async def __aenter__(self):
return self
async def __aexit__(self, exc_type, exc_val, exc_tb):
+ await self.close()
+
+ async def close(self):
+ self._closed = True
await self.response.aclose()
+@dataclass
class ServerEvent:
id: Optional[str] = None
event: Optional[str] = None
- data: Optional[str] = None
+ data: Any = None
retry: Optional[int] = None
MESSAGE_BOUNDARIES = [
b"\r\n\r\n",
- b"\n\n",
+ b"\r\n\r",
+ b"\r\n\n",
+ b"\r\r\n",
+ b"\n\r\n",
b"\r\r",
+ b"\n\r",
+ b"\n\n",
]
+MAX_BOUNDARY_LEN = max(len(b) for b in MESSAGE_BOUNDARIES)
+
+UTF8_BOM = b"\xef\xbb\xbf"
async def stream_events_async(
response: httpx.Response,
decoder: Callable[[str], T],
sentinel: Optional[str] = None,
+ data_required: bool = True,
) -> AsyncGenerator[T, None]:
- buffer = bytearray()
- position = 0
- discard = False
- async for chunk in response.aiter_bytes():
- # We've encountered the sentinel value and should no longer process
- # incoming data. Instead we throw new data away until the server closes
- # the connection.
- if discard:
- continue
-
- buffer += chunk
- for i in range(position, len(buffer)):
- char = buffer[i : i + 1]
- seq: Optional[bytes] = None
- if char in [b"\r", b"\n"]:
- for boundary in MESSAGE_BOUNDARIES:
- seq = _peek_sequence(i, buffer, boundary)
- if seq is not None:
- break
- if seq is None:
- continue
-
- block = buffer[position:i]
- position = i + len(seq)
- event, discard = _parse_event(block, decoder, sentinel)
- if event is not None:
- yield event
-
- if position > 0:
- buffer = buffer[position:]
- position = 0
-
- event, discard = _parse_event(buffer, decoder, sentinel)
- if event is not None:
- yield event
+ try:
+ buffer = bytearray()
+ position = 0
+ event_id: Optional[str] = None
+ async for chunk in response.aiter_bytes():
+ if len(buffer) == 0 and chunk.startswith(UTF8_BOM):
+ chunk = chunk[len(UTF8_BOM) :]
+ old_len = len(buffer)
+ buffer += chunk
+ search_start = max(position, old_len - MAX_BOUNDARY_LEN + 1)
+ for i in range(search_start, len(buffer)):
+ char = buffer[i : i + 1]
+ seq: Optional[bytes] = None
+ if char in [b"\r", b"\n"]:
+ for boundary in MESSAGE_BOUNDARIES:
+ seq = _peek_sequence(i, buffer, boundary)
+ if seq is not None:
+ break
+ if seq is None:
+ continue
+
+ block = buffer[position:i]
+ position = i + len(seq)
+ event, discard, event_id = _parse_event(
+ raw=block,
+ decoder=decoder,
+ sentinel=sentinel,
+ event_id=event_id,
+ data_required=data_required,
+ )
+ if event is not None:
+ yield event
+ if discard:
+ return
+
+ if position > 0:
+ buffer = buffer[position:]
+ position = 0
+
+ event, discard, _ = _parse_event(
+ raw=buffer,
+ decoder=decoder,
+ sentinel=sentinel,
+ event_id=event_id,
+ data_required=data_required,
+ )
+ if event is not None:
+ yield event
+ finally:
+ await response.aclose()
def stream_events(
response: httpx.Response,
decoder: Callable[[str], T],
sentinel: Optional[str] = None,
+ data_required: bool = True,
) -> Generator[T, None, None]:
- buffer = bytearray()
- position = 0
- discard = False
- for chunk in response.iter_bytes():
- # We've encountered the sentinel value and should no longer process
- # incoming data. Instead we throw new data away until the server closes
- # the connection.
- if discard:
- continue
-
- buffer += chunk
- for i in range(position, len(buffer)):
- char = buffer[i : i + 1]
- seq: Optional[bytes] = None
- if char in [b"\r", b"\n"]:
- for boundary in MESSAGE_BOUNDARIES:
- seq = _peek_sequence(i, buffer, boundary)
- if seq is not None:
- break
- if seq is None:
- continue
-
- block = buffer[position:i]
- position = i + len(seq)
- event, discard = _parse_event(block, decoder, sentinel)
- if event is not None:
- yield event
-
- if position > 0:
- buffer = buffer[position:]
- position = 0
-
- event, discard = _parse_event(buffer, decoder, sentinel)
- if event is not None:
- yield event
+ try:
+ buffer = bytearray()
+ position = 0
+ event_id: Optional[str] = None
+ for chunk in response.iter_bytes():
+ if len(buffer) == 0 and chunk.startswith(UTF8_BOM):
+ chunk = chunk[len(UTF8_BOM) :]
+ old_len = len(buffer)
+ buffer += chunk
+ search_start = max(position, old_len - MAX_BOUNDARY_LEN + 1)
+ for i in range(search_start, len(buffer)):
+ char = buffer[i : i + 1]
+ seq: Optional[bytes] = None
+ if char in [b"\r", b"\n"]:
+ for boundary in MESSAGE_BOUNDARIES:
+ seq = _peek_sequence(i, buffer, boundary)
+ if seq is not None:
+ break
+ if seq is None:
+ continue
+
+ block = buffer[position:i]
+ position = i + len(seq)
+ event, discard, event_id = _parse_event(
+ raw=block,
+ decoder=decoder,
+ sentinel=sentinel,
+ event_id=event_id,
+ data_required=data_required,
+ )
+ if event is not None:
+ yield event
+ if discard:
+ return
+
+ if position > 0:
+ buffer = buffer[position:]
+ position = 0
+
+ event, discard, _ = _parse_event(
+ raw=buffer,
+ decoder=decoder,
+ sentinel=sentinel,
+ event_id=event_id,
+ data_required=data_required,
+ )
+ if event is not None:
+ yield event
+ finally:
+ response.close()
def _parse_event(
- raw: bytearray, decoder: Callable[[str], T], sentinel: Optional[str] = None
-) -> Tuple[Optional[T], bool]:
+ *,
+ raw: bytearray,
+ decoder: Callable[[str], T],
+ sentinel: Optional[str] = None,
+ event_id: Optional[str] = None,
+ data_required: bool = True,
+) -> Tuple[Optional[T], bool, Optional[str]]:
block = raw.decode()
lines = re.split(r"\r?\n|\r", block)
publish = False
event = ServerEvent()
- data = ""
+ data_parts: List[str] = []
for line in lines:
if not line:
continue
delim = line.find(":")
- if delim <= 0:
+ if delim == 0:
continue
- field = line[0:delim]
- value = line[delim + 1 :] if delim < len(line) - 1 else ""
- if len(value) and value[0] == " ":
- value = value[1:]
+ field = line
+ value = ""
+ if delim > 0:
+ field = line[0:delim]
+ value = line[delim + 1 :] if delim < len(line) - 1 else ""
+ if len(value) and value[0] == " ":
+ value = value[1:]
if field == "event":
event.event = value
publish = True
elif field == "data":
- data += value + "\n"
+ data_parts.append(value)
publish = True
elif field == "id":
- event.id = value
publish = True
+ if "\x00" not in value:
+ event_id = value
elif field == "retry":
- event.retry = int(value) if value.isdigit() else None
+ if value.isdigit():
+ event.retry = int(value)
publish = True
- if sentinel and data == f"{sentinel}\n":
- return None, True
+ event.id = event_id
+ has_data = bool(data_parts)
+ data = "\n".join(data_parts)
- if data:
- data = data[:-1]
- event.data = data
+ if sentinel and has_data and data == sentinel:
+ return None, True, event_id
- data_is_primitive = (
- data.isnumeric() or data == "true" or data == "false" or data == "null"
- )
- data_is_json = (
- data.startswith("{") or data.startswith("[") or data.startswith('"')
- )
+ # Skip data-less events when data is required
+ if not has_data and publish and data_required:
+ return None, False, event_id
- if data_is_primitive or data_is_json:
- try:
- event.data = json.loads(data)
- except Exception:
- pass
+ if has_data:
+ try:
+ event.data = json.loads(data)
+ except json.JSONDecodeError:
+ event.data = data
out = None
if publish:
- out = decoder(json.dumps(event.__dict__))
-
- return out, False
+ out_dict = {
+ k: v
+ for k, v in asdict(event).items()
+ if v is not None or (k == "data" and has_data)
+ }
+ out = decoder(json.dumps(out_dict))
+
+ return out, False, event_id
def _peek_sequence(position: int, buffer: bytearray, sequence: bytes):
diff --git a/src/bolt_api_sdk/utils/forms.py b/src/bolt_api_sdk/utils/forms.py
index e873495f..fdf0dc9b 100644
--- a/src/bolt_api_sdk/utils/forms.py
+++ b/src/bolt_api_sdk/utils/forms.py
@@ -1,5 +1,6 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
+import io
from typing import (
Any,
Dict,
@@ -103,6 +104,10 @@ def _extract_file_properties(file_obj: Any) -> Tuple[str, Any, Any]:
if file_metadata.content:
content = getattr(file_obj, file_field_name, None)
+ if isinstance(content, io.TextIOBase):
+ content = content.read().encode(
+ getattr(content, "encoding", None) or "utf-8"
+ )
elif file_field_name == "content_type":
content_type = getattr(file_obj, file_field_name, None)
else:
@@ -142,16 +147,21 @@ def serialize_multipart_form(
if field_metadata.file:
if isinstance(val, List):
# Handle array of files
+ array_field_name = f_name + "[]"
for file_obj in val:
if not _is_set(file_obj):
continue
-
- file_name, content, content_type = _extract_file_properties(file_obj)
+
+ file_name, content, content_type = _extract_file_properties(
+ file_obj
+ )
if content_type is not None:
- files.append((f_name + "[]", (file_name, content, content_type)))
+ files.append(
+ (array_field_name, (file_name, content, content_type))
+ )
else:
- files.append((f_name + "[]", (file_name, content)))
+ files.append((array_field_name, (file_name, content)))
else:
# Handle single file
file_name, content, content_type = _extract_file_properties(val)
@@ -161,11 +171,16 @@ def serialize_multipart_form(
else:
files.append((f_name, (file_name, content)))
elif field_metadata.json:
- files.append((f_name, (
- None,
- marshal_json(val, request_field_types[name]),
- "application/json",
- )))
+ files.append(
+ (
+ f_name,
+ (
+ None,
+ marshal_json(val, request_field_types[name]),
+ "application/json",
+ ),
+ )
+ )
else:
if isinstance(val, List):
values = []
@@ -175,7 +190,8 @@ def serialize_multipart_form(
continue
values.append(_val_to_string(value))
- form[f_name + "[]"] = values
+ array_field_name = f_name + "[]"
+ form[array_field_name] = values
else:
form[f_name] = _val_to_string(val)
return media_type, form, files
diff --git a/src/bolt_api_sdk/utils/metadata.py b/src/bolt_api_sdk/utils/metadata.py
index 173b3e5c..5abddd58 100644
--- a/src/bolt_api_sdk/utils/metadata.py
+++ b/src/bolt_api_sdk/utils/metadata.py
@@ -15,6 +15,7 @@ class SecurityMetadata:
scheme_type: Optional[str] = None
sub_type: Optional[str] = None
field_name: Optional[str] = None
+ composite: bool = False
def get_field_name(self, default: str) -> str:
return self.field_name or default
diff --git a/src/bolt_api_sdk/utils/queryparams.py b/src/bolt_api_sdk/utils/queryparams.py
index 37a6e7f9..c04e0db8 100644
--- a/src/bolt_api_sdk/utils/queryparams.py
+++ b/src/bolt_api_sdk/utils/queryparams.py
@@ -27,12 +27,13 @@
def get_query_params(
query_params: Any,
gbls: Optional[Any] = None,
+ allow_empty_value: Optional[List[str]] = None,
) -> Dict[str, List[str]]:
params: Dict[str, List[str]] = {}
- globals_already_populated = _populate_query_params(query_params, gbls, params, [])
+ globals_already_populated = _populate_query_params(query_params, gbls, params, [], allow_empty_value)
if _is_set(gbls):
- _populate_query_params(gbls, None, params, globals_already_populated)
+ _populate_query_params(gbls, None, params, globals_already_populated, allow_empty_value)
return params
@@ -42,6 +43,7 @@ def _populate_query_params(
gbls: Any,
query_param_values: Dict[str, List[str]],
skip_fields: List[str],
+ allow_empty_value: Optional[List[str]] = None,
) -> List[str]:
globals_already_populated: List[str] = []
@@ -69,6 +71,16 @@ def _populate_query_params(
globals_already_populated.append(name)
f_name = field.alias if field.alias is not None else name
+
+ allow_empty_set = set(allow_empty_value or [])
+ should_include_empty = f_name in allow_empty_set and (
+ value is None or value == [] or value == ""
+ )
+
+ if should_include_empty:
+ query_param_values[f_name] = [""]
+ continue
+
serialization = metadata.serialization
if serialization is not None:
serialized_parms = _get_serialized_params(
diff --git a/src/bolt_api_sdk/utils/requestbodies.py b/src/bolt_api_sdk/utils/requestbodies.py
index d5240dd5..591415af 100644
--- a/src/bolt_api_sdk/utils/requestbodies.py
+++ b/src/bolt_api_sdk/utils/requestbodies.py
@@ -44,15 +44,16 @@ def serialize_request_body(
serialized_request_body = SerializedRequestBody(media_type)
- if re.match(r"(application|text)\/.*?\+*json.*", media_type) is not None:
+ if re.match(r"^(application|text)\/([^+]+\+)*json.*", media_type) is not None:
serialized_request_body.content = marshal_json(request_body, request_body_type)
- elif re.match(r"multipart\/.*", media_type) is not None:
+
+ elif re.match(r"^multipart\/.*", media_type) is not None:
(
serialized_request_body.media_type,
serialized_request_body.data,
serialized_request_body.files,
) = serialize_multipart_form(media_type, request_body)
- elif re.match(r"application\/x-www-form-urlencoded.*", media_type) is not None:
+ elif re.match(r"^application\/x-www-form-urlencoded.*", media_type) is not None:
serialized_request_body.data = serialize_form_data(request_body)
elif isinstance(request_body, (bytes, bytearray, io.BytesIO, io.BufferedReader)):
serialized_request_body.content = request_body
diff --git a/src/bolt_api_sdk/utils/retries.py b/src/bolt_api_sdk/utils/retries.py
index 4d608671..ca7b59ef 100644
--- a/src/bolt_api_sdk/utils/retries.py
+++ b/src/bolt_api_sdk/utils/retries.py
@@ -3,16 +3,21 @@
import asyncio
import random
import time
-from typing import List
+from datetime import datetime
+from email.utils import parsedate_to_datetime
+from typing import List, Optional
import httpx
class BackoffStrategy:
+ """Exponential backoff strategy configuration."""
+
initial_interval: int
max_interval: int
exponent: float
max_elapsed_time: int
+ jitter_ms: Optional[int]
def __init__(
self,
@@ -20,24 +25,63 @@ def __init__(
max_interval: int,
exponent: float,
max_elapsed_time: int,
+ jitter_ms: Optional[int] = None,
):
+ """Initialize a backoff strategy.
+
+ Args:
+ initial_interval: Initial retry interval in milliseconds.
+ max_interval: Maximum retry interval in milliseconds.
+ exponent: Base of the exponential backoff; the interval grows as
+ ``initial_interval * exponent ** retries``.
+ max_elapsed_time: Maximum total elapsed time in milliseconds.
+ jitter_ms: Additive jitter bound in milliseconds. When set, adds a random
+ value in ``[0, jitter_ms]`` to each computed backoff interval (default
+ ``+[0, 1s]``).
+
+ Note:
+ When a response carries a ``Retry-After`` or ``retry-after-ms`` header,
+ that delay is used as-is and the sleep-shaping parameters
+ (``initial_interval``, ``max_interval``, ``exponent``, ``jitter_ms``) are
+ ignored for that attempt.
+ """
+ if jitter_ms is not None and jitter_ms < 0:
+ raise ValueError("jitter_ms must be >= 0")
self.initial_interval = initial_interval
self.max_interval = max_interval
self.exponent = exponent
self.max_elapsed_time = max_elapsed_time
+ self.jitter_ms = jitter_ms
class RetryConfig:
+ """Runtime retry configuration."""
+
strategy: str
backoff: BackoffStrategy
retry_connection_errors: bool
+ status_codes_override: Optional[List[str]]
def __init__(
- self, strategy: str, backoff: BackoffStrategy, retry_connection_errors: bool
+ self,
+ strategy: str,
+ backoff: BackoffStrategy,
+ retry_connection_errors: bool,
+ status_codes_override: Optional[List[str]] = None,
):
+ """Initialize a retry configuration.
+
+ Args:
+ strategy: Retry strategy: ``"none"`` or ``"backoff"``.
+ backoff: Backoff parameters.
+ retry_connection_errors: Whether to also retry transport-level connection errors.
+ status_codes_override: Retryable HTTP status codes that take precedence over the
+ per-operation defaults when non-empty.
+ """
self.strategy = strategy
self.backoff = backoff
self.retry_connection_errors = retry_connection_errors
+ self.status_codes_override = status_codes_override
class Retries:
@@ -46,14 +90,16 @@ class Retries:
def __init__(self, config: RetryConfig, status_codes: List[str]):
self.config = config
- self.status_codes = status_codes
+ self.status_codes = config.status_codes_override or status_codes
class TemporaryError(Exception):
response: httpx.Response
+ retry_after: Optional[int]
def __init__(self, response: httpx.Response):
self.response = response
+ self.retry_after = _parse_retry_after_header(response)
class PermanentError(Exception):
@@ -63,6 +109,83 @@ def __init__(self, inner: Exception):
self.inner = inner
+def _parse_retry_after_header(response: httpx.Response) -> Optional[int]:
+ """Parse Retry-After header from response.
+
+ Returns:
+ Retry interval in milliseconds, or None if header is missing or invalid.
+ """
+ retry_after_header = response.headers.get("retry-after")
+ if not retry_after_header:
+ return None
+
+ try:
+ seconds = float(retry_after_header)
+ return round(seconds * 1000)
+ except ValueError:
+ pass
+
+ try:
+ retry_date = parsedate_to_datetime(retry_after_header)
+ delta = (retry_date - datetime.now(retry_date.tzinfo)).total_seconds()
+ return round(max(0, delta) * 1000)
+ except (ValueError, TypeError):
+ pass
+
+ return None
+
+
+def _parse_retry_after_ms_header(response: httpx.Response) -> Optional[int]:
+ retry_after_ms_header = response.headers.get("retry-after-ms")
+ if not retry_after_ms_header:
+ return None
+
+ try:
+ milliseconds = float(retry_after_ms_header)
+ if milliseconds >= 0:
+ return round(milliseconds)
+ except (OverflowError, ValueError):
+ pass
+
+ return None
+
+
+def _get_sleep_interval(
+ exception: Exception,
+ initial_interval: int,
+ max_interval: int,
+ exponent: float,
+ retries: int,
+ jitter_ms: Optional[int] = None,
+) -> float:
+ """Get sleep interval for retry with exponential backoff.
+
+ Args:
+ exception: The exception that triggered the retry.
+ initial_interval: Initial retry interval in milliseconds.
+ max_interval: Maximum retry interval in milliseconds.
+ exponent: Base for exponential backoff calculation.
+ retries: Current retry attempt count.
+ jitter_ms: Additive jitter bound in ms; see ``BackoffStrategy.jitter_ms``.
+
+ Returns:
+ Sleep interval in seconds.
+ """
+ if (
+ isinstance(exception, TemporaryError)
+ and exception.retry_after is not None
+ and exception.retry_after > 0
+ ):
+ return exception.retry_after / 1000
+
+ sleep = (initial_interval / 1000) * exponent**retries
+ if jitter_ms is not None:
+ sleep += random.uniform(0, jitter_ms / 1000)
+ else:
+ sleep += random.uniform(0, 1)
+ return min(sleep, max_interval / 1000)
+
+
def retry(func, retries: Retries):
if retries.config.strategy == "backoff":
@@ -84,12 +207,7 @@ def do_request() -> httpx.Response:
if res.status_code == parsed_code:
raise TemporaryError(res)
- except httpx.ConnectError as exception:
- if retries.config.retry_connection_errors:
- raise
-
- raise PermanentError(exception) from exception
- except httpx.TimeoutException as exception:
+ except (httpx.NetworkError, httpx.TimeoutException) as exception:
if retries.config.retry_connection_errors:
raise
@@ -107,6 +225,7 @@ def do_request() -> httpx.Response:
retries.config.backoff.max_interval,
retries.config.backoff.exponent,
retries.config.backoff.max_elapsed_time,
+ retries.config.backoff.jitter_ms,
)
return func()
@@ -133,12 +252,7 @@ async def do_request() -> httpx.Response:
if res.status_code == parsed_code:
raise TemporaryError(res)
- except httpx.ConnectError as exception:
- if retries.config.retry_connection_errors:
- raise
-
- raise PermanentError(exception) from exception
- except httpx.TimeoutException as exception:
+ except (httpx.NetworkError, httpx.TimeoutException) as exception:
if retries.config.retry_connection_errors:
raise
@@ -156,6 +270,7 @@ async def do_request() -> httpx.Response:
retries.config.backoff.max_interval,
retries.config.backoff.exponent,
retries.config.backoff.max_elapsed_time,
+ retries.config.backoff.jitter_ms,
)
return await func()
@@ -167,6 +282,7 @@ def retry_with_backoff(
max_interval=60000,
exponent=1.5,
max_elapsed_time=3600000,
+ jitter_ms=None,
):
start = round(time.time() * 1000)
retries = 0
@@ -183,8 +299,19 @@ def retry_with_backoff(
return exception.response
raise
- sleep = (initial_interval / 1000) * exponent**retries + random.uniform(0, 1)
- sleep = min(sleep, max_interval / 1000)
+
+ if isinstance(exception, TemporaryError):
+ retry_after_ms = _parse_retry_after_ms_header(exception.response)
+ if retry_after_ms is not None:
+ exception.retry_after = retry_after_ms
+ sleep = _get_sleep_interval(
+ exception,
+ initial_interval,
+ max_interval,
+ exponent,
+ retries,
+ jitter_ms=jitter_ms,
+ )
time.sleep(sleep)
retries += 1
@@ -195,6 +322,7 @@ async def retry_with_backoff_async(
max_interval=60000,
exponent=1.5,
max_elapsed_time=3600000,
+ jitter_ms=None,
):
start = round(time.time() * 1000)
retries = 0
@@ -211,7 +339,18 @@ async def retry_with_backoff_async(
return exception.response
raise
- sleep = (initial_interval / 1000) * exponent**retries + random.uniform(0, 1)
- sleep = min(sleep, max_interval / 1000)
+
+ if isinstance(exception, TemporaryError):
+ retry_after_ms = _parse_retry_after_ms_header(exception.response)
+ if retry_after_ms is not None:
+ exception.retry_after = retry_after_ms
+ sleep = _get_sleep_interval(
+ exception,
+ initial_interval,
+ max_interval,
+ exponent,
+ retries,
+ jitter_ms=jitter_ms,
+ )
await asyncio.sleep(sleep)
retries += 1
diff --git a/src/bolt_api_sdk/utils/security.py b/src/bolt_api_sdk/utils/security.py
index 058d18d9..e5746c12 100644
--- a/src/bolt_api_sdk/utils/security.py
+++ b/src/bolt_api_sdk/utils/security.py
@@ -19,7 +19,9 @@
import os
-def get_security(security: Any) -> Tuple[Dict[str, str], Dict[str, List[str]]]:
+def get_security(
+ security: Any, allowed_fields: Optional[List[str]] = None
+) -> Tuple[Dict[str, str], Dict[str, List[str]]]:
headers: Dict[str, str] = {}
query_params: Dict[str, List[str]] = {}
@@ -30,7 +32,14 @@ def get_security(security: Any) -> Tuple[Dict[str, str], Dict[str, List[str]]]:
raise TypeError("security must be a pydantic model")
sec_fields: Dict[str, FieldInfo] = security.__class__.model_fields
- for name in sec_fields:
+ sec_field_names = (
+ list(sec_fields.keys()) if allowed_fields is None else allowed_fields
+ )
+
+ for name in sec_field_names:
+ if name not in sec_fields:
+ continue
+
sec_field = sec_fields[name]
value = getattr(security, name)
@@ -52,6 +61,9 @@ def get_security(security: Any) -> Tuple[Dict[str, str], Dict[str, List[str]]]:
else:
_parse_security_scheme(headers, query_params, metadata, name, value)
+ if not metadata.composite:
+ return headers, query_params
+
return headers, query_params
@@ -80,15 +92,24 @@ def _parse_security_option(
raise TypeError("security option must be a pydantic model")
opt_fields: Dict[str, FieldInfo] = option.__class__.model_fields
+
for name in opt_fields:
opt_field = opt_fields[name]
metadata = find_field_metadata(opt_field, SecurityMetadata)
if metadata is None or not metadata.scheme:
continue
- _parse_security_scheme(
- headers, query_params, metadata, name, getattr(option, name)
- )
+
+ value = getattr(option, name)
+ if (
+ metadata.scheme_type == "http"
+ and metadata.sub_type == "basic"
+ and not isinstance(value, BaseModel)
+ ):
+ _parse_basic_auth_scheme(headers, option)
+ return
+
+ _parse_security_scheme(headers, query_params, metadata, name, value)
def _parse_security_scheme(
@@ -156,6 +177,8 @@ def _parse_security_scheme_value(
elif scheme_type == "http":
if sub_type == "bearer":
headers[header_name] = _apply_bearer(value)
+ elif sub_type == "basic":
+ headers[header_name] = value
elif sub_type == "custom":
return
else:
diff --git a/src/bolt_api_sdk/utils/serializers.py b/src/bolt_api_sdk/utils/serializers.py
index 378a14c0..1031ed93 100644
--- a/src/bolt_api_sdk/utils/serializers.py
+++ b/src/bolt_api_sdk/utils/serializers.py
@@ -4,7 +4,7 @@
import functools
import json
import typing
-from typing import Any, Dict, List, Tuple, Union, get_args
+from typing import Any, Dict, Iterable, List, Mapping, Tuple, Union, get_args
import typing_extensions
from typing_extensions import get_origin
@@ -17,8 +17,7 @@
def serialize_decimal(as_str: bool):
def serialize(d):
- # Optional[T] is a Union[T, None]
- if is_union(type(d)) and type(None) in get_args(type(d)) and d is None:
+ if d is None:
return None
if isinstance(d, Unset):
return d
@@ -46,8 +45,7 @@ def validate_decimal(d):
def serialize_float(as_str: bool):
def serialize(f):
- # Optional[T] is a Union[T, None]
- if is_union(type(f)) and type(None) in get_args(type(f)) and f is None:
+ if f is None:
return None
if isinstance(f, Unset):
return f
@@ -75,8 +73,7 @@ def validate_float(f):
def serialize_int(as_str: bool):
def serialize(i):
- # Optional[T] is a Union[T, None]
- if is_union(type(i)) and type(None) in get_args(type(i)) and i is None:
+ if i is None:
return None
if isinstance(i, Unset):
return i
@@ -102,30 +99,9 @@ def validate_int(b):
return int(b)
-def validate_open_enum(is_int: bool):
- def validate(e):
- if e is None:
- return None
-
- if isinstance(e, Unset):
- return e
-
- if is_int:
- if not isinstance(e, int):
- raise ValueError("Expected int")
- else:
- if not isinstance(e, str):
- raise ValueError("Expected string")
-
- return e
-
- return validate
-
-
def validate_const(v):
def validate(c):
- # Optional[T] is a Union[T, None]
- if is_union(type(c)) and type(None) in get_args(type(c)) and c is None:
+ if c is None:
return None
if v != c:
@@ -137,10 +113,12 @@ def validate(c):
def unmarshal_json(raw, typ: Any) -> Any:
- return unmarshal(from_json(raw), typ)
+ return unmarshal(from_json(raw), typ, coerce_iterables=False)
-def unmarshal(val, typ: Any) -> Any:
+def unmarshal(val, typ: Any, coerce_iterables: bool = True) -> Any:
+ if coerce_iterables:
+ val = _coerce_iterables_for_type(val, typ)
unmarshaller = create_model(
"Unmarshaller",
body=(typ, ...),
@@ -217,9 +195,88 @@ def get_pydantic_model(data: Any, typ: Any) -> Any:
if not _contains_pydantic_model(data):
return unmarshal(data, typ)
+ return _coerce_iterables_for_type(data, typ)
+
+
+def _coerce_iterables_for_type(data: Any, typ: Any) -> Any:
+ if data is None or isinstance(data, (BaseModel, Unset)):
+ return data
+
+ typ = _resolve_type_alias(typ)
+ origin = get_origin(typ)
+
+ if _is_annotated_type(origin):
+ args = get_args(typ)
+ return _coerce_iterables_for_type(data, args[0]) if args else data
+
+ if is_union(origin):
+ for arg in (arg for arg in get_args(typ) if arg is not type(None)):
+ coerced = _coerce_iterables_for_type(data, arg)
+ if coerced is not data:
+ return coerced
+ return data
+
+ if _is_list_type(typ):
+ item_type = get_args(typ)[0] if get_args(typ) else Any
+ if isinstance(data, (str, bytes, bytearray, Mapping)):
+ return data
+ if isinstance(data, Iterable):
+ return [_coerce_iterables_for_type(item, item_type) for item in data]
+ return data
+
+ if _is_mapping_type(typ):
+ value_type = get_args(typ)[1] if len(get_args(typ)) > 1 else Any
+ if isinstance(data, Mapping):
+ return {
+ key: _coerce_iterables_for_type(value, value_type)
+ for key, value in data.items()
+ }
+ return data
+
+ if _is_pydantic_model_type(typ) and isinstance(data, Mapping):
+ coerced = None
+ for field_name, field in typ.model_fields.items():
+ field_type = field.annotation
+ for key in (field_name, field.alias):
+ if key is not None and key in data:
+ value = data[key] if coerced is None else coerced[key]
+ coerced_value = _coerce_iterables_for_type(value, field_type)
+ if coerced_value is not value:
+ if coerced is None:
+ coerced = dict(data)
+ coerced[key] = coerced_value
+ return coerced if coerced is not None else data
+
return data
+def _resolve_type_alias(typ: Any) -> Any:
+ return getattr(typ, "__value__", typ)
+
+
+def _is_annotated_type(origin: Any) -> bool:
+ return any(
+ origin is typing_obj
+ for typing_obj in _get_typing_objects_by_name_of("Annotated")
+ )
+
+
+def _is_list_type(typ: Any) -> bool:
+ typ = _resolve_type_alias(typ)
+ return typ is list or get_origin(typ) is list
+
+
+def _is_mapping_type(typ: Any) -> bool:
+ typ = _resolve_type_alias(typ)
+ origin = get_origin(typ)
+ mapping_origin = get_origin(Mapping[Any, Any])
+ return typ in (dict, Dict, Mapping) or origin in (dict, Mapping, mapping_origin)
+
+
+def _is_pydantic_model_type(typ: Any) -> bool:
+ return isinstance(typ, type) and issubclass(typ, BaseModel)
+
+
def _contains_pydantic_model(data: Any) -> bool:
if isinstance(data, BaseModel):
return True
diff --git a/src/bolt_api_sdk/utils/unmarshal_json_response.py b/src/bolt_api_sdk/utils/unmarshal_json_response.py
index 30f52d82..0dc6b0c4 100644
--- a/src/bolt_api_sdk/utils/unmarshal_json_response.py
+++ b/src/bolt_api_sdk/utils/unmarshal_json_response.py
@@ -1,12 +1,26 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
-from typing import Any, Optional
+from typing import Any, Optional, Type, TypeVar, overload
import httpx
from .serializers import unmarshal_json
from bolt_api_sdk import errors
+T = TypeVar("T")
+
+
+@overload
+def unmarshal_json_response(
+ typ: Type[T], http_res: httpx.Response, body: Optional[str] = None
+) -> T: ...
+
+
+@overload
+def unmarshal_json_response(
+ typ: Any, http_res: httpx.Response, body: Optional[str] = None
+) -> Any: ...
+
def unmarshal_json_response(
typ: Any, http_res: httpx.Response, body: Optional[str] = None
diff --git a/src/bolt_api_sdk/webhooks.py b/src/bolt_api_sdk/webhooks.py
index 257ce451..94cf4c69 100644
--- a/src/bolt_api_sdk/webhooks.py
+++ b/src/bolt_api_sdk/webhooks.py
@@ -25,6 +25,8 @@ def query_webhooks(
Find webhook configurations belonging to a merchant division. Results are limited to only show webhooks authorized by the X-API-Key.
+ If set, this operation will use `x_api_key` from the global security.
+
:param division_id: The unique ID associated to the merchant's Bolt Account division; Merchants can have different divisions to suit multiple use cases (storefronts, pay-by-link, phone order processing). You can view and switch between these divisions from the Bolt Merchant Dashboard.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -58,6 +60,8 @@ def query_webhooks(
accept_header_value="application/json",
http_headers=http_headers,
security=self.sdk_configuration.security,
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -74,13 +78,15 @@ def query_webhooks(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="queryWebhooks",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Webhooks"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "403", "404", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -114,6 +120,8 @@ async def query_webhooks_async(
Find webhook configurations belonging to a merchant division. Results are limited to only show webhooks authorized by the X-API-Key.
+ If set, this operation will use `x_api_key` from the global security.
+
:param division_id: The unique ID associated to the merchant's Bolt Account division; Merchants can have different divisions to suit multiple use cases (storefronts, pay-by-link, phone order processing). You can view and switch between these divisions from the Bolt Merchant Dashboard.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -147,6 +155,8 @@ async def query_webhooks_async(
accept_header_value="application/json",
http_headers=http_headers,
security=self.sdk_configuration.security,
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -163,13 +173,15 @@ async def query_webhooks_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="queryWebhooks",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Webhooks"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "403", "404", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -205,6 +217,8 @@ def create_webhook(
Create a new webhook to receive notifications from Bolt about various events, such as transaction status. Webhooks must have unique configuration.
+ If set, this operation will use `x_api_key` from the global security.
+
:param request: The request object to send.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -241,6 +255,8 @@ def create_webhook(
get_serialized_body=lambda: utils.serialize_request_body(
request, False, False, "json", models.CreateWebhookRequest
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -257,13 +273,15 @@ def create_webhook(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="createWebhook",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Webhooks"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "403", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -299,6 +317,8 @@ async def create_webhook_async(
Create a new webhook to receive notifications from Bolt about various events, such as transaction status. Webhooks must have unique configuration.
+ If set, this operation will use `x_api_key` from the global security.
+
:param request: The request object to send.
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -335,6 +355,8 @@ async def create_webhook_async(
get_serialized_body=lambda: utils.serialize_request_body(
request, False, False, "json", models.CreateWebhookRequest
),
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -351,13 +373,15 @@ async def create_webhook_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="createWebhook",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Webhooks"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "403", "422", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -391,6 +415,8 @@ def delete_webhook(
Delete a Bolt webhook. Provide an authorized X-API-Key to perform this action.
+ If set, this operation will use `x_api_key` from the global security.
+
:param webhook_id: Webhook ID
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -424,6 +450,8 @@ def delete_webhook(
accept_header_value="application/json",
http_headers=http_headers,
security=self.sdk_configuration.security,
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -440,13 +468,15 @@ def delete_webhook(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="deleteWebhook",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Webhooks"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "403", "404", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -480,6 +510,8 @@ async def delete_webhook_async(
Delete a Bolt webhook. Provide an authorized X-API-Key to perform this action.
+ If set, this operation will use `x_api_key` from the global security.
+
:param webhook_id: Webhook ID
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -513,6 +545,8 @@ async def delete_webhook_async(
accept_header_value="application/json",
http_headers=http_headers,
security=self.sdk_configuration.security,
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -529,13 +563,15 @@ async def delete_webhook_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="deleteWebhook",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Webhooks"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "403", "404", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -569,6 +605,8 @@ def get_webhook(
Get Webhook information by its Webhook ID. Results only include webhooks authorized by the X-API-Key.
+ If set, this operation will use `x_api_key` from the global security.
+
:param webhook_id: Webhook ID
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -602,6 +640,8 @@ def get_webhook(
accept_header_value="application/json",
http_headers=http_headers,
security=self.sdk_configuration.security,
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -618,13 +658,15 @@ def get_webhook(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="getWebhook",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Webhooks"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "403", "404", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)
@@ -658,6 +700,8 @@ async def get_webhook_async(
Get Webhook information by its Webhook ID. Results only include webhooks authorized by the X-API-Key.
+ If set, this operation will use `x_api_key` from the global security.
+
:param webhook_id: Webhook ID
:param retries: Override the default retry configuration for this method
:param server_url: Override the default server URL for this method
@@ -691,6 +735,8 @@ async def get_webhook_async(
accept_header_value="application/json",
http_headers=http_headers,
security=self.sdk_configuration.security,
+ allow_empty_value=None,
+ allowed_fields=["x_api_key"],
timeout_ms=timeout_ms,
)
@@ -707,13 +753,15 @@ async def get_webhook_async(
config=self.sdk_configuration,
base_url=base_url or "",
operation_id="getWebhook",
- oauth2_scopes=[],
+ oauth2_scopes=None,
security_source=get_security_from_env(
self.sdk_configuration.security, models.Security
),
+ tags=["Webhooks"],
+ extensions=None,
),
request=req,
- error_status_codes=["400", "403", "404", "4XX", "5XX"],
+ is_error_status_code=lambda c: utils.match_status_codes(["4XX", "5XX"], c),
retry_config=retry_config,
)