From 7b057fc74eff394abb6386e1748ce09d5e132f68 Mon Sep 17 00:00:00 2001 From: stainless-bot Date: Wed, 26 Jun 2024 15:13:39 +0000 Subject: [PATCH] feat(api): update via SDK Studio --- .stats.yml | 2 +- api.md | 1 + .../resources/contacts/companies.py | 135 ++++++++++++++++++ .../types/contacts/__init__.py | 1 + .../contacts/contact_attached_companies.py | 47 ++++++ .../api_resources/contacts/test_companies.py | 93 ++++++++++++ 6 files changed, 278 insertions(+), 1 deletion(-) create mode 100644 src/python_minus_intercom/types/contacts/contact_attached_companies.py diff --git a/.stats.yml b/.stats.yml index efeff6c4..14c5e154 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 107 +configured_endpoints: 108 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/intercom%2Fintercom-a202b2b4aa0e356eb61376a3bf484132be2e9e3bff3796e1fe4606ab2a3734fd.yml diff --git a/api.md b/api.md index 61f2d96a..66db5e53 100644 --- a/api.md +++ b/api.md @@ -198,6 +198,7 @@ from python_minus_intercom.types.contacts import ContactAttachedCompanies Methods: - client.contacts.companies.create(contact_id, \*\*params) -> Company +- client.contacts.companies.list(contact_id) -> ContactAttachedCompanies - client.contacts.companies.delete(id, \*, contact_id) -> Company ## Notes diff --git a/src/python_minus_intercom/resources/contacts/companies.py b/src/python_minus_intercom/resources/contacts/companies.py index cd3968f4..88345404 100644 --- a/src/python_minus_intercom/resources/contacts/companies.py +++ b/src/python_minus_intercom/resources/contacts/companies.py @@ -26,6 +26,7 @@ ) from ...types.contacts import company_create_params from ...types.shared.company import Company +from ...types.contacts.contact_attached_companies import ContactAttachedCompanies __all__ = ["CompaniesResource", "AsyncCompaniesResource"] @@ -104,6 +105,67 @@ def create( cast_to=Company, ) + def list( + self, + contact_id: str, + *, + intercom_version: Literal[ + "1.0", + "1.1", + "1.2", + "1.3", + "1.4", + "2.0", + "2.1", + "2.2", + "2.3", + "2.4", + "2.5", + "2.6", + "2.7", + "2.8", + "2.9", + "2.10", + "2.11", + "Unstable", + ] + | NotGiven = NOT_GIVEN, + # 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, + ) -> ContactAttachedCompanies: + """ + You can fetch a list of companies that are associated to a contact. + + Args: + intercom_version: Intercom API version.By default, it's equal to the version set in the app + package. + + 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 contact_id: + raise ValueError(f"Expected a non-empty value for `contact_id` but received {contact_id!r}") + extra_headers = { + **strip_not_given({"Intercom-Version": str(intercom_version) if is_given(intercom_version) else NOT_GIVEN}), + **(extra_headers or {}), + } + return self._get( + f"/contacts/{contact_id}/companies", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ContactAttachedCompanies, + ) + def delete( self, id: str, @@ -243,6 +305,67 @@ async def create( cast_to=Company, ) + async def list( + self, + contact_id: str, + *, + intercom_version: Literal[ + "1.0", + "1.1", + "1.2", + "1.3", + "1.4", + "2.0", + "2.1", + "2.2", + "2.3", + "2.4", + "2.5", + "2.6", + "2.7", + "2.8", + "2.9", + "2.10", + "2.11", + "Unstable", + ] + | NotGiven = NOT_GIVEN, + # 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, + ) -> ContactAttachedCompanies: + """ + You can fetch a list of companies that are associated to a contact. + + Args: + intercom_version: Intercom API version.By default, it's equal to the version set in the app + package. + + 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 contact_id: + raise ValueError(f"Expected a non-empty value for `contact_id` but received {contact_id!r}") + extra_headers = { + **strip_not_given({"Intercom-Version": str(intercom_version) if is_given(intercom_version) else NOT_GIVEN}), + **(extra_headers or {}), + } + return await self._get( + f"/contacts/{contact_id}/companies", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=ContactAttachedCompanies, + ) + async def delete( self, id: str, @@ -315,6 +438,9 @@ def __init__(self, companies: CompaniesResource) -> None: self.create = to_raw_response_wrapper( companies.create, ) + self.list = to_raw_response_wrapper( + companies.list, + ) self.delete = to_raw_response_wrapper( companies.delete, ) @@ -327,6 +453,9 @@ def __init__(self, companies: AsyncCompaniesResource) -> None: self.create = async_to_raw_response_wrapper( companies.create, ) + self.list = async_to_raw_response_wrapper( + companies.list, + ) self.delete = async_to_raw_response_wrapper( companies.delete, ) @@ -339,6 +468,9 @@ def __init__(self, companies: CompaniesResource) -> None: self.create = to_streamed_response_wrapper( companies.create, ) + self.list = to_streamed_response_wrapper( + companies.list, + ) self.delete = to_streamed_response_wrapper( companies.delete, ) @@ -351,6 +483,9 @@ def __init__(self, companies: AsyncCompaniesResource) -> None: self.create = async_to_streamed_response_wrapper( companies.create, ) + self.list = async_to_streamed_response_wrapper( + companies.list, + ) self.delete = async_to_streamed_response_wrapper( companies.delete, ) diff --git a/src/python_minus_intercom/types/contacts/__init__.py b/src/python_minus_intercom/types/contacts/__init__.py index 503a73d1..e6eb9d80 100644 --- a/src/python_minus_intercom/types/contacts/__init__.py +++ b/src/python_minus_intercom/types/contacts/__init__.py @@ -8,4 +8,5 @@ from .tag_create_params import TagCreateParams as TagCreateParams from .note_create_params import NoteCreateParams as NoteCreateParams from .company_create_params import CompanyCreateParams as CompanyCreateParams +from .contact_attached_companies import ContactAttachedCompanies as ContactAttachedCompanies from .subscription_create_params import SubscriptionCreateParams as SubscriptionCreateParams diff --git a/src/python_minus_intercom/types/contacts/contact_attached_companies.py b/src/python_minus_intercom/types/contacts/contact_attached_companies.py new file mode 100644 index 00000000..b8252496 --- /dev/null +++ b/src/python_minus_intercom/types/contacts/contact_attached_companies.py @@ -0,0 +1,47 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing import List, Optional +from typing_extensions import Literal + +from ..._models import BaseModel +from ..shared.company import Company + +__all__ = ["ContactAttachedCompanies", "Pages"] + + +class Pages(BaseModel): + next: Optional[str] = None + """A link to the next page of results. + + A response that does not contain a next link does not have further data to + fetch. + """ + + page: Optional[int] = None + + per_page: Optional[int] = None + + total_pages: Optional[int] = None + + type: Optional[Literal["pages"]] = None + + +class ContactAttachedCompanies(BaseModel): + companies: Optional[List[Company]] = None + """An array containing Company Objects""" + + pages: Optional[Pages] = None + """ + The majority of list resources in the API are paginated to allow clients to + traverse data over multiple requests. + + Their responses are likely to contain a pages object that hosts pagination links + which a client can use to paginate through the data without having to construct + a query. The link relations for the pages field are as follows. + """ + + total_count: Optional[int] = None + """The total number of companies associated to this contact""" + + type: Optional[Literal["list"]] = None + """The type of object""" diff --git a/tests/api_resources/contacts/test_companies.py b/tests/api_resources/contacts/test_companies.py index 1e229ddb..8ae26936 100644 --- a/tests/api_resources/contacts/test_companies.py +++ b/tests/api_resources/contacts/test_companies.py @@ -10,6 +10,7 @@ from tests.utils import assert_matches_type from python_minus_intercom import Intercom, AsyncIntercom from python_minus_intercom.types.shared import Company +from python_minus_intercom.types.contacts import ContactAttachedCompanies base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") @@ -68,6 +69,52 @@ def test_path_params_create(self, client: Intercom) -> None: company_id="6657add46abd0167d9419cd2", ) + @parametrize + def test_method_list(self, client: Intercom) -> None: + company = client.contacts.companies.list( + "string", + ) + assert_matches_type(ContactAttachedCompanies, company, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: Intercom) -> None: + company = client.contacts.companies.list( + "string", + intercom_version="2.11", + ) + assert_matches_type(ContactAttachedCompanies, company, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: Intercom) -> None: + response = client.contacts.companies.with_raw_response.list( + "string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + company = response.parse() + assert_matches_type(ContactAttachedCompanies, company, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: Intercom) -> None: + with client.contacts.companies.with_streaming_response.list( + "string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + company = response.parse() + assert_matches_type(ContactAttachedCompanies, company, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_list(self, client: Intercom) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `contact_id` but received ''"): + client.contacts.companies.with_raw_response.list( + "", + ) + @parametrize def test_method_delete(self, client: Intercom) -> None: company = client.contacts.companies.delete( @@ -180,6 +227,52 @@ async def test_path_params_create(self, async_client: AsyncIntercom) -> None: company_id="6657add46abd0167d9419cd2", ) + @parametrize + async def test_method_list(self, async_client: AsyncIntercom) -> None: + company = await async_client.contacts.companies.list( + "string", + ) + assert_matches_type(ContactAttachedCompanies, company, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncIntercom) -> None: + company = await async_client.contacts.companies.list( + "string", + intercom_version="2.11", + ) + assert_matches_type(ContactAttachedCompanies, company, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncIntercom) -> None: + response = await async_client.contacts.companies.with_raw_response.list( + "string", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + company = await response.parse() + assert_matches_type(ContactAttachedCompanies, company, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncIntercom) -> None: + async with async_client.contacts.companies.with_streaming_response.list( + "string", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + company = await response.parse() + assert_matches_type(ContactAttachedCompanies, company, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, async_client: AsyncIntercom) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `contact_id` but received ''"): + await async_client.contacts.companies.with_raw_response.list( + "", + ) + @parametrize async def test_method_delete(self, async_client: AsyncIntercom) -> None: company = await async_client.contacts.companies.delete(