Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
configured_endpoints: 238
openapi_spec_hash: fa67b808ca579e929aea7dd917b18cf9
config_hash: 2ae0d8aaecf01b38cbf9f9e112822c23
configured_endpoints: 239
openapi_spec_hash: 202e0c39463e4ad1b25a72b0da68a6ce
config_hash: 1ca082e374ef7000e2a5971e8da740e0
1 change: 1 addition & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ Methods:
- <code title="post /files">client.files.<a href="./src/increase/resources/files.py">create</a>(\*\*<a href="src/increase/types/file_create_params.py">params</a>) -> <a href="./src/increase/types/file.py">File</a></code>
- <code title="get /files/{file_id}">client.files.<a href="./src/increase/resources/files.py">retrieve</a>(file_id) -> <a href="./src/increase/types/file.py">File</a></code>
- <code title="get /files">client.files.<a href="./src/increase/resources/files.py">list</a>(\*\*<a href="src/increase/types/file_list_params.py">params</a>) -> <a href="./src/increase/types/file.py">SyncPage[File]</a></code>
- <code title="get /files/{file_id}/contents">client.files.<a href="./src/increase/resources/files.py">contents</a>(file_id) -> BinaryAPIResponse</code>

# FileLinks

Expand Down
2 changes: 1 addition & 1 deletion scripts/mock

Large diffs are not rendered by default.

23 changes: 4 additions & 19 deletions src/increase/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def _make_status_error(
) -> _exceptions.APIStatusError:
raise NotImplementedError()

