diff --git a/poetry.lock b/poetry.lock index 2bbd0c2..6d676cf 100644 --- a/poetry.lock +++ b/poetry.lock @@ -236,13 +236,13 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "pydantic" -version = "2.7.3" +version = "2.7.4" description = "Data validation using Python type hints" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic-2.7.3-py3-none-any.whl", hash = "sha256:ea91b002777bf643bb20dd717c028ec43216b24a6001a280f83877fd2655d0b4"}, - {file = "pydantic-2.7.3.tar.gz", hash = "sha256:c46c76a40bb1296728d7a8b99aa73dd70a48c3510111ff290034f860c99c419e"}, + {file = "pydantic-2.7.4-py3-none-any.whl", hash = "sha256:ee8538d41ccb9c0a9ad3e0e5f07bf15ed8015b481ced539a1759d8cc89ae90d0"}, + {file = "pydantic-2.7.4.tar.gz", hash = "sha256:0c84efd9548d545f63ac0060c1e4d39bb9b14db8b3c0652338aecc07b5adec52"}, ] [package.dependencies] diff --git a/pyproject.toml b/pyproject.toml index a1d1700..39c6762 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "schematichq" -version = "1.0.2" +version = "1.0.3" description = "" readme = "README.md" authors = [] diff --git a/src/schematic/__init__.py b/src/schematic/__init__.py index 9cafb84..0f38149 100644 --- a/src/schematic/__init__.py +++ b/src/schematic/__init__.py @@ -13,6 +13,7 @@ CheckFlagRequestBody, CheckFlagResponseData, CheckFlagsResponseData, + CompanyCrmDealsResponseData, CompanyDetailResponseData, CompanyMembershipDetailResponseData, CompanyMembershipResponseData, @@ -35,6 +36,11 @@ CreateReqCommon, CreateReqCommonMetricPeriod, CreateReqCommonValueType, + CrmDealLineItem, + CrmDealResponseData, + CrmLineItemResponseData, + CrmProductResponseData, + Decimal, DeleteResponse, EntityKeyDefinitionResponseData, EntityKeyDetailResponseData, @@ -92,11 +98,12 @@ UpsertUserSubRequestBody, UserDetailResponseData, UserResponseData, + WebhookEventDetailResponseData, WebhookEventResponseData, WebhookResponseData, ) from .errors import BadRequestError, ForbiddenError, InternalServerError, NotFoundError, UnauthorizedError -from . import accounts, billing, companies, entitlements, events, features, plans, webhooks +from . import accounts, billing, companies, crm, entitlements, events, features, plans, webhooks from .accounts import ( CountApiKeysParams, CountApiKeysResponse, @@ -147,6 +154,8 @@ DeleteUserResponse, GetActiveCompanySubscriptionParams, GetActiveCompanySubscriptionResponse, + GetActiveDealsParams, + GetActiveDealsResponse, GetCompanyResponse, GetEntityTraitDefinitionResponse, GetEntityTraitValuesParams, @@ -177,6 +186,14 @@ UpsertUserResponse, UpsertUserTraitResponse, ) +from .crm import ( + ListCrmProductsParams, + ListCrmProductsResponse, + UpsertCrmDealResponse, + UpsertCrmProductResponse, + UpsertDealLineItemAssociationResponse, + UpsertLineItemResponse, +) from .entitlements import ( CountCompanyOverridesParams, CountCompanyOverridesResponse, @@ -315,6 +332,7 @@ "CheckFlagResponseData", "CheckFlagsResponse", "CheckFlagsResponseData", + "CompanyCrmDealsResponseData", "CompanyDetailResponseData", "CompanyMembershipDetailResponseData", "CompanyMembershipResponseData", @@ -394,6 +412,11 @@ "CreateReqCommonValueType", "CreateUserResponse", "CreateWebhookResponse", + "CrmDealLineItem", + "CrmDealResponseData", + "CrmLineItemResponseData", + "CrmProductResponseData", + "Decimal", "DeleteApiKeyResponse", "DeleteAudienceResponse", "DeleteCompanyByKeysResponse", @@ -438,6 +461,8 @@ "ForbiddenError", "GetActiveCompanySubscriptionParams", "GetActiveCompanySubscriptionResponse", + "GetActiveDealsParams", + "GetActiveDealsResponse", "GetApiKeyResponse", "GetApiRequestResponse", "GetAudienceResponse", @@ -482,6 +507,8 @@ "ListCompanyOverridesResponse", "ListCompanyPlansParams", "ListCompanyPlansResponse", + "ListCrmProductsParams", + "ListCrmProductsResponse", "ListEntityKeyDefinitionsParams", "ListEntityKeyDefinitionsResponse", "ListEntityTraitDefinitionsParams", @@ -573,6 +600,10 @@ "UpsertCompanyRequestBody", "UpsertCompanyResponse", "UpsertCompanyTraitResponse", + "UpsertCrmDealResponse", + "UpsertCrmProductResponse", + "UpsertDealLineItemAssociationResponse", + "UpsertLineItemResponse", "UpsertTraitRequestBody", "UpsertUserRequestBody", "UpsertUserResponse", @@ -580,12 +611,14 @@ "UpsertUserTraitResponse", "UserDetailResponseData", "UserResponseData", + "WebhookEventDetailResponseData", "WebhookEventResponseData", "WebhookResponseData", "__version__", "accounts", "billing", "companies", + "crm", "entitlements", "events", "features", diff --git a/src/schematic/base_client.py b/src/schematic/base_client.py index e8f43bb..99febf5 100644 --- a/src/schematic/base_client.py +++ b/src/schematic/base_client.py @@ -8,6 +8,7 @@ from .billing.client import AsyncBillingClient, BillingClient from .companies.client import AsyncCompaniesClient, CompaniesClient from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from .crm.client import AsyncCrmClient, CrmClient from .entitlements.client import AsyncEntitlementsClient, EntitlementsClient from .environment import SchematicEnvironment from .events.client import AsyncEventsClient, EventsClient @@ -79,6 +80,7 @@ def __init__( self.billing = BillingClient(client_wrapper=self._client_wrapper) self.companies = CompaniesClient(client_wrapper=self._client_wrapper) self.entitlements = EntitlementsClient(client_wrapper=self._client_wrapper) + self.crm = CrmClient(client_wrapper=self._client_wrapper) self.events = EventsClient(client_wrapper=self._client_wrapper) self.plans = PlansClient(client_wrapper=self._client_wrapper) self.webhooks = WebhooksClient(client_wrapper=self._client_wrapper) @@ -147,6 +149,7 @@ def __init__( self.billing = AsyncBillingClient(client_wrapper=self._client_wrapper) self.companies = AsyncCompaniesClient(client_wrapper=self._client_wrapper) self.entitlements = AsyncEntitlementsClient(client_wrapper=self._client_wrapper) + self.crm = AsyncCrmClient(client_wrapper=self._client_wrapper) self.events = AsyncEventsClient(client_wrapper=self._client_wrapper) self.plans = AsyncPlansClient(client_wrapper=self._client_wrapper) self.webhooks = AsyncWebhooksClient(client_wrapper=self._client_wrapper) diff --git a/src/schematic/companies/__init__.py b/src/schematic/companies/__init__.py index 0c15699..f9edb63 100644 --- a/src/schematic/companies/__init__.py +++ b/src/schematic/companies/__init__.py @@ -20,6 +20,8 @@ DeleteUserResponse, GetActiveCompanySubscriptionParams, GetActiveCompanySubscriptionResponse, + GetActiveDealsParams, + GetActiveDealsResponse, GetCompanyResponse, GetEntityTraitDefinitionResponse, GetEntityTraitValuesParams, @@ -71,6 +73,8 @@ "DeleteUserResponse", "GetActiveCompanySubscriptionParams", "GetActiveCompanySubscriptionResponse", + "GetActiveDealsParams", + "GetActiveDealsResponse", "GetCompanyResponse", "GetEntityTraitDefinitionResponse", "GetEntityTraitValuesParams", diff --git a/src/schematic/companies/client.py b/src/schematic/companies/client.py index 0bdeae8..86d50d9 100644 --- a/src/schematic/companies/client.py +++ b/src/schematic/companies/client.py @@ -36,6 +36,7 @@ from .types.delete_user_by_keys_response import DeleteUserByKeysResponse from .types.delete_user_response import DeleteUserResponse from .types.get_active_company_subscription_response import GetActiveCompanySubscriptionResponse +from .types.get_active_deals_response import GetActiveDealsResponse from .types.get_company_response import GetCompanyResponse from .types.get_entity_trait_definition_response import GetEntityTraitDefinitionResponse from .types.get_entity_trait_values_response import GetEntityTraitValuesResponse @@ -782,6 +783,102 @@ def lookup_company( raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + def get_active_deals( + self, + *, + company_id: str, + deal_stage: str, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetActiveDealsResponse: + """ + Parameters + ---------- + company_id : str + + deal_stage : str + + limit : typing.Optional[int] + Page limit (default 100) + + offset : typing.Optional[int] + Page offset (default 0) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetActiveDealsResponse + OK + + Examples + -------- + from schematic.client import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.companies.get_active_deals( + company_id="company_id", + deal_stage="deal_stage", + ) + """ + _response = self._client_wrapper.httpx_client.request( + method="GET", + url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-crm-deals"), + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "company_id": company_id, + "deal_stage": deal_stage, + "limit": limit, + "offset": offset, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) + ) + ), + headers=jsonable_encoder( + remove_none_from_dict( + { + **self._client_wrapper.get_headers(), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + timeout=request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self._client_wrapper.get_timeout(), + retries=0, + max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + ) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(GetActiveDealsResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + def list_company_memberships( self, *, @@ -3609,6 +3706,102 @@ async def lookup_company( raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + async def get_active_deals( + self, + *, + company_id: str, + deal_stage: str, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> GetActiveDealsResponse: + """ + Parameters + ---------- + company_id : str + + deal_stage : str + + limit : typing.Optional[int] + Page limit (default 100) + + offset : typing.Optional[int] + Page offset (default 0) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + GetActiveDealsResponse + OK + + Examples + -------- + from schematic.client import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + await client.companies.get_active_deals( + company_id="company_id", + deal_stage="deal_stage", + ) + """ + _response = await self._client_wrapper.httpx_client.request( + method="GET", + url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "company-crm-deals"), + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "company_id": company_id, + "deal_stage": deal_stage, + "limit": limit, + "offset": offset, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) + ) + ), + headers=jsonable_encoder( + remove_none_from_dict( + { + **self._client_wrapper.get_headers(), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + timeout=request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self._client_wrapper.get_timeout(), + retries=0, + max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + ) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(GetActiveDealsResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + async def list_company_memberships( self, *, diff --git a/src/schematic/companies/types/__init__.py b/src/schematic/companies/types/__init__.py index a9e2537..a4cb073 100644 --- a/src/schematic/companies/types/__init__.py +++ b/src/schematic/companies/types/__init__.py @@ -19,6 +19,8 @@ from .delete_user_response import DeleteUserResponse from .get_active_company_subscription_params import GetActiveCompanySubscriptionParams from .get_active_company_subscription_response import GetActiveCompanySubscriptionResponse +from .get_active_deals_params import GetActiveDealsParams +from .get_active_deals_response import GetActiveDealsResponse from .get_company_response import GetCompanyResponse from .get_entity_trait_definition_response import GetEntityTraitDefinitionResponse from .get_entity_trait_values_params import GetEntityTraitValuesParams @@ -69,6 +71,8 @@ "DeleteUserResponse", "GetActiveCompanySubscriptionParams", "GetActiveCompanySubscriptionResponse", + "GetActiveDealsParams", + "GetActiveDealsResponse", "GetCompanyResponse", "GetEntityTraitDefinitionResponse", "GetEntityTraitValuesParams", diff --git a/src/schematic/companies/types/get_active_deals_params.py b/src/schematic/companies/types/get_active_deals_params.py new file mode 100644 index 0000000..28f8702 --- /dev/null +++ b/src/schematic/companies/types/get_active_deals_params.py @@ -0,0 +1,36 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 + + +class GetActiveDealsParams(pydantic_v1.BaseModel): + """ + Input parameters + """ + + company_id: typing.Optional[str] = None + deal_stage: typing.Optional[str] = None + limit: typing.Optional[int] = None + offset: typing.Optional[int] = None + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/companies/types/get_active_deals_response.py b/src/schematic/companies/types/get_active_deals_response.py new file mode 100644 index 0000000..f9bd1e2 --- /dev/null +++ b/src/schematic/companies/types/get_active_deals_response.py @@ -0,0 +1,39 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...types.company_crm_deals_response_data import CompanyCrmDealsResponseData +from .get_active_deals_params import GetActiveDealsParams + + +class GetActiveDealsResponse(pydantic_v1.BaseModel): + data: typing.List[CompanyCrmDealsResponseData] = pydantic_v1.Field() + """ + The returned resources + """ + + params: GetActiveDealsParams = pydantic_v1.Field() + """ + Input parameters + """ + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/core/client_wrapper.py b/src/schematic/core/client_wrapper.py index 727624e..adcdbcd 100644 --- a/src/schematic/core/client_wrapper.py +++ b/src/schematic/core/client_wrapper.py @@ -17,7 +17,7 @@ def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", "X-Fern-SDK-Name": "schematichq", - "X-Fern-SDK-Version": "1.0.2", + "X-Fern-SDK-Version": "1.0.3", } headers["X-Schematic-Api-Key"] = self.api_key return headers diff --git a/src/schematic/crm/__init__.py b/src/schematic/crm/__init__.py new file mode 100644 index 0000000..99a0869 --- /dev/null +++ b/src/schematic/crm/__init__.py @@ -0,0 +1,19 @@ +# This file was auto-generated by Fern from our API Definition. + +from .types import ( + ListCrmProductsParams, + ListCrmProductsResponse, + UpsertCrmDealResponse, + UpsertCrmProductResponse, + UpsertDealLineItemAssociationResponse, + UpsertLineItemResponse, +) + +__all__ = [ + "ListCrmProductsParams", + "ListCrmProductsResponse", + "UpsertCrmDealResponse", + "UpsertCrmProductResponse", + "UpsertDealLineItemAssociationResponse", + "UpsertLineItemResponse", +] diff --git a/src/schematic/crm/client.py b/src/schematic/crm/client.py new file mode 100644 index 0000000..95e72bc --- /dev/null +++ b/src/schematic/crm/client.py @@ -0,0 +1,1124 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +import urllib.parse +from json.decoder import JSONDecodeError + +from ..core.api_error import ApiError as core_api_error_ApiError +from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ..core.jsonable_encoder import jsonable_encoder +from ..core.pydantic_utilities import pydantic_v1 +from ..core.query_encoder import encode_query +from ..core.remove_none_from_dict import remove_none_from_dict +from ..core.request_options import RequestOptions +from ..errors.bad_request_error import BadRequestError +from ..errors.forbidden_error import ForbiddenError +from ..errors.internal_server_error import InternalServerError +from ..errors.unauthorized_error import UnauthorizedError +from ..types.api_error import ApiError as types_api_error_ApiError +from .types.list_crm_products_response import ListCrmProductsResponse +from .types.upsert_crm_deal_response import UpsertCrmDealResponse +from .types.upsert_crm_product_response import UpsertCrmProductResponse +from .types.upsert_deal_line_item_association_response import UpsertDealLineItemAssociationResponse +from .types.upsert_line_item_response import UpsertLineItemResponse + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class CrmClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def upsert_deal_line_item_association( + self, + *, + deal_external_id: str, + line_item_external_id: str, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpsertDealLineItemAssociationResponse: + """ + Parameters + ---------- + deal_external_id : str + + line_item_external_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpsertDealLineItemAssociationResponse + Created + + Examples + -------- + from schematic.client import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.crm.upsert_deal_line_item_association( + deal_external_id="deal_external_id", + line_item_external_id="line_item_external_id", + ) + """ + _response = self._client_wrapper.httpx_client.request( + method="POST", + url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/associations/deal-line-item"), + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) + ), + json=jsonable_encoder( + {"deal_external_id": deal_external_id, "line_item_external_id": line_item_external_id} + ) + if request_options is None or request_options.get("additional_body_parameters") is None + else { + **jsonable_encoder( + {"deal_external_id": deal_external_id, "line_item_external_id": line_item_external_id} + ), + **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + }, + headers=jsonable_encoder( + remove_none_from_dict( + { + **self._client_wrapper.get_headers(), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + timeout=request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self._client_wrapper.get_timeout(), + retries=0, + max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + ) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(UpsertDealLineItemAssociationResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + + def upsert_line_item( + self, + *, + amount: str, + interval: str, + line_item_external_id: str, + product_external_id: str, + quantity: int, + term_month: typing.Optional[int] = OMIT, + discount_percentage: typing.Optional[str] = OMIT, + total_discount: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpsertLineItemResponse: + """ + Parameters + ---------- + amount : str + + interval : str + + line_item_external_id : str + + product_external_id : str + + quantity : int + + term_month : typing.Optional[int] + + discount_percentage : typing.Optional[str] + + total_discount : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpsertLineItemResponse + Created + + Examples + -------- + from schematic.client import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.crm.upsert_line_item( + amount="amount", + interval="interval", + line_item_external_id="line_item_external_id", + product_external_id="product_external_id", + quantity=1, + ) + """ + _request: typing.Dict[str, typing.Any] = { + "amount": amount, + "interval": interval, + "line_item_external_id": line_item_external_id, + "product_external_id": product_external_id, + "quantity": quantity, + } + if term_month is not OMIT: + _request["TermMonth"] = term_month + if discount_percentage is not OMIT: + _request["discount_percentage"] = discount_percentage + if total_discount is not OMIT: + _request["total_discount"] = total_discount + _response = self._client_wrapper.httpx_client.request( + method="POST", + url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/deal-line-item/upsert"), + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) + ), + json=jsonable_encoder(_request) + if request_options is None or request_options.get("additional_body_parameters") is None + else { + **jsonable_encoder(_request), + **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + }, + headers=jsonable_encoder( + remove_none_from_dict( + { + **self._client_wrapper.get_headers(), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + timeout=request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self._client_wrapper.get_timeout(), + retries=0, + max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + ) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(UpsertLineItemResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + + def upsert_crm_deal( + self, + *, + crm_company_key: str, + crm_type: str, + deal_external_id: str, + arr: typing.Optional[str] = OMIT, + crm_company_id: typing.Optional[str] = OMIT, + crm_product_id: typing.Optional[str] = OMIT, + deal_name: typing.Optional[str] = OMIT, + deal_stage: typing.Optional[str] = OMIT, + mrr: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpsertCrmDealResponse: + """ + Parameters + ---------- + crm_company_key : str + + crm_type : str + + deal_external_id : str + + arr : typing.Optional[str] + + crm_company_id : typing.Optional[str] + + crm_product_id : typing.Optional[str] + + deal_name : typing.Optional[str] + + deal_stage : typing.Optional[str] + + mrr : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpsertCrmDealResponse + Created + + Examples + -------- + from schematic.client import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.crm.upsert_crm_deal( + crm_company_key="crm_company_key", + crm_type="crm_type", + deal_external_id="deal_external_id", + ) + """ + _request: typing.Dict[str, typing.Any] = { + "crm_company_key": crm_company_key, + "crm_type": crm_type, + "deal_external_id": deal_external_id, + } + if arr is not OMIT: + _request["arr"] = arr + if crm_company_id is not OMIT: + _request["crm_company_id"] = crm_company_id + if crm_product_id is not OMIT: + _request["crm_product_id"] = crm_product_id + if deal_name is not OMIT: + _request["deal_name"] = deal_name + if deal_stage is not OMIT: + _request["deal_stage"] = deal_stage + if mrr is not OMIT: + _request["mrr"] = mrr + _response = self._client_wrapper.httpx_client.request( + method="POST", + url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/deals/upsert"), + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) + ), + json=jsonable_encoder(_request) + if request_options is None or request_options.get("additional_body_parameters") is None + else { + **jsonable_encoder(_request), + **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + }, + headers=jsonable_encoder( + remove_none_from_dict( + { + **self._client_wrapper.get_headers(), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + timeout=request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self._client_wrapper.get_timeout(), + retries=0, + max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + ) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(UpsertCrmDealResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + + def list_crm_products( + self, + *, + ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + name: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> ListCrmProductsResponse: + """ + Parameters + ---------- + ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + + name : typing.Optional[str] + + limit : typing.Optional[int] + Page limit (default 100) + + offset : typing.Optional[int] + Page offset (default 0) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ListCrmProductsResponse + OK + + Examples + -------- + from schematic.client import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.crm.list_crm_products() + """ + _response = self._client_wrapper.httpx_client.request( + method="GET", + url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/products"), + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "ids": ids, + "name": name, + "limit": limit, + "offset": offset, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) + ) + ), + headers=jsonable_encoder( + remove_none_from_dict( + { + **self._client_wrapper.get_headers(), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + timeout=request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self._client_wrapper.get_timeout(), + retries=0, + max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + ) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ListCrmProductsResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + + def upsert_crm_product( + self, + *, + currency: str, + description: str, + external_id: str, + interval: str, + name: str, + price: str, + quantity: int, + sku: str, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpsertCrmProductResponse: + """ + Parameters + ---------- + currency : str + + description : str + + external_id : str + + interval : str + + name : str + + price : str + + quantity : int + + sku : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpsertCrmProductResponse + Created + + Examples + -------- + from schematic.client import Schematic + + client = Schematic( + api_key="YOUR_API_KEY", + ) + client.crm.upsert_crm_product( + currency="currency", + description="description", + external_id="external_id", + interval="interval", + name="name", + price="price", + quantity=1, + sku="sku", + ) + """ + _response = self._client_wrapper.httpx_client.request( + method="POST", + url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/products/upsert"), + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) + ), + json=jsonable_encoder( + { + "currency": currency, + "description": description, + "external_id": external_id, + "interval": interval, + "name": name, + "price": price, + "quantity": quantity, + "sku": sku, + } + ) + if request_options is None or request_options.get("additional_body_parameters") is None + else { + **jsonable_encoder( + { + "currency": currency, + "description": description, + "external_id": external_id, + "interval": interval, + "name": name, + "price": price, + "quantity": quantity, + "sku": sku, + } + ), + **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + }, + headers=jsonable_encoder( + remove_none_from_dict( + { + **self._client_wrapper.get_headers(), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + timeout=request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self._client_wrapper.get_timeout(), + retries=0, + max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + ) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(UpsertCrmProductResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + + +class AsyncCrmClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def upsert_deal_line_item_association( + self, + *, + deal_external_id: str, + line_item_external_id: str, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpsertDealLineItemAssociationResponse: + """ + Parameters + ---------- + deal_external_id : str + + line_item_external_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpsertDealLineItemAssociationResponse + Created + + Examples + -------- + from schematic.client import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + await client.crm.upsert_deal_line_item_association( + deal_external_id="deal_external_id", + line_item_external_id="line_item_external_id", + ) + """ + _response = await self._client_wrapper.httpx_client.request( + method="POST", + url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/associations/deal-line-item"), + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) + ), + json=jsonable_encoder( + {"deal_external_id": deal_external_id, "line_item_external_id": line_item_external_id} + ) + if request_options is None or request_options.get("additional_body_parameters") is None + else { + **jsonable_encoder( + {"deal_external_id": deal_external_id, "line_item_external_id": line_item_external_id} + ), + **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + }, + headers=jsonable_encoder( + remove_none_from_dict( + { + **self._client_wrapper.get_headers(), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + timeout=request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self._client_wrapper.get_timeout(), + retries=0, + max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + ) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(UpsertDealLineItemAssociationResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + + async def upsert_line_item( + self, + *, + amount: str, + interval: str, + line_item_external_id: str, + product_external_id: str, + quantity: int, + term_month: typing.Optional[int] = OMIT, + discount_percentage: typing.Optional[str] = OMIT, + total_discount: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpsertLineItemResponse: + """ + Parameters + ---------- + amount : str + + interval : str + + line_item_external_id : str + + product_external_id : str + + quantity : int + + term_month : typing.Optional[int] + + discount_percentage : typing.Optional[str] + + total_discount : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpsertLineItemResponse + Created + + Examples + -------- + from schematic.client import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + await client.crm.upsert_line_item( + amount="amount", + interval="interval", + line_item_external_id="line_item_external_id", + product_external_id="product_external_id", + quantity=1, + ) + """ + _request: typing.Dict[str, typing.Any] = { + "amount": amount, + "interval": interval, + "line_item_external_id": line_item_external_id, + "product_external_id": product_external_id, + "quantity": quantity, + } + if term_month is not OMIT: + _request["TermMonth"] = term_month + if discount_percentage is not OMIT: + _request["discount_percentage"] = discount_percentage + if total_discount is not OMIT: + _request["total_discount"] = total_discount + _response = await self._client_wrapper.httpx_client.request( + method="POST", + url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/deal-line-item/upsert"), + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) + ), + json=jsonable_encoder(_request) + if request_options is None or request_options.get("additional_body_parameters") is None + else { + **jsonable_encoder(_request), + **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + }, + headers=jsonable_encoder( + remove_none_from_dict( + { + **self._client_wrapper.get_headers(), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + timeout=request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self._client_wrapper.get_timeout(), + retries=0, + max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + ) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(UpsertLineItemResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + + async def upsert_crm_deal( + self, + *, + crm_company_key: str, + crm_type: str, + deal_external_id: str, + arr: typing.Optional[str] = OMIT, + crm_company_id: typing.Optional[str] = OMIT, + crm_product_id: typing.Optional[str] = OMIT, + deal_name: typing.Optional[str] = OMIT, + deal_stage: typing.Optional[str] = OMIT, + mrr: typing.Optional[str] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpsertCrmDealResponse: + """ + Parameters + ---------- + crm_company_key : str + + crm_type : str + + deal_external_id : str + + arr : typing.Optional[str] + + crm_company_id : typing.Optional[str] + + crm_product_id : typing.Optional[str] + + deal_name : typing.Optional[str] + + deal_stage : typing.Optional[str] + + mrr : typing.Optional[str] + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpsertCrmDealResponse + Created + + Examples + -------- + from schematic.client import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + await client.crm.upsert_crm_deal( + crm_company_key="crm_company_key", + crm_type="crm_type", + deal_external_id="deal_external_id", + ) + """ + _request: typing.Dict[str, typing.Any] = { + "crm_company_key": crm_company_key, + "crm_type": crm_type, + "deal_external_id": deal_external_id, + } + if arr is not OMIT: + _request["arr"] = arr + if crm_company_id is not OMIT: + _request["crm_company_id"] = crm_company_id + if crm_product_id is not OMIT: + _request["crm_product_id"] = crm_product_id + if deal_name is not OMIT: + _request["deal_name"] = deal_name + if deal_stage is not OMIT: + _request["deal_stage"] = deal_stage + if mrr is not OMIT: + _request["mrr"] = mrr + _response = await self._client_wrapper.httpx_client.request( + method="POST", + url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/deals/upsert"), + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) + ), + json=jsonable_encoder(_request) + if request_options is None or request_options.get("additional_body_parameters") is None + else { + **jsonable_encoder(_request), + **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + }, + headers=jsonable_encoder( + remove_none_from_dict( + { + **self._client_wrapper.get_headers(), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + timeout=request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self._client_wrapper.get_timeout(), + retries=0, + max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + ) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(UpsertCrmDealResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + + async def list_crm_products( + self, + *, + ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + name: typing.Optional[str] = None, + limit: typing.Optional[int] = None, + offset: typing.Optional[int] = None, + request_options: typing.Optional[RequestOptions] = None, + ) -> ListCrmProductsResponse: + """ + Parameters + ---------- + ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + + name : typing.Optional[str] + + limit : typing.Optional[int] + Page limit (default 100) + + offset : typing.Optional[int] + Page offset (default 0) + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + ListCrmProductsResponse + OK + + Examples + -------- + from schematic.client import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + await client.crm.list_crm_products() + """ + _response = await self._client_wrapper.httpx_client.request( + method="GET", + url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/products"), + params=encode_query( + jsonable_encoder( + remove_none_from_dict( + { + "ids": ids, + "name": name, + "limit": limit, + "offset": offset, + **( + request_options.get("additional_query_parameters", {}) + if request_options is not None + else {} + ), + } + ) + ) + ), + headers=jsonable_encoder( + remove_none_from_dict( + { + **self._client_wrapper.get_headers(), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + timeout=request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self._client_wrapper.get_timeout(), + retries=0, + max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + ) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(ListCrmProductsResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) + + async def upsert_crm_product( + self, + *, + currency: str, + description: str, + external_id: str, + interval: str, + name: str, + price: str, + quantity: int, + sku: str, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpsertCrmProductResponse: + """ + Parameters + ---------- + currency : str + + description : str + + external_id : str + + interval : str + + name : str + + price : str + + quantity : int + + sku : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpsertCrmProductResponse + Created + + Examples + -------- + from schematic.client import AsyncSchematic + + client = AsyncSchematic( + api_key="YOUR_API_KEY", + ) + await client.crm.upsert_crm_product( + currency="currency", + description="description", + external_id="external_id", + interval="interval", + name="name", + price="price", + quantity=1, + sku="sku", + ) + """ + _response = await self._client_wrapper.httpx_client.request( + method="POST", + url=urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "crm/products/upsert"), + params=encode_query( + jsonable_encoder( + request_options.get("additional_query_parameters") if request_options is not None else None + ) + ), + json=jsonable_encoder( + { + "currency": currency, + "description": description, + "external_id": external_id, + "interval": interval, + "name": name, + "price": price, + "quantity": quantity, + "sku": sku, + } + ) + if request_options is None or request_options.get("additional_body_parameters") is None + else { + **jsonable_encoder( + { + "currency": currency, + "description": description, + "external_id": external_id, + "interval": interval, + "name": name, + "price": price, + "quantity": quantity, + "sku": sku, + } + ), + **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))), + }, + headers=jsonable_encoder( + remove_none_from_dict( + { + **self._client_wrapper.get_headers(), + **(request_options.get("additional_headers", {}) if request_options is not None else {}), + } + ) + ), + timeout=request_options.get("timeout_in_seconds") + if request_options is not None and request_options.get("timeout_in_seconds") is not None + else self._client_wrapper.get_timeout(), + retries=0, + max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore + ) + if 200 <= _response.status_code < 300: + return pydantic_v1.parse_obj_as(UpsertCrmProductResponse, _response.json()) # type: ignore + if _response.status_code == 400: + raise BadRequestError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 401: + raise UnauthorizedError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + if _response.status_code == 403: + raise ForbiddenError(pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json())) # type: ignore + if _response.status_code == 500: + raise InternalServerError( + pydantic_v1.parse_obj_as(types_api_error_ApiError, _response.json()) # type: ignore + ) + try: + _response_json = _response.json() + except JSONDecodeError: + raise core_api_error_ApiError(status_code=_response.status_code, body=_response.text) + raise core_api_error_ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/schematic/crm/types/__init__.py b/src/schematic/crm/types/__init__.py new file mode 100644 index 0000000..36374d4 --- /dev/null +++ b/src/schematic/crm/types/__init__.py @@ -0,0 +1,17 @@ +# This file was auto-generated by Fern from our API Definition. + +from .list_crm_products_params import ListCrmProductsParams +from .list_crm_products_response import ListCrmProductsResponse +from .upsert_crm_deal_response import UpsertCrmDealResponse +from .upsert_crm_product_response import UpsertCrmProductResponse +from .upsert_deal_line_item_association_response import UpsertDealLineItemAssociationResponse +from .upsert_line_item_response import UpsertLineItemResponse + +__all__ = [ + "ListCrmProductsParams", + "ListCrmProductsResponse", + "UpsertCrmDealResponse", + "UpsertCrmProductResponse", + "UpsertDealLineItemAssociationResponse", + "UpsertLineItemResponse", +] diff --git a/src/schematic/crm/types/list_crm_products_params.py b/src/schematic/crm/types/list_crm_products_params.py new file mode 100644 index 0000000..c465634 --- /dev/null +++ b/src/schematic/crm/types/list_crm_products_params.py @@ -0,0 +1,36 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 + + +class ListCrmProductsParams(pydantic_v1.BaseModel): + """ + Input parameters + """ + + ids: typing.Optional[typing.List[str]] = None + limit: typing.Optional[int] = None + name: typing.Optional[str] = None + offset: typing.Optional[int] = None + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/crm/types/list_crm_products_response.py b/src/schematic/crm/types/list_crm_products_response.py new file mode 100644 index 0000000..df0e9a0 --- /dev/null +++ b/src/schematic/crm/types/list_crm_products_response.py @@ -0,0 +1,39 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...types.crm_product_response_data import CrmProductResponseData +from .list_crm_products_params import ListCrmProductsParams + + +class ListCrmProductsResponse(pydantic_v1.BaseModel): + data: typing.List[CrmProductResponseData] = pydantic_v1.Field() + """ + The returned resources + """ + + params: ListCrmProductsParams = pydantic_v1.Field() + """ + Input parameters + """ + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/crm/types/upsert_crm_deal_response.py b/src/schematic/crm/types/upsert_crm_deal_response.py new file mode 100644 index 0000000..54a66de --- /dev/null +++ b/src/schematic/crm/types/upsert_crm_deal_response.py @@ -0,0 +1,34 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...types.crm_deal_response_data import CrmDealResponseData + + +class UpsertCrmDealResponse(pydantic_v1.BaseModel): + data: CrmDealResponseData + params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + """ + Input parameters + """ + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/crm/types/upsert_crm_product_response.py b/src/schematic/crm/types/upsert_crm_product_response.py new file mode 100644 index 0000000..3e785f1 --- /dev/null +++ b/src/schematic/crm/types/upsert_crm_product_response.py @@ -0,0 +1,34 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...types.crm_product_response_data import CrmProductResponseData + + +class UpsertCrmProductResponse(pydantic_v1.BaseModel): + data: CrmProductResponseData + params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + """ + Input parameters + """ + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/crm/types/upsert_deal_line_item_association_response.py b/src/schematic/crm/types/upsert_deal_line_item_association_response.py new file mode 100644 index 0000000..c6ef6ca --- /dev/null +++ b/src/schematic/crm/types/upsert_deal_line_item_association_response.py @@ -0,0 +1,34 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...types.crm_line_item_response_data import CrmLineItemResponseData + + +class UpsertDealLineItemAssociationResponse(pydantic_v1.BaseModel): + data: CrmLineItemResponseData + params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + """ + Input parameters + """ + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/crm/types/upsert_line_item_response.py b/src/schematic/crm/types/upsert_line_item_response.py new file mode 100644 index 0000000..16a35b0 --- /dev/null +++ b/src/schematic/crm/types/upsert_line_item_response.py @@ -0,0 +1,34 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ...core.datetime_utils import serialize_datetime +from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from ...types.crm_line_item_response_data import CrmLineItemResponseData + + +class UpsertLineItemResponse(pydantic_v1.BaseModel): + data: CrmLineItemResponseData + params: typing.Dict[str, typing.Any] = pydantic_v1.Field() + """ + Input parameters + """ + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/types/__init__.py b/src/schematic/types/__init__.py index a12fd95..a8da277 100644 --- a/src/schematic/types/__init__.py +++ b/src/schematic/types/__init__.py @@ -12,6 +12,7 @@ from .check_flag_request_body import CheckFlagRequestBody from .check_flag_response_data import CheckFlagResponseData from .check_flags_response_data import CheckFlagsResponseData +from .company_crm_deals_response_data import CompanyCrmDealsResponseData from .company_detail_response_data import CompanyDetailResponseData from .company_membership_detail_response_data import CompanyMembershipDetailResponseData from .company_membership_response_data import CompanyMembershipResponseData @@ -34,6 +35,11 @@ from .create_req_common import CreateReqCommon from .create_req_common_metric_period import CreateReqCommonMetricPeriod from .create_req_common_value_type import CreateReqCommonValueType +from .crm_deal_line_item import CrmDealLineItem +from .crm_deal_response_data import CrmDealResponseData +from .crm_line_item_response_data import CrmLineItemResponseData +from .crm_product_response_data import CrmProductResponseData +from .decimal import Decimal from .delete_response import DeleteResponse from .entity_key_definition_response_data import EntityKeyDefinitionResponseData from .entity_key_detail_response_data import EntityKeyDetailResponseData @@ -91,6 +97,7 @@ from .upsert_user_sub_request_body import UpsertUserSubRequestBody from .user_detail_response_data import UserDetailResponseData from .user_response_data import UserResponseData +from .webhook_event_detail_response_data import WebhookEventDetailResponseData from .webhook_event_response_data import WebhookEventResponseData from .webhook_response_data import WebhookResponseData @@ -107,6 +114,7 @@ "CheckFlagRequestBody", "CheckFlagResponseData", "CheckFlagsResponseData", + "CompanyCrmDealsResponseData", "CompanyDetailResponseData", "CompanyMembershipDetailResponseData", "CompanyMembershipResponseData", @@ -129,6 +137,11 @@ "CreateReqCommon", "CreateReqCommonMetricPeriod", "CreateReqCommonValueType", + "CrmDealLineItem", + "CrmDealResponseData", + "CrmLineItemResponseData", + "CrmProductResponseData", + "Decimal", "DeleteResponse", "EntityKeyDefinitionResponseData", "EntityKeyDetailResponseData", @@ -186,6 +199,7 @@ "UpsertUserSubRequestBody", "UserDetailResponseData", "UserResponseData", + "WebhookEventDetailResponseData", "WebhookEventResponseData", "WebhookResponseData", ] diff --git a/src/schematic/types/company_crm_deals_response_data.py b/src/schematic/types/company_crm_deals_response_data.py new file mode 100644 index 0000000..70c4ca7 --- /dev/null +++ b/src/schematic/types/company_crm_deals_response_data.py @@ -0,0 +1,34 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .crm_deal_line_item import CrmDealLineItem + + +class CompanyCrmDealsResponseData(pydantic_v1.BaseModel): + deal_arr: str + deal_external_id: str + deal_mrr: str + deal_name: typing.Optional[str] = None + line_items: typing.List[CrmDealLineItem] + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/types/create_or_update_condition_request_body_condition_type.py b/src/schematic/types/create_or_update_condition_request_body_condition_type.py index e727b14..852a7f3 100644 --- a/src/schematic/types/create_or_update_condition_request_body_condition_type.py +++ b/src/schematic/types/create_or_update_condition_request_body_condition_type.py @@ -3,5 +3,5 @@ import typing CreateOrUpdateConditionRequestBodyConditionType = typing.Union[ - typing.Literal["company", "metric", "trait", "user", "plan", "billing_product"], typing.Any + typing.Literal["company", "metric", "trait", "user", "plan", "billing_product", "crm_product"], typing.Any ] diff --git a/src/schematic/types/crm_deal_line_item.py b/src/schematic/types/crm_deal_line_item.py new file mode 100644 index 0000000..dcfc00e --- /dev/null +++ b/src/schematic/types/crm_deal_line_item.py @@ -0,0 +1,42 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .decimal import Decimal + + +class CrmDealLineItem(pydantic_v1.BaseModel): + billing_frequency: str + created_at: dt.datetime + currency: str + deleted_at: typing.Optional[dt.datetime] = None + description: str + discount_percentage: typing.Optional[Decimal] = None + id: str + name: str + price: float + quantity: int + term_month: typing.Optional[int] = None + total_discount: typing.Optional[Decimal] = None + updated_at: dt.datetime + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/types/crm_deal_response_data.py b/src/schematic/types/crm_deal_response_data.py new file mode 100644 index 0000000..3bccef4 --- /dev/null +++ b/src/schematic/types/crm_deal_response_data.py @@ -0,0 +1,44 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 + + +class CrmDealResponseData(pydantic_v1.BaseModel): + """ + The created resource + """ + + account_id: str + arr: str + company_external_id: typing.Optional[str] = None + created_at: dt.datetime + deal_external_id: str + deal_id: str + deleted_at: typing.Optional[dt.datetime] = None + environment_id: str + mrr: str + name: typing.Optional[str] = None + product_external_id: typing.Optional[str] = None + updated_at: dt.datetime + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/types/crm_line_item_response_data.py b/src/schematic/types/crm_line_item_response_data.py new file mode 100644 index 0000000..d455b3f --- /dev/null +++ b/src/schematic/types/crm_line_item_response_data.py @@ -0,0 +1,39 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 + + +class CrmLineItemResponseData(pydantic_v1.BaseModel): + """ + The created resource + """ + + account_id: str + created_at: dt.datetime + deal_id: typing.Optional[str] = None + deleted_at: typing.Optional[dt.datetime] = None + environment_id: str + product_external_id: typing.Optional[str] = None + updated_at: dt.datetime + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/types/crm_product_response_data.py b/src/schematic/types/crm_product_response_data.py new file mode 100644 index 0000000..2ccc4ad --- /dev/null +++ b/src/schematic/types/crm_product_response_data.py @@ -0,0 +1,43 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 + + +class CrmProductResponseData(pydantic_v1.BaseModel): + """ + The created resource + """ + + account_id: str + created_at: dt.datetime + currency: str + deleted_at: typing.Optional[dt.datetime] = None + environment_id: str + external_id: str + name: str + price: str + product_id: str + quantity: float + updated_at: dt.datetime + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/types/decimal.py b/src/schematic/types/decimal.py new file mode 100644 index 0000000..b290d5b --- /dev/null +++ b/src/schematic/types/decimal.py @@ -0,0 +1,5 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +Decimal = typing.Dict[str, typing.Any] diff --git a/src/schematic/types/webhook_event_detail_response_data.py b/src/schematic/types/webhook_event_detail_response_data.py new file mode 100644 index 0000000..473b30e --- /dev/null +++ b/src/schematic/types/webhook_event_detail_response_data.py @@ -0,0 +1,38 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +from ..core.datetime_utils import serialize_datetime +from ..core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 +from .webhook_response_data import WebhookResponseData + + +class WebhookEventDetailResponseData(pydantic_v1.BaseModel): + created_at: dt.datetime + id: str + request_type: str + response_code: typing.Optional[int] = None + sent_at: typing.Optional[dt.datetime] = None + status: str + updated_at: dt.datetime + webhook: typing.Optional[WebhookResponseData] = None + webhook_id: str + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs} + + return deep_union_pydantic_dicts( + super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none) + ) + + class Config: + frozen = True + smart_union = True + extra = pydantic_v1.Extra.allow + json_encoders = {dt.datetime: serialize_datetime} diff --git a/src/schematic/types/webhook_response_data.py b/src/schematic/types/webhook_response_data.py index 8b59b64..eec7364 100644 --- a/src/schematic/types/webhook_response_data.py +++ b/src/schematic/types/webhook_response_data.py @@ -8,10 +8,6 @@ class WebhookResponseData(pydantic_v1.BaseModel): - """ - The updated resource - """ - created_at: dt.datetime id: str name: str diff --git a/src/schematic/webhooks/client.py b/src/schematic/webhooks/client.py index 820efab..dd4018e 100644 --- a/src/schematic/webhooks/client.py +++ b/src/schematic/webhooks/client.py @@ -38,6 +38,9 @@ def __init__(self, *, client_wrapper: SyncClientWrapper): def list_webhook_events( self, *, + webhook_id: typing.Optional[str] = None, + ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + q: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, @@ -45,6 +48,12 @@ def list_webhook_events( """ Parameters ---------- + webhook_id : typing.Optional[str] + + ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + + q : typing.Optional[str] + limit : typing.Optional[int] Page limit (default 100) @@ -75,6 +84,9 @@ def list_webhook_events( jsonable_encoder( remove_none_from_dict( { + "webhook_id": webhook_id, + "ids": ids, + "q": q, "limit": limit, "offset": offset, **( @@ -195,6 +207,9 @@ def get_webhook_event( def count_webhook_events( self, *, + webhook_id: typing.Optional[str] = None, + ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + q: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, @@ -202,6 +217,12 @@ def count_webhook_events( """ Parameters ---------- + webhook_id : typing.Optional[str] + + ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + + q : typing.Optional[str] + limit : typing.Optional[int] Page limit (default 100) @@ -232,6 +253,9 @@ def count_webhook_events( jsonable_encoder( remove_none_from_dict( { + "webhook_id": webhook_id, + "ids": ids, + "q": q, "limit": limit, "offset": offset, **( @@ -792,6 +816,9 @@ def __init__(self, *, client_wrapper: AsyncClientWrapper): async def list_webhook_events( self, *, + webhook_id: typing.Optional[str] = None, + ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + q: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, @@ -799,6 +826,12 @@ async def list_webhook_events( """ Parameters ---------- + webhook_id : typing.Optional[str] + + ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + + q : typing.Optional[str] + limit : typing.Optional[int] Page limit (default 100) @@ -829,6 +862,9 @@ async def list_webhook_events( jsonable_encoder( remove_none_from_dict( { + "webhook_id": webhook_id, + "ids": ids, + "q": q, "limit": limit, "offset": offset, **( @@ -949,6 +985,9 @@ async def get_webhook_event( async def count_webhook_events( self, *, + webhook_id: typing.Optional[str] = None, + ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None, + q: typing.Optional[str] = None, limit: typing.Optional[int] = None, offset: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None, @@ -956,6 +995,12 @@ async def count_webhook_events( """ Parameters ---------- + webhook_id : typing.Optional[str] + + ids : typing.Optional[typing.Union[str, typing.Sequence[str]]] + + q : typing.Optional[str] + limit : typing.Optional[int] Page limit (default 100) @@ -986,6 +1031,9 @@ async def count_webhook_events( jsonable_encoder( remove_none_from_dict( { + "webhook_id": webhook_id, + "ids": ids, + "q": q, "limit": limit, "offset": offset, **( diff --git a/src/schematic/webhooks/types/count_webhook_events_params.py b/src/schematic/webhooks/types/count_webhook_events_params.py index 495d543..97710cb 100644 --- a/src/schematic/webhooks/types/count_webhook_events_params.py +++ b/src/schematic/webhooks/types/count_webhook_events_params.py @@ -12,8 +12,11 @@ class CountWebhookEventsParams(pydantic_v1.BaseModel): Input parameters """ + ids: typing.Optional[typing.List[str]] = None limit: typing.Optional[int] = None offset: typing.Optional[int] = None + q: typing.Optional[str] = None + webhook_id: typing.Optional[str] = None def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} diff --git a/src/schematic/webhooks/types/get_webhook_event_response.py b/src/schematic/webhooks/types/get_webhook_event_response.py index 1dc97e7..bd6d750 100644 --- a/src/schematic/webhooks/types/get_webhook_event_response.py +++ b/src/schematic/webhooks/types/get_webhook_event_response.py @@ -5,11 +5,11 @@ from ...core.datetime_utils import serialize_datetime from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from ...types.webhook_event_response_data import WebhookEventResponseData +from ...types.webhook_event_detail_response_data import WebhookEventDetailResponseData class GetWebhookEventResponse(pydantic_v1.BaseModel): - data: WebhookEventResponseData + data: WebhookEventDetailResponseData params: typing.Dict[str, typing.Any] = pydantic_v1.Field() """ Input parameters diff --git a/src/schematic/webhooks/types/list_webhook_events_params.py b/src/schematic/webhooks/types/list_webhook_events_params.py index 45add9b..80891e9 100644 --- a/src/schematic/webhooks/types/list_webhook_events_params.py +++ b/src/schematic/webhooks/types/list_webhook_events_params.py @@ -12,8 +12,11 @@ class ListWebhookEventsParams(pydantic_v1.BaseModel): Input parameters """ + ids: typing.Optional[typing.List[str]] = None limit: typing.Optional[int] = None offset: typing.Optional[int] = None + q: typing.Optional[str] = None + webhook_id: typing.Optional[str] = None def json(self, **kwargs: typing.Any) -> str: kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} diff --git a/src/schematic/webhooks/types/list_webhook_events_response.py b/src/schematic/webhooks/types/list_webhook_events_response.py index 8f35fe7..43e4acb 100644 --- a/src/schematic/webhooks/types/list_webhook_events_response.py +++ b/src/schematic/webhooks/types/list_webhook_events_response.py @@ -5,12 +5,12 @@ from ...core.datetime_utils import serialize_datetime from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1 -from ...types.webhook_event_response_data import WebhookEventResponseData +from ...types.webhook_event_detail_response_data import WebhookEventDetailResponseData from .list_webhook_events_params import ListWebhookEventsParams class ListWebhookEventsResponse(pydantic_v1.BaseModel): - data: typing.List[WebhookEventResponseData] = pydantic_v1.Field() + data: typing.List[WebhookEventDetailResponseData] = pydantic_v1.Field() """ The returned resources """