Skip to content

Commit

Permalink
feat(api): update via SDK Studio
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Jun 26, 2024
1 parent c3013f2 commit 7b057fc
Show file tree
Hide file tree
Showing 6 changed files with 278 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ from python_minus_intercom.types.contacts import ContactAttachedCompanies
Methods:

- <code title="post /contacts/{contact_id}/companies">client.contacts.companies.<a href="./src/python_minus_intercom/resources/contacts/companies.py">create</a>(contact_id, \*\*<a href="src/python_minus_intercom/types/contacts/company_create_params.py">params</a>) -> <a href="./src/python_minus_intercom/types/shared/company.py">Company</a></code>
- <code title="get /contacts/{contact_id}/companies">client.contacts.companies.<a href="./src/python_minus_intercom/resources/contacts/companies.py">list</a>(contact_id) -> <a href="./src/python_minus_intercom/types/contacts/contact_attached_companies.py">ContactAttachedCompanies</a></code>
- <code title="delete /contacts/{contact_id}/companies/{id}">client.contacts.companies.<a href="./src/python_minus_intercom/resources/contacts/companies.py">delete</a>(id, \*, contact_id) -> <a href="./src/python_minus_intercom/types/shared/company.py">Company</a></code>

## Notes
Expand Down
135 changes: 135 additions & 0 deletions src/python_minus_intercom/resources/contacts/companies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
)
Expand All @@ -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,
)
Expand All @@ -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,
)
Expand All @@ -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,
)
1 change: 1 addition & 0 deletions src/python_minus_intercom/types/contacts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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"""
93 changes: 93 additions & 0 deletions tests/api_resources/contacts/test_companies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 7b057fc

Please sign in to comment.