def _build_headers(self, options: FinalRequestOptions, *, retries_taken: int = 0) -> httpx.Headers:
def _build_headers(self, options: FinalRequestOptions) -> httpx.Headers:
custom_headers = options.headers or {}
headers_dict = _merge_mappings(self.default_headers, custom_headers)
self._validate_headers(headers_dict, custom_headers)
Expand All @@ -444,18 +444,6 @@ def _build_headers(self, options: FinalRequestOptions, *, retries_taken: int = 0
if idempotency_header and options.idempotency_key and idempotency_header not in headers:
headers[idempotency_header] = options.idempotency_key

# Don't set these headers if they were already set or removed by the caller. We check
# `custom_headers`, which can contain `Omit()`, instead of `headers` to account for the removal case.
lower_custom_headers = [header.lower() for header in custom_headers]
if "x-stainless-retry-count" not in lower_custom_headers:
headers["x-stainless-retry-count"] = str(retries_taken)
if "x-stainless-read-timeout" not in lower_custom_headers:
timeout = self.timeout if isinstance(options.timeout, NotGiven) else options.timeout
if isinstance(timeout, Timeout):
timeout = timeout.read
if timeout is not None:
headers["x-stainless-read-timeout"] = str(timeout)

return headers

def _prepare_url(self, url: str) -> URL:
Expand All @@ -477,8 +465,6 @@ def _make_sse_decoder(self) -> SSEDecoder | SSEBytesDecoder:
def _build_request(
self,
options: FinalRequestOptions,
*,
retries_taken: int = 0,
) -> httpx.Request:
if log.isEnabledFor(logging.DEBUG):
log.debug(
Expand All @@ -505,7 +491,7 @@ def _build_request(
else:
raise RuntimeError(f"Unexpected JSON data type, {type(json_data)}, cannot merge with `extra_body`")

headers = self._build_headers(options, retries_taken=retries_taken)
headers = self._build_headers(options)
params = _merge_mappings(self.default_query, options.params)
content_type = headers.get("Content-Type")
files = options.files
Expand Down Expand Up @@ -674,7 +660,6 @@ def default_headers(self) -> dict[str, str | Omit]:
"Accept": "application/json",
"Content-Type": "application/json",
"User-Agent": self.user_agent,
**self.platform_headers(),
**self.auth_headers,
**self._custom_headers,
}
Expand Down Expand Up @@ -990,7 +975,7 @@ def request(
options = self._prepare_options(options)

remaining_retries = max_retries - retries_taken
request = self._build_request(options, retries_taken=retries_taken)
request = self._build_request(options)
self._prepare_request(request)

kwargs: HttpxSendArgs = {}
Expand Down Expand Up @@ -1575,7 +1560,7 @@ async def request(
options = await self._prepare_options(options)

remaining_retries = max_retries - retries_taken
request = self._build_request(options, retries_taken=retries_taken)
request = self._build_request(options)
await self._prepare_request(request)

kwargs: HttpxSendArgs = {}
Expand Down
9 changes: 1 addition & 8 deletions src/increase/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@
RequestOptions,
not_given,
)
from ._utils import (
is_given,
is_mapping,
is_mapping_t,
get_async_library,
)
from ._utils import is_given, is_mapping, is_mapping_t
from ._compat import cached_property
from ._version import __version__
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
Expand Down Expand Up @@ -653,7 +648,6 @@ def auth_headers(self) -> dict[str, str]:
def default_headers(self) -> dict[str, str | Omit]:
return {
**super().default_headers,
"X-Stainless-Async": "false",
**self._custom_headers,
}

Expand Down Expand Up @@ -1255,7 +1249,6 @@ def auth_headers(self) -> dict[str, str]:
def default_headers(self) -> dict[str, str | Omit]:
return {
**super().default_headers,
"X-Stainless-Async": f"async:{get_async_library()}",
**self._custom_headers,
}

Expand Down
112 changes: 112 additions & 0 deletions src/increase/resources/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@
from .._compat import cached_property
from .._resource import SyncAPIResource, AsyncAPIResource
from .._response import (
BinaryAPIResponse,
AsyncBinaryAPIResponse,
StreamedBinaryAPIResponse,
AsyncStreamedBinaryAPIResponse,
to_raw_response_wrapper,
to_streamed_response_wrapper,
async_to_raw_response_wrapper,
to_custom_raw_response_wrapper,
async_to_streamed_response_wrapper,
to_custom_streamed_response_wrapper,
async_to_custom_raw_response_wrapper,
async_to_custom_streamed_response_wrapper,
)
from ..pagination import SyncPage, AsyncPage
from ..types.file import File
Expand Down Expand Up @@ -262,6 +270,50 @@ def list(
model=File,
)

def contents(
self,
file_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> BinaryAPIResponse:
"""Download the contents of a File.

Responds with a 307 redirect whose `Location`
header points at a short-lived, pre-signed URL. Our
[SDKs](/documentation/software-development-kits) follow the redirect and return
the File's contents; if you call the API directly, follow the redirect to
download it. The pre-signed URL serves the File with a `Content-Type` matching
its `mime` and a `Content-Disposition` header set to its `filename`. It expires
in 10 minutes. To share a File with someone who doesn't have access to your API
key, create a File Link.

Args:
file_id: The identifier of the File.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
if not file_id:
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})}
return self._get(
path_template("/files/{file_id}/contents", file_id=file_id),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=BinaryAPIResponse,
)


class AsyncFilesResource(AsyncAPIResource):
@cached_property
Expand Down Expand Up @@ -499,6 +551,50 @@ def list(
model=File,
)

async def contents(
self,
file_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> AsyncBinaryAPIResponse:
"""Download the contents of a File.

Responds with a 307 redirect whose `Location`
header points at a short-lived, pre-signed URL. Our
[SDKs](/documentation/software-development-kits) follow the redirect and return
the File's contents; if you call the API directly, follow the redirect to
download it. The pre-signed URL serves the File with a `Content-Type` matching
its `mime` and a `Content-Disposition` header set to its `filename`. It expires
in 10 minutes. To share a File with someone who doesn't have access to your API
key, create a File Link.

Args:
file_id: The identifier of the File.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
if not file_id:
raise ValueError(f"Expected a non-empty value for `file_id` but received {file_id!r}")
extra_headers = {"Accept": "application/octet-stream", **(extra_headers or {})}
return await self._get(
path_template("/files/{file_id}/contents", file_id=file_id),
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=AsyncBinaryAPIResponse,
)


class FilesResourceWithRawResponse:
def __init__(self, files: FilesResource) -> None:
Expand All @@ -513,6 +609,10 @@ def __init__(self, files: FilesResource) -> None:
self.list = to_raw_response_wrapper(
files.list,
)
self.contents = to_custom_raw_response_wrapper(
files.contents,
BinaryAPIResponse,
)


class AsyncFilesResourceWithRawResponse:
Expand All @@ -528,6 +628,10 @@ def __init__(self, files: AsyncFilesResource) -> None:
self.list = async_to_raw_response_wrapper(
files.list,
)
self.contents = async_to_custom_raw_response_wrapper(
files.contents,
AsyncBinaryAPIResponse,
)


class FilesResourceWithStreamingResponse:
Expand All @@ -543,6 +647,10 @@ def __init__(self, files: FilesResource) -> None:
self.list = to_streamed_response_wrapper(
files.list,
)
self.contents = to_custom_streamed_response_wrapper(
files.contents,
StreamedBinaryAPIResponse,
)


class AsyncFilesResourceWithStreamingResponse:
Expand All @@ -558,3 +666,7 @@ def __init__(self, files: AsyncFilesResource) -> None:
self.list = async_to_streamed_response_wrapper(
files.list,
)
self.contents = async_to_custom_streamed_response_wrapper(
files.contents,
AsyncStreamedBinaryAPIResponse,
)
9 changes: 3 additions & 6 deletions src/increase/types/beneficial_owner_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,12 @@ class IndividualAddress(TypedDict, total=False):
city: Required[str]
"""The city, district, town, or village of the address."""

country: Required[str]
"""The two-letter ISO 3166-1 alpha-2 code for the country of the address."""

line1: Required[str]
"""The first line of the address. This is usually the street number and street."""

country: str
"""The two-letter ISO 3166-1 alpha-2 code for the country of the address.

Defaults to `US`.
"""

line2: str
"""The second line of the address. This might be the floor or room number."""

Expand Down
9 changes: 3 additions & 6 deletions src/increase/types/beneficial_owner_update_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,12 @@ class Address(TypedDict, total=False):
city: Required[str]
"""The city, district, town, or village of the address."""

country: Required[str]
"""The two-letter ISO 3166-1 alpha-2 code for the country of the address."""

line1: Required[str]
"""The first line of the address. This is usually the street number and street."""

country: str
"""The two-letter ISO 3166-1 alpha-2 code for the country of the address.

Defaults to `US`.
"""

line2: str
"""The second line of the address. This might be the floor or room number."""

Expand Down
Loading
Loading