diff --git a/openapi/openapi.json b/openapi/openapi.json index 3a62f38..e5cb67b 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -7711,6 +7711,155 @@ "bearerAuth": [] } ] + }, + "post": { + "tags": [ + "deals" + ], + "summary": "Create Public Deal Pipeline", + "operationId": "create_public_deal_pipeline_api_v2_public_deals_pipelines_post", + "parameters": [ + { + "name": "workspace_id", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Workspace Id" + } + }, + { + "$ref": "#/components/parameters/XWorkspaceCode" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DealPipelineCreateRequest" + } + } + } + }, + "responses": { + "201": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreatePublicDealPipelineApiV2PublicDealsPipelinesPost201Envelope" + } + } + }, + "headers": { + "x-ctx-id": { + "$ref": "#/components/headers/XCtxId" + } + } + }, + "422": { + "$ref": "#/components/responses/ErrorResponse" + }, + "401": { + "$ref": "#/components/responses/ErrorResponse" + } + }, + "x-sanka-surface": "public_developer", + "x-sanka-api-version": "v2", + "x-sanka-auth": "developer_bearer", + "security": [ + { + "bearerAuth": [] + } + ] + } + }, + "/v2/public/deals/pipelines/{pipeline_id}": { + "patch": { + "tags": [ + "deals" + ], + "summary": "Update Public Deal Pipeline", + "operationId": "update_public_deal_pipeline_api_v2_public_deals_pipelines__pipeline_id__patch", + "parameters": [ + { + "name": "pipeline_id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "title": "Pipeline Id" + } + }, + { + "name": "workspace_id", + "in": "query", + "required": false, + "schema": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Workspace Id" + } + }, + { + "$ref": "#/components/parameters/XWorkspaceCode" + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DealPipelineUpdateRequest" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdatePublicDealPipelineApiV2PublicDealsPipelinesPipelineIdPatch200Envelope" + } + } + }, + "headers": { + "x-ctx-id": { + "$ref": "#/components/headers/XCtxId" + } + } + }, + "422": { + "$ref": "#/components/responses/ErrorResponse" + }, + "401": { + "$ref": "#/components/responses/ErrorResponse" + } + }, + "x-sanka-surface": "public_developer", + "x-sanka-api-version": "v2", + "x-sanka-auth": "developer_bearer", + "security": [ + { + "bearerAuth": [] + } + ] } }, "/v2/public/deals/{deal_id}": { @@ -38992,6 +39141,26 @@ } } }, + "CreatePublicDealPipelineApiV2PublicDealsPipelinesPost201Envelope": { + "type": "object", + "required": [ + "success", + "data", + "meta" + ], + "properties": { + "success": { + "type": "boolean", + "const": true + }, + "data": { + "$ref": "#/components/schemas/DealPipelineData" + }, + "meta": { + "$ref": "#/components/schemas/EnvelopeMeta" + } + } + }, "CreatePublicDeveloperPropertyApiV2PublicPropertiesObjectNamePost200Envelope": { "type": "object", "required": [ @@ -48829,6 +48998,26 @@ } } }, + "UpdatePublicDealPipelineApiV2PublicDealsPipelinesPipelineIdPatch200Envelope": { + "type": "object", + "required": [ + "success", + "data", + "meta" + ], + "properties": { + "success": { + "type": "boolean", + "const": true + }, + "data": { + "$ref": "#/components/schemas/DealPipelineData" + }, + "meta": { + "$ref": "#/components/schemas/EnvelopeMeta" + } + } + }, "UpdatePublicDeveloperPropertyApiV2PublicPropertiesObjectNamePropertyRefPut200Envelope": { "type": "object", "required": [ @@ -50235,6 +50424,46 @@ "type": "object", "title": "AssociationEdgeMutationData" }, + "DealPipelineData": { + "properties": { + "id": { + "type": "string", + "title": "Id" + }, + "name": { + "type": "string", + "title": "Name" + }, + "internal_name": { + "type": "string", + "title": "Internal Name" + }, + "is_default": { + "type": "boolean", + "title": "Is Default", + "default": false + }, + "order": { + "type": "integer", + "title": "Order", + "default": 0 + }, + "stages": { + "items": { + "$ref": "#/components/schemas/DealPipelineStageData" + }, + "type": "array", + "title": "Stages" + } + }, + "type": "object", + "required": [ + "id", + "name", + "internal_name" + ], + "title": "DealPipelineData" + }, "FerryDiagramData": { "properties": { "name": { @@ -53012,6 +53241,49 @@ ], "title": "AssociationEdge" }, + "DealPipelineStageData": { + "properties": { + "id": { + "type": "string", + "title": "Id" + }, + "name": { + "type": "string", + "title": "Name" + }, + "internal_value": { + "type": "string", + "title": "Internal Value" + }, + "score": { + "type": "integer", + "title": "Score", + "default": 0 + }, + "order": { + "type": "integer", + "title": "Order", + "default": 0 + }, + "is_default": { + "type": "boolean", + "title": "Is Default", + "default": false + }, + "is_hidden": { + "type": "boolean", + "title": "Is Hidden", + "default": false + } + }, + "type": "object", + "required": [ + "id", + "name", + "internal_value" + ], + "title": "DealPipelineStageData" + }, "FerryProgramEndpoint": { "properties": { "id": { @@ -55816,6 +56088,90 @@ } } }, + "DealPipelineCreateRequest": { + "properties": { + "name": { + "type": "string", + "maxLength": 200, + "minLength": 1, + "title": "Name" + }, + "is_default": { + "type": "boolean", + "title": "Is Default", + "description": "Make this the workspace's default Deal pipeline.", + "default": false + }, + "stages": { + "items": { + "$ref": "#/components/schemas/DealPipelineStageCreate" + }, + "type": "array", + "title": "Stages", + "description": "Ordered stages. When empty the standard default stages are created." + } + }, + "type": "object", + "required": [ + "name" + ], + "title": "DealPipelineCreateRequest" + }, + "DealPipelineUpdateRequest": { + "properties": { + "name": { + "anyOf": [ + { + "type": "string", + "maxLength": 200, + "minLength": 1 + }, + { + "type": "null" + } + ], + "title": "Name" + }, + "is_default": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Is Default", + "description": "Set true to make this the workspace's default Deal pipeline." + }, + "stages": { + "anyOf": [ + { + "items": { + "$ref": "#/components/schemas/DealPipelineStageUpdate" + }, + "type": "array", + "minItems": 1 + }, + { + "type": "null" + } + ], + "title": "Stages", + "description": "Complete ordered stage list. Every existing stage must appear here by id or in removed_stages. Omit it to keep the current stages and order." + }, + "removed_stages": { + "items": { + "$ref": "#/components/schemas/DealPipelineStageRemoval" + }, + "type": "array", + "title": "Removed Stages", + "description": "Stages to delete. A stage is only deleted when listed here." + } + }, + "type": "object", + "title": "DealPipelineUpdateRequest" + }, "PositionUpdateRequest": { "properties": { "expected_version": { @@ -56286,6 +56642,163 @@ ], "title": "WorkforcePositionData" }, + "DealPipelineStageCreate": { + "properties": { + "name": { + "type": "string", + "maxLength": 200, + "minLength": 1, + "title": "Name" + }, + "internal_value": { + "anyOf": [ + { + "type": "string", + "maxLength": 100, + "minLength": 1 + }, + { + "type": "null" + } + ], + "title": "Internal Value", + "description": "Value stored on Deals in this stage. Derived from the name when omitted; normalized to lowercase letters, digits and underscores." + }, + "score": { + "type": "integer", + "maximum": 100.0, + "minimum": 0.0, + "title": "Score", + "default": 0 + }, + "is_default": { + "type": "boolean", + "title": "Is Default", + "description": "Exactly one stage is the default. The first stage is used when none is.", + "default": false + }, + "is_hidden": { + "type": "boolean", + "title": "Is Hidden", + "default": false + } + }, + "type": "object", + "required": [ + "name" + ], + "title": "DealPipelineStageCreate" + }, + "DealPipelineStageRemoval": { + "properties": { + "id": { + "type": "string", + "minLength": 1, + "title": "Id" + }, + "replacement_stage_id": { + "anyOf": [ + { + "type": "string", + "minLength": 1 + }, + { + "type": "null" + } + ], + "title": "Replacement Stage Id", + "description": "Kept stage of the same pipeline that receives this stage's Deals. Required when Deals use the removed stage." + } + }, + "type": "object", + "required": [ + "id" + ], + "title": "DealPipelineStageRemoval" + }, + "DealPipelineStageUpdate": { + "properties": { + "id": { + "anyOf": [ + { + "type": "string", + "minLength": 1 + }, + { + "type": "null" + } + ], + "title": "Id", + "description": "Existing stage id. Omit it to add a new stage at this position." + }, + "name": { + "anyOf": [ + { + "type": "string", + "maxLength": 200, + "minLength": 1 + }, + { + "type": "null" + } + ], + "title": "Name", + "description": "Required for a new stage; an existing stage keeps its name when omitted." + }, + "internal_value": { + "anyOf": [ + { + "type": "string", + "maxLength": 100, + "minLength": 1 + }, + { + "type": "null" + } + ], + "title": "Internal Value", + "description": "An existing stage keeps its value when omitted. Changing it moves the stage's Deals to the new value." + }, + "score": { + "anyOf": [ + { + "type": "integer", + "maximum": 100.0, + "minimum": 0.0 + }, + { + "type": "null" + } + ], + "title": "Score" + }, + "is_default": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Is Default", + "description": "Set true on one stage to make it the default. Omit it everywhere to keep the current default stage." + }, + "is_hidden": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "null" + } + ], + "title": "Is Hidden" + } + }, + "type": "object", + "title": "DealPipelineStageUpdate" + }, "UnassignedJobData": { "properties": { "id": { diff --git a/src/sanka_sdk/deals/client.py b/src/sanka_sdk/deals/client.py index 6a94bf0..f22e20b 100644 --- a/src/sanka_sdk/deals/client.py +++ b/src/sanka_sdk/deals/client.py @@ -7,6 +7,12 @@ from ..types.create_public_deal_api_v_2_public_deals_post_200_envelope import ( CreatePublicDealApiV2PublicDealsPost200Envelope, ) +from ..types.create_public_deal_pipeline_api_v_2_public_deals_pipelines_post_201_envelope import ( + CreatePublicDealPipelineApiV2PublicDealsPipelinesPost201Envelope, +) +from ..types.deal_pipeline_stage_create import DealPipelineStageCreate +from ..types.deal_pipeline_stage_removal import DealPipelineStageRemoval +from ..types.deal_pipeline_stage_update import DealPipelineStageUpdate from ..types.delete_public_deal_api_v_2_public_deals_deal_id_delete_200_envelope import ( DeletePublicDealApiV2PublicDealsDealIdDelete200Envelope, ) @@ -22,6 +28,9 @@ from ..types.update_public_deal_api_v_2_public_deals_deal_id_put_200_envelope import ( UpdatePublicDealApiV2PublicDealsDealIdPut200Envelope, ) +from ..types.update_public_deal_pipeline_api_v_2_public_deals_pipelines_pipeline_id_patch_200_envelope import ( + UpdatePublicDealPipelineApiV2PublicDealsPipelinesPipelineIdPatch200Envelope, +) from .raw_client import AsyncRawDealsClient, RawDealsClient # this is used as the default value for optional parameters @@ -252,6 +261,113 @@ def list_public_deal_pipelines_api( ) return _response.data + def create_public_deal_pipeline_api( + self, + *, + name: str, + workspace_id: typing.Optional[str] = None, + is_default: typing.Optional[bool] = OMIT, + stages: typing.Optional[typing.Sequence[DealPipelineStageCreate]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> CreatePublicDealPipelineApiV2PublicDealsPipelinesPost201Envelope: + """ + Parameters + ---------- + name : str + + workspace_id : typing.Optional[str] + + is_default : typing.Optional[bool] + Make this the workspace's default Deal pipeline. + + stages : typing.Optional[typing.Sequence[DealPipelineStageCreate]] + Ordered stages. When empty the standard default stages are created. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CreatePublicDealPipelineApiV2PublicDealsPipelinesPost201Envelope + Successful Response + + Examples + -------- + from sanka_sdk import SankaClient + + client = SankaClient( + workspace_code="YOUR_WORKSPACE_CODE", + token="YOUR_TOKEN", + ) + client.deals.create_public_deal_pipeline_api( + name="name", + ) + """ + _response = self._raw_client.create_public_deal_pipeline_api( + name=name, workspace_id=workspace_id, is_default=is_default, stages=stages, request_options=request_options + ) + return _response.data + + def update_public_deal_pipeline_api( + self, + pipeline_id: str, + *, + workspace_id: typing.Optional[str] = None, + name: typing.Optional[str] = OMIT, + is_default: typing.Optional[bool] = OMIT, + stages: typing.Optional[typing.Sequence[DealPipelineStageUpdate]] = OMIT, + removed_stages: typing.Optional[typing.Sequence[DealPipelineStageRemoval]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpdatePublicDealPipelineApiV2PublicDealsPipelinesPipelineIdPatch200Envelope: + """ + Parameters + ---------- + pipeline_id : str + + workspace_id : typing.Optional[str] + + name : typing.Optional[str] + + is_default : typing.Optional[bool] + Set true to make this the workspace's default Deal pipeline. + + stages : typing.Optional[typing.Sequence[DealPipelineStageUpdate]] + Complete ordered stage list. Every existing stage must appear here by id or in removed_stages. Omit it to keep the current stages and order. + + removed_stages : typing.Optional[typing.Sequence[DealPipelineStageRemoval]] + Stages to delete. A stage is only deleted when listed here. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpdatePublicDealPipelineApiV2PublicDealsPipelinesPipelineIdPatch200Envelope + Successful Response + + Examples + -------- + from sanka_sdk import SankaClient + + client = SankaClient( + workspace_code="YOUR_WORKSPACE_CODE", + token="YOUR_TOKEN", + ) + client.deals.update_public_deal_pipeline_api( + pipeline_id="pipeline_id", + ) + """ + _response = self._raw_client.update_public_deal_pipeline_api( + pipeline_id, + workspace_id=workspace_id, + name=name, + is_default=is_default, + stages=stages, + removed_stages=removed_stages, + request_options=request_options, + ) + return _response.data + def get_public_deal_api( self, deal_id: str, @@ -712,6 +828,129 @@ async def main() -> None: ) return _response.data + async def create_public_deal_pipeline_api( + self, + *, + name: str, + workspace_id: typing.Optional[str] = None, + is_default: typing.Optional[bool] = OMIT, + stages: typing.Optional[typing.Sequence[DealPipelineStageCreate]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> CreatePublicDealPipelineApiV2PublicDealsPipelinesPost201Envelope: + """ + Parameters + ---------- + name : str + + workspace_id : typing.Optional[str] + + is_default : typing.Optional[bool] + Make this the workspace's default Deal pipeline. + + stages : typing.Optional[typing.Sequence[DealPipelineStageCreate]] + Ordered stages. When empty the standard default stages are created. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + CreatePublicDealPipelineApiV2PublicDealsPipelinesPost201Envelope + Successful Response + + Examples + -------- + import asyncio + + from sanka_sdk import AsyncSankaClient + + client = AsyncSankaClient( + workspace_code="YOUR_WORKSPACE_CODE", + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.deals.create_public_deal_pipeline_api( + name="name", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.create_public_deal_pipeline_api( + name=name, workspace_id=workspace_id, is_default=is_default, stages=stages, request_options=request_options + ) + return _response.data + + async def update_public_deal_pipeline_api( + self, + pipeline_id: str, + *, + workspace_id: typing.Optional[str] = None, + name: typing.Optional[str] = OMIT, + is_default: typing.Optional[bool] = OMIT, + stages: typing.Optional[typing.Sequence[DealPipelineStageUpdate]] = OMIT, + removed_stages: typing.Optional[typing.Sequence[DealPipelineStageRemoval]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> UpdatePublicDealPipelineApiV2PublicDealsPipelinesPipelineIdPatch200Envelope: + """ + Parameters + ---------- + pipeline_id : str + + workspace_id : typing.Optional[str] + + name : typing.Optional[str] + + is_default : typing.Optional[bool] + Set true to make this the workspace's default Deal pipeline. + + stages : typing.Optional[typing.Sequence[DealPipelineStageUpdate]] + Complete ordered stage list. Every existing stage must appear here by id or in removed_stages. Omit it to keep the current stages and order. + + removed_stages : typing.Optional[typing.Sequence[DealPipelineStageRemoval]] + Stages to delete. A stage is only deleted when listed here. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + UpdatePublicDealPipelineApiV2PublicDealsPipelinesPipelineIdPatch200Envelope + Successful Response + + Examples + -------- + import asyncio + + from sanka_sdk import AsyncSankaClient + + client = AsyncSankaClient( + workspace_code="YOUR_WORKSPACE_CODE", + token="YOUR_TOKEN", + ) + + + async def main() -> None: + await client.deals.update_public_deal_pipeline_api( + pipeline_id="pipeline_id", + ) + + + asyncio.run(main()) + """ + _response = await self._raw_client.update_public_deal_pipeline_api( + pipeline_id, + workspace_id=workspace_id, + name=name, + is_default=is_default, + stages=stages, + removed_stages=removed_stages, + request_options=request_options, + ) + return _response.data + async def get_public_deal_api( self, deal_id: str, diff --git a/src/sanka_sdk/deals/raw_client.py b/src/sanka_sdk/deals/raw_client.py index 14388bb..e64996b 100644 --- a/src/sanka_sdk/deals/raw_client.py +++ b/src/sanka_sdk/deals/raw_client.py @@ -8,12 +8,19 @@ from ..core.http_response import AsyncHttpResponse, HttpResponse from ..core.jsonable_encoder import jsonable_encoder from ..core.request_options import RequestOptions +from ..core.serialization import convert_and_respect_annotation_metadata from ..core.unchecked_base_model import construct_type from ..errors.unauthorized_error import UnauthorizedError from ..errors.unprocessable_entity_error import UnprocessableEntityError from ..types.create_public_deal_api_v_2_public_deals_post_200_envelope import ( CreatePublicDealApiV2PublicDealsPost200Envelope, ) +from ..types.create_public_deal_pipeline_api_v_2_public_deals_pipelines_post_201_envelope import ( + CreatePublicDealPipelineApiV2PublicDealsPipelinesPost201Envelope, +) +from ..types.deal_pipeline_stage_create import DealPipelineStageCreate +from ..types.deal_pipeline_stage_removal import DealPipelineStageRemoval +from ..types.deal_pipeline_stage_update import DealPipelineStageUpdate from ..types.delete_public_deal_api_v_2_public_deals_deal_id_delete_200_envelope import ( DeletePublicDealApiV2PublicDealsDealIdDelete200Envelope, ) @@ -30,6 +37,9 @@ from ..types.update_public_deal_api_v_2_public_deals_deal_id_put_200_envelope import ( UpdatePublicDealApiV2PublicDealsDealIdPut200Envelope, ) +from ..types.update_public_deal_pipeline_api_v_2_public_deals_pipelines_pipeline_id_patch_200_envelope import ( + UpdatePublicDealPipelineApiV2PublicDealsPipelinesPipelineIdPatch200Envelope, +) # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -344,6 +354,190 @@ def list_public_deal_pipelines_api( raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + def create_public_deal_pipeline_api( + self, + *, + name: str, + workspace_id: typing.Optional[str] = None, + is_default: typing.Optional[bool] = OMIT, + stages: typing.Optional[typing.Sequence[DealPipelineStageCreate]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[CreatePublicDealPipelineApiV2PublicDealsPipelinesPost201Envelope]: + """ + Parameters + ---------- + name : str + + workspace_id : typing.Optional[str] + + is_default : typing.Optional[bool] + Make this the workspace's default Deal pipeline. + + stages : typing.Optional[typing.Sequence[DealPipelineStageCreate]] + Ordered stages. When empty the standard default stages are created. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[CreatePublicDealPipelineApiV2PublicDealsPipelinesPost201Envelope] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + "v2/public/deals/pipelines", + method="POST", + params={ + "workspace_id": workspace_id, + }, + json={ + "name": name, + "is_default": is_default, + "stages": convert_and_respect_annotation_metadata( + object_=stages, annotation=typing.Sequence[DealPipelineStageCreate], direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CreatePublicDealPipelineApiV2PublicDealsPipelinesPost201Envelope, + construct_type( + type_=CreatePublicDealPipelineApiV2PublicDealsPipelinesPost201Envelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + ErrorEnvelope, + construct_type( + type_=ErrorEnvelope, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + ErrorEnvelope, + construct_type( + type_=ErrorEnvelope, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + def update_public_deal_pipeline_api( + self, + pipeline_id: str, + *, + workspace_id: typing.Optional[str] = None, + name: typing.Optional[str] = OMIT, + is_default: typing.Optional[bool] = OMIT, + stages: typing.Optional[typing.Sequence[DealPipelineStageUpdate]] = OMIT, + removed_stages: typing.Optional[typing.Sequence[DealPipelineStageRemoval]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> HttpResponse[UpdatePublicDealPipelineApiV2PublicDealsPipelinesPipelineIdPatch200Envelope]: + """ + Parameters + ---------- + pipeline_id : str + + workspace_id : typing.Optional[str] + + name : typing.Optional[str] + + is_default : typing.Optional[bool] + Set true to make this the workspace's default Deal pipeline. + + stages : typing.Optional[typing.Sequence[DealPipelineStageUpdate]] + Complete ordered stage list. Every existing stage must appear here by id or in removed_stages. Omit it to keep the current stages and order. + + removed_stages : typing.Optional[typing.Sequence[DealPipelineStageRemoval]] + Stages to delete. A stage is only deleted when listed here. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + HttpResponse[UpdatePublicDealPipelineApiV2PublicDealsPipelinesPipelineIdPatch200Envelope] + Successful Response + """ + _response = self._client_wrapper.httpx_client.request( + f"v2/public/deals/pipelines/{jsonable_encoder(pipeline_id)}", + method="PATCH", + params={ + "workspace_id": workspace_id, + }, + json={ + "name": name, + "is_default": is_default, + "stages": convert_and_respect_annotation_metadata( + object_=stages, + annotation=typing.Optional[typing.Sequence[DealPipelineStageUpdate]], + direction="write", + ), + "removed_stages": convert_and_respect_annotation_metadata( + object_=removed_stages, annotation=typing.Sequence[DealPipelineStageRemoval], direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + UpdatePublicDealPipelineApiV2PublicDealsPipelinesPipelineIdPatch200Envelope, + construct_type( + type_=UpdatePublicDealPipelineApiV2PublicDealsPipelinesPipelineIdPatch200Envelope, # type: ignore + object_=_response.json(), + ), + ) + return HttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + ErrorEnvelope, + construct_type( + type_=ErrorEnvelope, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + ErrorEnvelope, + construct_type( + type_=ErrorEnvelope, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + def get_public_deal_api( self, deal_id: str, @@ -949,6 +1143,190 @@ async def list_public_deal_pipelines_api( raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + async def create_public_deal_pipeline_api( + self, + *, + name: str, + workspace_id: typing.Optional[str] = None, + is_default: typing.Optional[bool] = OMIT, + stages: typing.Optional[typing.Sequence[DealPipelineStageCreate]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[CreatePublicDealPipelineApiV2PublicDealsPipelinesPost201Envelope]: + """ + Parameters + ---------- + name : str + + workspace_id : typing.Optional[str] + + is_default : typing.Optional[bool] + Make this the workspace's default Deal pipeline. + + stages : typing.Optional[typing.Sequence[DealPipelineStageCreate]] + Ordered stages. When empty the standard default stages are created. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[CreatePublicDealPipelineApiV2PublicDealsPipelinesPost201Envelope] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + "v2/public/deals/pipelines", + method="POST", + params={ + "workspace_id": workspace_id, + }, + json={ + "name": name, + "is_default": is_default, + "stages": convert_and_respect_annotation_metadata( + object_=stages, annotation=typing.Sequence[DealPipelineStageCreate], direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + CreatePublicDealPipelineApiV2PublicDealsPipelinesPost201Envelope, + construct_type( + type_=CreatePublicDealPipelineApiV2PublicDealsPipelinesPost201Envelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + ErrorEnvelope, + construct_type( + type_=ErrorEnvelope, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + ErrorEnvelope, + construct_type( + type_=ErrorEnvelope, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + + async def update_public_deal_pipeline_api( + self, + pipeline_id: str, + *, + workspace_id: typing.Optional[str] = None, + name: typing.Optional[str] = OMIT, + is_default: typing.Optional[bool] = OMIT, + stages: typing.Optional[typing.Sequence[DealPipelineStageUpdate]] = OMIT, + removed_stages: typing.Optional[typing.Sequence[DealPipelineStageRemoval]] = OMIT, + request_options: typing.Optional[RequestOptions] = None, + ) -> AsyncHttpResponse[UpdatePublicDealPipelineApiV2PublicDealsPipelinesPipelineIdPatch200Envelope]: + """ + Parameters + ---------- + pipeline_id : str + + workspace_id : typing.Optional[str] + + name : typing.Optional[str] + + is_default : typing.Optional[bool] + Set true to make this the workspace's default Deal pipeline. + + stages : typing.Optional[typing.Sequence[DealPipelineStageUpdate]] + Complete ordered stage list. Every existing stage must appear here by id or in removed_stages. Omit it to keep the current stages and order. + + removed_stages : typing.Optional[typing.Sequence[DealPipelineStageRemoval]] + Stages to delete. A stage is only deleted when listed here. + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + AsyncHttpResponse[UpdatePublicDealPipelineApiV2PublicDealsPipelinesPipelineIdPatch200Envelope] + Successful Response + """ + _response = await self._client_wrapper.httpx_client.request( + f"v2/public/deals/pipelines/{jsonable_encoder(pipeline_id)}", + method="PATCH", + params={ + "workspace_id": workspace_id, + }, + json={ + "name": name, + "is_default": is_default, + "stages": convert_and_respect_annotation_metadata( + object_=stages, + annotation=typing.Optional[typing.Sequence[DealPipelineStageUpdate]], + direction="write", + ), + "removed_stages": convert_and_respect_annotation_metadata( + object_=removed_stages, annotation=typing.Sequence[DealPipelineStageRemoval], direction="write" + ), + }, + headers={ + "content-type": "application/json", + }, + request_options=request_options, + omit=OMIT, + ) + try: + if 200 <= _response.status_code < 300: + _data = typing.cast( + UpdatePublicDealPipelineApiV2PublicDealsPipelinesPipelineIdPatch200Envelope, + construct_type( + type_=UpdatePublicDealPipelineApiV2PublicDealsPipelinesPipelineIdPatch200Envelope, # type: ignore + object_=_response.json(), + ), + ) + return AsyncHttpResponse(response=_response, data=_data) + if _response.status_code == 401: + raise UnauthorizedError( + headers=dict(_response.headers), + body=typing.cast( + ErrorEnvelope, + construct_type( + type_=ErrorEnvelope, # type: ignore + object_=_response.json(), + ), + ), + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + headers=dict(_response.headers), + body=typing.cast( + ErrorEnvelope, + construct_type( + type_=ErrorEnvelope, # type: ignore + object_=_response.json(), + ), + ), + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) + async def get_public_deal_api( self, deal_id: str, diff --git a/src/sanka_sdk/types/create_public_deal_pipeline_api_v_2_public_deals_pipelines_post_201_envelope.py b/src/sanka_sdk/types/create_public_deal_pipeline_api_v_2_public_deals_pipelines_post_201_envelope.py new file mode 100644 index 0000000..e9e2500 --- /dev/null +++ b/src/sanka_sdk/types/create_public_deal_pipeline_api_v_2_public_deals_pipelines_post_201_envelope.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .deal_pipeline_data import DealPipelineData +from .envelope_meta import EnvelopeMeta + + +class CreatePublicDealPipelineApiV2PublicDealsPipelinesPost201Envelope(UncheckedBaseModel): + success: typing.Literal[True] = True + data: DealPipelineData + meta: EnvelopeMeta + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/sanka_sdk/types/deal_pipeline_data.py b/src/sanka_sdk/types/deal_pipeline_data.py new file mode 100644 index 0000000..385f567 --- /dev/null +++ b/src/sanka_sdk/types/deal_pipeline_data.py @@ -0,0 +1,26 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .deal_pipeline_stage_data import DealPipelineStageData + + +class DealPipelineData(UncheckedBaseModel): + id: str + name: str + internal_name: str + is_default: typing.Optional[bool] = None + order: typing.Optional[int] = None + stages: typing.Optional[typing.List[DealPipelineStageData]] = None + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/sanka_sdk/types/deal_pipeline_stage_create.py b/src/sanka_sdk/types/deal_pipeline_stage_create.py new file mode 100644 index 0000000..8838c28 --- /dev/null +++ b/src/sanka_sdk/types/deal_pipeline_stage_create.py @@ -0,0 +1,32 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel + + +class DealPipelineStageCreate(UncheckedBaseModel): + name: str + internal_value: typing.Optional[str] = pydantic.Field(default=None) + """ + Value stored on Deals in this stage. Derived from the name when omitted; normalized to lowercase letters, digits and underscores. + """ + + score: typing.Optional[int] = None + is_default: typing.Optional[bool] = pydantic.Field(default=None) + """ + Exactly one stage is the default. The first stage is used when none is. + """ + + is_hidden: typing.Optional[bool] = None + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/sanka_sdk/types/deal_pipeline_stage_data.py b/src/sanka_sdk/types/deal_pipeline_stage_data.py new file mode 100644 index 0000000..9d73906 --- /dev/null +++ b/src/sanka_sdk/types/deal_pipeline_stage_data.py @@ -0,0 +1,26 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel + + +class DealPipelineStageData(UncheckedBaseModel): + id: str + name: str + internal_value: str + score: typing.Optional[int] = None + order: typing.Optional[int] = None + is_default: typing.Optional[bool] = None + is_hidden: typing.Optional[bool] = None + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/sanka_sdk/types/deal_pipeline_stage_removal.py b/src/sanka_sdk/types/deal_pipeline_stage_removal.py new file mode 100644 index 0000000..fe102b8 --- /dev/null +++ b/src/sanka_sdk/types/deal_pipeline_stage_removal.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel + + +class DealPipelineStageRemoval(UncheckedBaseModel): + id: str + replacement_stage_id: typing.Optional[str] = pydantic.Field(default=None) + """ + Kept stage of the same pipeline that receives this stage's Deals. Required when Deals use the removed stage. + """ + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/sanka_sdk/types/deal_pipeline_stage_update.py b/src/sanka_sdk/types/deal_pipeline_stage_update.py new file mode 100644 index 0000000..be02bff --- /dev/null +++ b/src/sanka_sdk/types/deal_pipeline_stage_update.py @@ -0,0 +1,41 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel + + +class DealPipelineStageUpdate(UncheckedBaseModel): + id: typing.Optional[str] = pydantic.Field(default=None) + """ + Existing stage id. Omit it to add a new stage at this position. + """ + + name: typing.Optional[str] = pydantic.Field(default=None) + """ + Required for a new stage; an existing stage keeps its name when omitted. + """ + + internal_value: typing.Optional[str] = pydantic.Field(default=None) + """ + An existing stage keeps its value when omitted. Changing it moves the stage's Deals to the new value. + """ + + score: typing.Optional[int] = None + is_default: typing.Optional[bool] = pydantic.Field(default=None) + """ + Set true on one stage to make it the default. Omit it everywhere to keep the current default stage. + """ + + is_hidden: typing.Optional[bool] = None + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow diff --git a/src/sanka_sdk/types/update_public_deal_pipeline_api_v_2_public_deals_pipelines_pipeline_id_patch_200_envelope.py b/src/sanka_sdk/types/update_public_deal_pipeline_api_v_2_public_deals_pipelines_pipeline_id_patch_200_envelope.py new file mode 100644 index 0000000..e05870c --- /dev/null +++ b/src/sanka_sdk/types/update_public_deal_pipeline_api_v_2_public_deals_pipelines_pipeline_id_patch_200_envelope.py @@ -0,0 +1,24 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing + +import pydantic +from ..core.pydantic_utilities import IS_PYDANTIC_V2 +from ..core.unchecked_base_model import UncheckedBaseModel +from .deal_pipeline_data import DealPipelineData +from .envelope_meta import EnvelopeMeta + + +class UpdatePublicDealPipelineApiV2PublicDealsPipelinesPipelineIdPatch200Envelope(UncheckedBaseModel): + success: typing.Literal[True] = True + data: DealPipelineData + meta: EnvelopeMeta + + if IS_PYDANTIC_V2: + model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2 + else: + + class Config: + frozen = True + smart_union = True + extra = pydantic.Extra.allow