Skip to content

Commit 7b057fc

Browse files
committed
feat(api): update via SDK Studio
1 parent c3013f2 commit 7b057fc

File tree

6 files changed

+278
-1
lines changed

6 files changed

+278
-1
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 107
1+
configured_endpoints: 108
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/intercom%2Fintercom-a202b2b4aa0e356eb61376a3bf484132be2e9e3bff3796e1fe4606ab2a3734fd.yml

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ from python_minus_intercom.types.contacts import ContactAttachedCompanies
198198
Methods:
199199

200200
- <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>
201+
- <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>
201202
- <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>
202203

203204
## Notes

src/python_minus_intercom/resources/contacts/companies.py

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
)
2727
from ...types.contacts import company_create_params
2828
from ...types.shared.company import Company
29+
from ...types.contacts.contact_attached_companies import ContactAttachedCompanies
2930

3031
__all__ = ["CompaniesResource", "AsyncCompaniesResource"]
3132

@@ -104,6 +105,67 @@ def create(
104105
cast_to=Company,
105106
)
106107

108+
def list(
109+
self,
110+
contact_id: str,
111+
*,
112+
intercom_version: Literal[
113+
"1.0",
114+
"1.1",
115+
"1.2",
116+
"1.3",
117+
"1.4",
118+
"2.0",
119+
"2.1",
120+
"2.2",
121+
"2.3",
122+
"2.4",
123+
"2.5",
124+
"2.6",
125+
"2.7",
126+
"2.8",
127+
"2.9",
128+
"2.10",
129+
"2.11",
130+
"Unstable",
131+
]
132+
| NotGiven = NOT_GIVEN,
133+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
134+
# The extra values given here take precedence over values defined on the client or passed to this method.
135+
extra_headers: Headers | None = None,
136+
extra_query: Query | None = None,
137+
extra_body: Body | None = None,
138+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
139+
) -> ContactAttachedCompanies:
140+
"""
141+
You can fetch a list of companies that are associated to a contact.
142+
143+
Args:
144+
intercom_version: Intercom API version.By default, it's equal to the version set in the app
145+
package.
146+
147+
extra_headers: Send extra headers
148+
149+
extra_query: Add additional query parameters to the request
150+
151+
extra_body: Add additional JSON properties to the request
152+
153+
timeout: Override the client-level default timeout for this request, in seconds
154+
"""
155+
if not contact_id:
156+
raise ValueError(f"Expected a non-empty value for `contact_id` but received {contact_id!r}")
157+
extra_headers = {
158+
**strip_not_given({"Intercom-Version": str(intercom_version) if is_given(intercom_version) else NOT_GIVEN}),
159+
**(extra_headers or {}),
160+
}
161+
return self._get(
162+
f"/contacts/{contact_id}/companies",
163+
options=make_request_options(
164+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
165+
),
166+
cast_to=ContactAttachedCompanies,
167+
)
168+
107169
def delete(
108170
self,
109171
id: str,
@@ -243,6 +305,67 @@ async def create(
243305
cast_to=Company,
244306
)
245307

308+
async def list(
309+
self,
310+
contact_id: str,
311+
*,
312+
intercom_version: Literal[
313+
"1.0",
314+
"1.1",
315+
"1.2",
316+
"1.3",
317+
"1.4",
318+
"2.0",
319+
"2.1",
320+
"2.2",
321+
"2.3",
322+
"2.4",
323+
"2.5",
324+
"2.6",
325+
"2.7",
326+
"2.8",
327+
"2.9",
328+
"2.10",
329+
"2.11",
330+
"Unstable",
331+
]
332+
| NotGiven = NOT_GIVEN,
333+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
334+
# The extra values given here take precedence over values defined on the client or passed to this method.
335+
extra_headers: Headers | None = None,
336+
extra_query: Query | None = None,
337+
extra_body: Body | None = None,
338+
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
339+
) -> ContactAttachedCompanies:
340+
"""
341+
You can fetch a list of companies that are associated to a contact.
342+
343+
Args:
344+
intercom_version: Intercom API version.By default, it's equal to the version set in the app
345+
package.
346+
347+
extra_headers: Send extra headers
348+
349+
extra_query: Add additional query parameters to the request
350+
351+
extra_body: Add additional JSON properties to the request
352+
353+
timeout: Override the client-level default timeout for this request, in seconds
354+
"""
355+
if not contact_id:
356+
raise ValueError(f"Expected a non-empty value for `contact_id` but received {contact_id!r}")
357+
extra_headers = {
358+
**strip_not_given({"Intercom-Version": str(intercom_version) if is_given(intercom_version) else NOT_GIVEN}),
359+
**(extra_headers or {}),
360+
}
361+
return await self._get(
362+
f"/contacts/{contact_id}/companies",
363+
options=make_request_options(
364+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
365+
),
366+
cast_to=ContactAttachedCompanies,
367+
)
368+
246369
async def delete(
247370
self,
248371
id: str,
@@ -315,6 +438,9 @@ def __init__(self, companies: CompaniesResource) -> None:
315438
self.create = to_raw_response_wrapper(
316439
companies.create,
317440
)
441+
self.list = to_raw_response_wrapper(
442+
companies.list,
443+
)
318444
self.delete = to_raw_response_wrapper(
319445
companies.delete,
320446
)
@@ -327,6 +453,9 @@ def __init__(self, companies: AsyncCompaniesResource) -> None:
327453
self.create = async_to_raw_response_wrapper(
328454
companies.create,
329455
)
456+
self.list = async_to_raw_response_wrapper(
457+
companies.list,
458+
)
330459
self.delete = async_to_raw_response_wrapper(
331460
companies.delete,
332461
)
@@ -339,6 +468,9 @@ def __init__(self, companies: CompaniesResource) -> None:
339468
self.create = to_streamed_response_wrapper(
340469
companies.create,
341470
)
471+
self.list = to_streamed_response_wrapper(
472+
companies.list,
473+
)
342474
self.delete = to_streamed_response_wrapper(
343475
companies.delete,
344476
)
@@ -351,6 +483,9 @@ def __init__(self, companies: AsyncCompaniesResource) -> None:
351483
self.create = async_to_streamed_response_wrapper(
352484
companies.create,
353485
)
486+
self.list = async_to_streamed_response_wrapper(
487+
companies.list,
488+
)
354489
self.delete = async_to_streamed_response_wrapper(
355490
companies.delete,
356491
)

src/python_minus_intercom/types/contacts/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
from .tag_create_params import TagCreateParams as TagCreateParams
99
from .note_create_params import NoteCreateParams as NoteCreateParams
1010
from .company_create_params import CompanyCreateParams as CompanyCreateParams
11+
from .contact_attached_companies import ContactAttachedCompanies as ContactAttachedCompanies
1112
from .subscription_create_params import SubscriptionCreateParams as SubscriptionCreateParams
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import List, Optional
4+
from typing_extensions import Literal
5+
6+
from ..._models import BaseModel
7+
from ..shared.company import Company
8+
9+
__all__ = ["ContactAttachedCompanies", "Pages"]
10+
11+
12+
class Pages(BaseModel):
13+
next: Optional[str] = None
14+
"""A link to the next page of results.
15+
16+
A response that does not contain a next link does not have further data to
17+
fetch.
18+
"""
19+
20+
page: Optional[int] = None
21+
22+
per_page: Optional[int] = None
23+
24+
total_pages: Optional[int] = None
25+
26+
type: Optional[Literal["pages"]] = None
27+
28+
29+
class ContactAttachedCompanies(BaseModel):
30+
companies: Optional[List[Company]] = None
31+
"""An array containing Company Objects"""
32+
33+
pages: Optional[Pages] = None
34+
"""
35+
The majority of list resources in the API are paginated to allow clients to
36+
traverse data over multiple requests.
37+
38+
Their responses are likely to contain a pages object that hosts pagination links
39+
which a client can use to paginate through the data without having to construct
40+
a query. The link relations for the pages field are as follows.
41+
"""
42+
43+
total_count: Optional[int] = None
44+
"""The total number of companies associated to this contact"""
45+
46+
type: Optional[Literal["list"]] = None
47+
"""The type of object"""

tests/api_resources/contacts/test_companies.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from tests.utils import assert_matches_type
1111
from python_minus_intercom import Intercom, AsyncIntercom
1212
from python_minus_intercom.types.shared import Company
13+
from python_minus_intercom.types.contacts import ContactAttachedCompanies
1314

1415
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
1516

@@ -68,6 +69,52 @@ def test_path_params_create(self, client: Intercom) -> None:
6869
company_id="6657add46abd0167d9419cd2",
6970
)
7071

72+
@parametrize
73+
def test_method_list(self, client: Intercom) -> None:
74+
company = client.contacts.companies.list(
75+
"string",
76+
)
77+
assert_matches_type(ContactAttachedCompanies, company, path=["response"])
78+
79+
@parametrize
80+
def test_method_list_with_all_params(self, client: Intercom) -> None:
81+
company = client.contacts.companies.list(
82+
"string",
83+
intercom_version="2.11",
84+
)
85+
assert_matches_type(ContactAttachedCompanies, company, path=["response"])
86+
87+
@parametrize
88+
def test_raw_response_list(self, client: Intercom) -> None:
89+
response = client.contacts.companies.with_raw_response.list(
90+
"string",
91+
)
92+
93+
assert response.is_closed is True
94+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
95+
company = response.parse()
96+
assert_matches_type(ContactAttachedCompanies, company, path=["response"])
97+
98+
@parametrize
99+
def test_streaming_response_list(self, client: Intercom) -> None:
100+
with client.contacts.companies.with_streaming_response.list(
101+
"string",
102+
) as response:
103+
assert not response.is_closed
104+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
105+
106+
company = response.parse()
107+
assert_matches_type(ContactAttachedCompanies, company, path=["response"])
108+
109+
assert cast(Any, response.is_closed) is True
110+
111+
@parametrize
112+
def test_path_params_list(self, client: Intercom) -> None:
113+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `contact_id` but received ''"):
114+
client.contacts.companies.with_raw_response.list(
115+
"",
116+
)
117+
71118
@parametrize
72119
def test_method_delete(self, client: Intercom) -> None:
73120
company = client.contacts.companies.delete(
@@ -180,6 +227,52 @@ async def test_path_params_create(self, async_client: AsyncIntercom) -> None:
180227
company_id="6657add46abd0167d9419cd2",
181228
)
182229

230+
@parametrize
231+
async def test_method_list(self, async_client: AsyncIntercom) -> None:
232+
company = await async_client.contacts.companies.list(
233+
"string",
234+
)
235+
assert_matches_type(ContactAttachedCompanies, company, path=["response"])
236+
237+
@parametrize
238+
async def test_method_list_with_all_params(self, async_client: AsyncIntercom) -> None:
239+
company = await async_client.contacts.companies.list(
240+
"string",
241+
intercom_version="2.11",
242+
)
243+
assert_matches_type(ContactAttachedCompanies, company, path=["response"])
244+
245+
@parametrize
246+
async def test_raw_response_list(self, async_client: AsyncIntercom) -> None:
247+
response = await async_client.contacts.companies.with_raw_response.list(
248+
"string",
249+
)
250+
251+
assert response.is_closed is True
252+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
253+
company = await response.parse()
254+
assert_matches_type(ContactAttachedCompanies, company, path=["response"])
255+
256+
@parametrize
257+
async def test_streaming_response_list(self, async_client: AsyncIntercom) -> None:
258+
async with async_client.contacts.companies.with_streaming_response.list(
259+
"string",
260+
) as response:
261+
assert not response.is_closed
262+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
263+
264+
company = await response.parse()
265+
assert_matches_type(ContactAttachedCompanies, company, path=["response"])
266+
267+
assert cast(Any, response.is_closed) is True
268+
269+
@parametrize
270+
async def test_path_params_list(self, async_client: AsyncIntercom) -> None:
271+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `contact_id` but received ''"):
272+
await async_client.contacts.companies.with_raw_response.list(
273+
"",
274+
)
275+
183276
@parametrize
184277
async def test_method_delete(self, async_client: AsyncIntercom) -> None:
185278
company = await async_client.contacts.companies.delete(

0 commit comments

Comments
 (0)