dex-connector-pipedrive 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dex_connector_pipedrive-0.1.0.dist-info/METADATA +26 -0
- dex_connector_pipedrive-0.1.0.dist-info/RECORD +22 -0
- dex_connector_pipedrive-0.1.0.dist-info/WHEEL +4 -0
- dex_connector_pipedrive-0.1.0.dist-info/licenses/LICENSE +21 -0
- dex_connectors/pipedrive/__init__.py +51 -0
- dex_connectors/pipedrive/_generated/__init__.py +2 -0
- dex_connectors/pipedrive/_generated/config.py +30 -0
- dex_connectors/pipedrive/_generated/connection.py +252 -0
- dex_connectors/pipedrive/_generated/definitions.py +130 -0
- dex_connectors/pipedrive/_generated/mock.py +371 -0
- dex_connectors/pipedrive/_generated/models.py +247 -0
- dex_connectors/pipedrive/_generated/refresh.py +9 -0
- dex_connectors/pipedrive/_generated/steps.py +343 -0
- dex_connectors/pipedrive/_generated/timestamps.py +60 -0
- dex_connectors/pipedrive/client.py +465 -0
- dex_connectors/pipedrive/connection.py +8 -0
- dex_connectors/pipedrive/dex-connector.json +229 -0
- dex_connectors/pipedrive/models.py +270 -0
- dex_connectors/pipedrive/operations.py +996 -0
- dex_connectors/pipedrive/pipedrivemock/__init__.py +6 -0
- dex_connectors/pipedrive/py.typed +0 -0
- dex_connectors/pipedrive/steps.py +10 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: dex-connector-pipedrive
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Dex-native Pipedrive CRM connector
|
|
5
|
+
Project-URL: Source, https://github.com/superdurable/dex-connectors-library/tree/main/connectors/pipedrive/python
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: >=3.11
|
|
9
|
+
Requires-Dist: dex-connectors-sdk==0.7.0
|
|
10
|
+
Requires-Dist: dex-python-sdk>=1.28.0
|
|
11
|
+
Requires-Dist: httpx>=0.27
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# Pipedrive Python connector
|
|
15
|
+
|
|
16
|
+
`dex-connector-pipedrive` exposes the six manifest operations: `searchObjects`, `getObject`, `listObjects`, `upsertObject`, `createObject`, and `updateObject`. It requires `dex-connectors-sdk==0.7.0` and `dex-python-sdk>=1.28.0`. The package has no Triggers.
|
|
17
|
+
|
|
18
|
+
Load a named Pipedrive connection from Dex project configuration with `new_project_connection(project, "pipedrive-crm")`. The generated connection binds Personal API token credentials or Pipedrive OAuth credentials and handles refresh through the generated manifest driver. Provider calls resolve credentials at dispatch time; never put a token in Flow input or an Attribute.
|
|
19
|
+
|
|
20
|
+
See the runnable [deal lookup example](examples/deal_lookup/README.md) for a Flow, Worker, start command, and a real Dex integration test. `getObject` returns a complete record; search returns partial records, which can be hydrated through `getObject`. Non-happy branches are optional and fail an example Flow unless explicitly wired for a business reaction. The source of truth for authorization and configuration is the connector's [`connector.yaml`](../connector.yaml).
|
|
21
|
+
|
|
22
|
+
`listObjects` accepts the Go JSON timestamp spellings for `updatedSince` and `updatedUntil`, including comma fractions and offsets through 24:60, and sends the filters as whole-second UTC times.
|
|
23
|
+
|
|
24
|
+
Open-ended `fields` and `customFields` values retain their JSON number spelling when Python can encode it unchanged. A number that would round or change spelling makes a read select `invalidResponse`; an already accepted write can instead be `uncertain`.
|
|
25
|
+
|
|
26
|
+
Run the package checks from this directory with `uv sync` and `uv run pytest`. Run provider replay from the repository root with `make test-connector-conformance CONNECTOR_DIRECTORY=connectors/pipedrive`. Live Pipedrive authorization and API behavior are unverified.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
dex_connectors/pipedrive/__init__.py,sha256=5HygFkVQmIPR55dMSAjoleJ9bPLIUF0WVedqses7WCg,1953
|
|
2
|
+
dex_connectors/pipedrive/client.py,sha256=CuYDX_AcS5xcy0cyYkAE_0GiDmWUKvHTE0E4fwCXxKM,17947
|
|
3
|
+
dex_connectors/pipedrive/connection.py,sha256=4N55qxs_aR-bxPISC8zulw9Q49sOihcLKej0yTD2pEY,442
|
|
4
|
+
dex_connectors/pipedrive/dex-connector.json,sha256=X-WzX9lNtdgEn7uObcwdg7r9EkJka6TdBcuFm3TDw8o,5351
|
|
5
|
+
dex_connectors/pipedrive/models.py,sha256=oQceltlfvubEgiHC94vNeOaWkWxZjZXQqRnAK_EPiNY,10151
|
|
6
|
+
dex_connectors/pipedrive/operations.py,sha256=8zApnlUvCoL5se5gXE4O46vLXwpfhuA9aVvd7hJerJ4,43026
|
|
7
|
+
dex_connectors/pipedrive/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
dex_connectors/pipedrive/steps.py,sha256=atDGpLoQ2VK4C4kq5Ye4Z2Alr6W7Llx6DBGxajzMIeo,600
|
|
9
|
+
dex_connectors/pipedrive/_generated/__init__.py,sha256=ShfMsAGzSt4xuhCaf20ibgtfXl4pXomZb00ovUw6CeI,66
|
|
10
|
+
dex_connectors/pipedrive/_generated/config.py,sha256=LpJPeW70uVSOMHLnkP_52yz_5htYxlqvCgIeVYfiLM4,780
|
|
11
|
+
dex_connectors/pipedrive/_generated/connection.py,sha256=wSz5_CPWrjTwaC5KOw6AYpNkvtDUAd-NBxgSRAODZBo,13289
|
|
12
|
+
dex_connectors/pipedrive/_generated/definitions.py,sha256=jMnqmyybioIKU-NmdtQDI8smi8_5rq-WL9Shhycsz0c,6333
|
|
13
|
+
dex_connectors/pipedrive/_generated/mock.py,sha256=sh9FyvxKE8E5mywQG010Ya7fpQw21c65hxAb8Da1To8,20809
|
|
14
|
+
dex_connectors/pipedrive/_generated/models.py,sha256=vDvYb-LDulqGLE9m0TUi3aTt4qxJsapm78M6k1S-eO4,15054
|
|
15
|
+
dex_connectors/pipedrive/_generated/refresh.py,sha256=HvsPa-GYJyPx-55RaR5esWCAYlMMGK-uFWjFAEj5cBo,1913
|
|
16
|
+
dex_connectors/pipedrive/_generated/steps.py,sha256=HZShbE5EuLqsI79ovvJtotT3W9RzSUL1wb92cMu4MAg,15856
|
|
17
|
+
dex_connectors/pipedrive/_generated/timestamps.py,sha256=Z8VwrE60w-33InIMgEMLiMPTFyRjj6oBq8tUro8Ssi8,3164
|
|
18
|
+
dex_connectors/pipedrive/pipedrivemock/__init__.py,sha256=sEODfqQ6BJ0_cxRmH7FUHlzuhGC26jntpGD0cmUtm_U,167
|
|
19
|
+
dex_connector_pipedrive-0.1.0.dist-info/METADATA,sha256=Pho_hFejyS-UbipW82F5d7kkG6yIXuqHgDFJpKvJY0Q,2302
|
|
20
|
+
dex_connector_pipedrive-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
21
|
+
dex_connector_pipedrive-0.1.0.dist-info/licenses/LICENSE,sha256=WNj87Zd5micrAShl1LujOPM6PDzDqjlNLrryDZ4hE0M,1070
|
|
22
|
+
dex_connector_pipedrive-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Super Durable
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
"""Pipedrive connector for Dex Python applications."""
|
|
4
|
+
|
|
5
|
+
from .client import Client as Client
|
|
6
|
+
from .client import Config as Config
|
|
7
|
+
from .client import Credentials as Credentials
|
|
8
|
+
from .connection import Connection as Connection
|
|
9
|
+
from .connection import new_connection as new_connection
|
|
10
|
+
from .connection import new_connection_with_operations as new_connection_with_operations
|
|
11
|
+
from .connection import new_project_connection as new_project_connection
|
|
12
|
+
from .models import CreateObjectInput as CreateObjectInput
|
|
13
|
+
from .models import CRMObject as CRMObject
|
|
14
|
+
from .models import GetObjectInput as GetObjectInput
|
|
15
|
+
from .models import ListObjectsInput as ListObjectsInput
|
|
16
|
+
from .models import ObjectPage as ObjectPage
|
|
17
|
+
from .models import SearchObjectsInput as SearchObjectsInput
|
|
18
|
+
from .models import UpdateObjectInput as UpdateObjectInput
|
|
19
|
+
from .models import UpsertedObject as UpsertedObject
|
|
20
|
+
from .models import UpsertObjectInput as UpsertObjectInput
|
|
21
|
+
from .steps import new_create_object_step as new_create_object_step
|
|
22
|
+
from .steps import new_get_object_step as new_get_object_step
|
|
23
|
+
from .steps import new_list_objects_step as new_list_objects_step
|
|
24
|
+
from .steps import new_search_objects_step as new_search_objects_step
|
|
25
|
+
from .steps import new_update_object_step as new_update_object_step
|
|
26
|
+
from .steps import new_upsert_object_step as new_upsert_object_step
|
|
27
|
+
|
|
28
|
+
__all__ = [
|
|
29
|
+
"Client",
|
|
30
|
+
"Config",
|
|
31
|
+
"Credentials",
|
|
32
|
+
"Connection",
|
|
33
|
+
"new_connection",
|
|
34
|
+
"new_connection_with_operations",
|
|
35
|
+
"new_project_connection",
|
|
36
|
+
"CreateObjectInput",
|
|
37
|
+
"CRMObject",
|
|
38
|
+
"GetObjectInput",
|
|
39
|
+
"ListObjectsInput",
|
|
40
|
+
"ObjectPage",
|
|
41
|
+
"SearchObjectsInput",
|
|
42
|
+
"UpdateObjectInput",
|
|
43
|
+
"UpsertedObject",
|
|
44
|
+
"UpsertObjectInput",
|
|
45
|
+
"new_create_object_step",
|
|
46
|
+
"new_get_object_step",
|
|
47
|
+
"new_list_objects_step",
|
|
48
|
+
"new_search_objects_step",
|
|
49
|
+
"new_update_object_step",
|
|
50
|
+
"new_upsert_object_step",
|
|
51
|
+
]
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
# ruff: noqa
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
from dex_connectors.sdk import SecretString
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass(frozen=True, slots=True)
|
|
11
|
+
class Config:
|
|
12
|
+
|
|
13
|
+
endpoint: str = "https://api.pipedrive.com"
|
|
14
|
+
max_response_bytes: int = 1048576
|
|
15
|
+
|
|
16
|
+
setattr(Config, '__module__', 'dex_connectors.pipedrive.client')
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass(frozen=True, slots=True)
|
|
20
|
+
class Credentials:
|
|
21
|
+
|
|
22
|
+
auth_method_id: str = "api-token"
|
|
23
|
+
api_token: SecretString | None = None
|
|
24
|
+
oauth_client_id: str | None = None
|
|
25
|
+
oauth_client_secret: SecretString | None = None
|
|
26
|
+
access_token: SecretString | None = None
|
|
27
|
+
refresh_token: SecretString | None = None
|
|
28
|
+
api_domain: str = ''
|
|
29
|
+
|
|
30
|
+
setattr(Credentials, '__module__', 'dex_connectors.pipedrive.client')
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
# ruff: noqa
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
from dex_connectors.sdk import ConnectionRef, Mutation, Query, Call, SecretString, CredentialRefreshDriver
|
|
9
|
+
from dex_connectors.sdk.projectconfig import ConnectionKey, LoadedProject
|
|
10
|
+
from dex_connectors.sdk.projectconfig.provider import RefreshingCredentialProvider
|
|
11
|
+
from dex_connectors.sdk.oauthtoken import ManifestCredentialRefreshDriver
|
|
12
|
+
|
|
13
|
+
from ..client import Client, Config, Credentials
|
|
14
|
+
from .definitions import CONNECTOR_ID, CREATE_OBJECT_DEFINITION, GET_OBJECT_DEFINITION, LIST_OBJECTS_DEFINITION, SEARCH_OBJECTS_DEFINITION, UPDATE_OBJECT_DEFINITION, UPSERT_OBJECT_DEFINITION
|
|
15
|
+
from .refresh import AUTHORIZATION, CREDENTIAL_FIELDS
|
|
16
|
+
from ..models import CRMObject, CreateObjectInput, GetObjectInput, ListObjectsInput, ObjectPage, SearchObjectsInput, UpdateObjectInput, UpsertObjectInput, UpsertedObject
|
|
17
|
+
|
|
18
|
+
class Connection:
|
|
19
|
+
|
|
20
|
+
__slots__ = ('_search_objects', '_get_object', '_list_objects', '_upsert_object', '_create_object', '_update_object', '_client', 'reference')
|
|
21
|
+
|
|
22
|
+
def __init__(self,
|
|
23
|
+
reference: ConnectionRef,
|
|
24
|
+
search_objects: Query[SearchObjectsInput, ObjectPage],
|
|
25
|
+
get_object: Query[GetObjectInput, CRMObject],
|
|
26
|
+
list_objects: Query[ListObjectsInput, ObjectPage],
|
|
27
|
+
upsert_object: Mutation[UpsertObjectInput, UpsertedObject],
|
|
28
|
+
create_object: Mutation[CreateObjectInput, CRMObject],
|
|
29
|
+
update_object: Mutation[UpdateObjectInput, CRMObject],
|
|
30
|
+
client: Client | None = None,
|
|
31
|
+
) -> None:
|
|
32
|
+
reference.validate()
|
|
33
|
+
if reference.provider != CONNECTOR_ID or search_objects is None or get_object is None or list_objects is None or upsert_object is None or create_object is None or update_object is None:
|
|
34
|
+
raise ValueError("Pipedrive connection provider and operations are required")
|
|
35
|
+
if search_objects.definition().operation != SEARCH_OBJECTS_DEFINITION.operation:
|
|
36
|
+
raise ValueError("Pipedrive connection operation identity differs")
|
|
37
|
+
if get_object.definition().operation != GET_OBJECT_DEFINITION.operation:
|
|
38
|
+
raise ValueError("Pipedrive connection operation identity differs")
|
|
39
|
+
if list_objects.definition().operation != LIST_OBJECTS_DEFINITION.operation:
|
|
40
|
+
raise ValueError("Pipedrive connection operation identity differs")
|
|
41
|
+
if upsert_object.definition().operation != UPSERT_OBJECT_DEFINITION.operation:
|
|
42
|
+
raise ValueError("Pipedrive connection operation identity differs")
|
|
43
|
+
if create_object.definition().operation != CREATE_OBJECT_DEFINITION.operation:
|
|
44
|
+
raise ValueError("Pipedrive connection operation identity differs")
|
|
45
|
+
if update_object.definition().operation != UPDATE_OBJECT_DEFINITION.operation:
|
|
46
|
+
raise ValueError("Pipedrive connection operation identity differs")
|
|
47
|
+
self.reference = reference
|
|
48
|
+
self._search_objects = search_objects
|
|
49
|
+
self._get_object = get_object
|
|
50
|
+
self._list_objects = list_objects
|
|
51
|
+
self._upsert_object = upsert_object
|
|
52
|
+
self._create_object = create_object
|
|
53
|
+
self._update_object = update_object
|
|
54
|
+
self._client = client
|
|
55
|
+
|
|
56
|
+
def search_objects(self) -> Query[SearchObjectsInput, ObjectPage]:
|
|
57
|
+
return self._search_objects
|
|
58
|
+
|
|
59
|
+
def get_object(self) -> Query[GetObjectInput, CRMObject]:
|
|
60
|
+
return self._get_object
|
|
61
|
+
|
|
62
|
+
def list_objects(self) -> Query[ListObjectsInput, ObjectPage]:
|
|
63
|
+
return self._list_objects
|
|
64
|
+
|
|
65
|
+
def upsert_object(self) -> Mutation[UpsertObjectInput, UpsertedObject]:
|
|
66
|
+
return self._upsert_object
|
|
67
|
+
|
|
68
|
+
def create_object(self) -> Mutation[CreateObjectInput, CRMObject]:
|
|
69
|
+
return self._create_object
|
|
70
|
+
|
|
71
|
+
def update_object(self) -> Mutation[UpdateObjectInput, CRMObject]:
|
|
72
|
+
return self._update_object
|
|
73
|
+
|
|
74
|
+
async def aclose(self) -> None:
|
|
75
|
+
if self._client is not None:
|
|
76
|
+
await self._client.aclose()
|
|
77
|
+
|
|
78
|
+
def __repr__(self) -> str:
|
|
79
|
+
return "pipedrive.Connection([REDACTED])"
|
|
80
|
+
|
|
81
|
+
def __reduce__(self) -> tuple[object, ...]:
|
|
82
|
+
raise TypeError("Pipedrive connections cannot be serialized")
|
|
83
|
+
|
|
84
|
+
setattr(Connection, '__module__', 'dex_connectors.pipedrive.connection')
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def new_connection(client: Client, reference: ConnectionRef) -> Connection:
|
|
88
|
+
if client is None:
|
|
89
|
+
raise ValueError("Pipedrive client is required")
|
|
90
|
+
return Connection(reference, client.search_objects(), client.get_object(), client.list_objects(), client.upsert_object(), client.create_object(), client.update_object(), client)
|
|
91
|
+
|
|
92
|
+
setattr(new_connection, '__module__', 'dex_connectors.pipedrive.connection')
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def new_connection_with_operations(
|
|
96
|
+
search_objects: Query[SearchObjectsInput, ObjectPage],
|
|
97
|
+
get_object: Query[GetObjectInput, CRMObject],
|
|
98
|
+
list_objects: Query[ListObjectsInput, ObjectPage],
|
|
99
|
+
upsert_object: Mutation[UpsertObjectInput, UpsertedObject],
|
|
100
|
+
create_object: Mutation[CreateObjectInput, CRMObject],
|
|
101
|
+
update_object: Mutation[UpdateObjectInput, CRMObject],
|
|
102
|
+
reference: ConnectionRef,
|
|
103
|
+
) -> Connection:
|
|
104
|
+
return Connection(reference, search_objects, get_object, list_objects, upsert_object, create_object, update_object)
|
|
105
|
+
|
|
106
|
+
setattr(new_connection_with_operations, '__module__', 'dex_connectors.pipedrive.connection')
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def decode_credentials(material: dict[str, Any], *, shared: bool = False) -> Credentials:
|
|
110
|
+
if not isinstance(material, dict):
|
|
111
|
+
raise ValueError("Pipedrive stored credential does not match the connector credential fields")
|
|
112
|
+
if set(material) - set(('api_token', 'oauth_client_id', 'oauth_client_secret', 'access_token', 'refresh_token', 'api_domain', 'auth_method')):
|
|
113
|
+
raise ValueError("Pipedrive stored credential does not match the connector credential fields")
|
|
114
|
+
is_shared = shared
|
|
115
|
+
api_token = material.get("api_token")
|
|
116
|
+
if api_token is not None and not (isinstance(api_token, str)):
|
|
117
|
+
raise ValueError("Pipedrive credential api_token has an invalid type")
|
|
118
|
+
oauth_client_id = material.get("oauth_client_id")
|
|
119
|
+
if oauth_client_id is not None and not (isinstance(oauth_client_id, str)):
|
|
120
|
+
raise ValueError("Pipedrive credential oauth_client_id has an invalid type")
|
|
121
|
+
oauth_client_secret = material.get("oauth_client_secret")
|
|
122
|
+
if oauth_client_secret is not None and not (isinstance(oauth_client_secret, str)):
|
|
123
|
+
raise ValueError("Pipedrive credential oauth_client_secret has an invalid type")
|
|
124
|
+
access_token = material.get("access_token")
|
|
125
|
+
if access_token is not None and not (isinstance(access_token, str)):
|
|
126
|
+
raise ValueError("Pipedrive credential access_token has an invalid type")
|
|
127
|
+
refresh_token = material.get("refresh_token")
|
|
128
|
+
if refresh_token is not None and not (isinstance(refresh_token, str)):
|
|
129
|
+
raise ValueError("Pipedrive credential refresh_token has an invalid type")
|
|
130
|
+
api_domain = material.get("api_domain")
|
|
131
|
+
if api_domain is not None and not (isinstance(api_domain, str)):
|
|
132
|
+
raise ValueError("Pipedrive credential api_domain has an invalid type")
|
|
133
|
+
selected_method = material.get('auth_method')
|
|
134
|
+
if selected_method is None:
|
|
135
|
+
selected_method = ''
|
|
136
|
+
if not isinstance(selected_method, str):
|
|
137
|
+
raise ValueError("Pipedrive credential auth_method is invalid")
|
|
138
|
+
method = selected_method or "api-token"
|
|
139
|
+
values: dict[str, Any] = {'auth_method_id': method}
|
|
140
|
+
if method == "api-token":
|
|
141
|
+
if not api_token:
|
|
142
|
+
raise ValueError("Pipedrive credential api_token is required")
|
|
143
|
+
if api_token:
|
|
144
|
+
values["api_token"] = SecretString(api_token)
|
|
145
|
+
elif method == "pipedrive-oauth":
|
|
146
|
+
if not oauth_client_id:
|
|
147
|
+
raise ValueError("Pipedrive credential oauth_client_id is required")
|
|
148
|
+
if oauth_client_id:
|
|
149
|
+
values["oauth_client_id"] = oauth_client_id
|
|
150
|
+
if not oauth_client_secret and not is_shared:
|
|
151
|
+
raise ValueError("Pipedrive credential oauth_client_secret is required")
|
|
152
|
+
if oauth_client_secret:
|
|
153
|
+
values["oauth_client_secret"] = SecretString(oauth_client_secret)
|
|
154
|
+
if not access_token:
|
|
155
|
+
raise ValueError("Pipedrive credential access_token is required")
|
|
156
|
+
if access_token:
|
|
157
|
+
values["access_token"] = SecretString(access_token)
|
|
158
|
+
if not refresh_token and not is_shared:
|
|
159
|
+
raise ValueError("Pipedrive credential refresh_token is required")
|
|
160
|
+
if refresh_token:
|
|
161
|
+
values["refresh_token"] = SecretString(refresh_token)
|
|
162
|
+
values["api_domain"] = api_domain or ''
|
|
163
|
+
else:
|
|
164
|
+
raise ValueError("Pipedrive credential auth_method is invalid")
|
|
165
|
+
return Credentials(**values)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def decode_shared_credentials(material: dict[str, Any]) -> Credentials:
|
|
169
|
+
return decode_credentials(material, shared=True)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def encode_credentials(credentials: Credentials) -> dict[str, Any]:
|
|
173
|
+
material: dict[str, Any] = {}
|
|
174
|
+
method = credentials.auth_method_id or "api-token"
|
|
175
|
+
material['auth_method'] = method
|
|
176
|
+
if method == "api-token":
|
|
177
|
+
if (credentials.api_token.reveal() if credentials.api_token is not None else ''):
|
|
178
|
+
material["api_token"] = (credentials.api_token.reveal() if credentials.api_token is not None else '')
|
|
179
|
+
elif method == "pipedrive-oauth":
|
|
180
|
+
if credentials.oauth_client_id:
|
|
181
|
+
material["oauth_client_id"] = credentials.oauth_client_id
|
|
182
|
+
if (credentials.oauth_client_secret.reveal() if credentials.oauth_client_secret is not None else ''):
|
|
183
|
+
material["oauth_client_secret"] = (credentials.oauth_client_secret.reveal() if credentials.oauth_client_secret is not None else '')
|
|
184
|
+
if (credentials.access_token.reveal() if credentials.access_token is not None else ''):
|
|
185
|
+
material["access_token"] = (credentials.access_token.reveal() if credentials.access_token is not None else '')
|
|
186
|
+
if (credentials.refresh_token.reveal() if credentials.refresh_token is not None else ''):
|
|
187
|
+
material["refresh_token"] = (credentials.refresh_token.reveal() if credentials.refresh_token is not None else '')
|
|
188
|
+
if credentials.api_domain:
|
|
189
|
+
material["api_domain"] = credentials.api_domain
|
|
190
|
+
else:
|
|
191
|
+
raise ValueError("Pipedrive credential auth_method is invalid")
|
|
192
|
+
decode_credentials(material)
|
|
193
|
+
return material
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
class _ProjectCredentialSource:
|
|
197
|
+
def __init__(self, project: LoadedProject, key: ConnectionKey, http_client: httpx.AsyncClient, settings: dict[str, Any]) -> None:
|
|
198
|
+
self.provider = RefreshingCredentialProvider(
|
|
199
|
+
project.connections, key, decode_credentials, encode_credentials, decode_shared_credentials
|
|
200
|
+
)
|
|
201
|
+
self.driver = ManifestCredentialRefreshDriver[Credentials]("Pipedrive", AUTHORIZATION, CREDENTIAL_FIELDS, http_client, settings=settings)
|
|
202
|
+
|
|
203
|
+
async def resolve(self, call: Call) -> Credentials:
|
|
204
|
+
return await self.provider.resolve_with_refresh(call, self.driver)
|
|
205
|
+
|
|
206
|
+
async def resolve_with_refresh(self, call: Call, driver: CredentialRefreshDriver[Credentials] | None = None) -> Credentials:
|
|
207
|
+
return await self.provider.resolve_with_refresh(call, driver or self.driver)
|
|
208
|
+
|
|
209
|
+
async def resolve_after_rejection(self, call: Call, driver: CredentialRefreshDriver[Credentials] | None = None) -> Credentials:
|
|
210
|
+
return await self.provider.resolve_after_rejection(call, driver or self.driver)
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def new_project_connection(
|
|
214
|
+
project: LoadedProject, connection_name: str, http_client: httpx.AsyncClient | None = None
|
|
215
|
+
) -> Connection:
|
|
216
|
+
if project is None:
|
|
217
|
+
raise ValueError("Pipedrive connection requires loaded project configuration")
|
|
218
|
+
reference = ConnectionRef(CONNECTOR_ID, connection_name)
|
|
219
|
+
reference.validate()
|
|
220
|
+
key = ConnectionKey(CONNECTOR_ID, connection_name)
|
|
221
|
+
matching = [
|
|
222
|
+
entry
|
|
223
|
+
for entry in project.configuration.connections
|
|
224
|
+
if entry.connector_id == CONNECTOR_ID and entry.connection_name == connection_name
|
|
225
|
+
]
|
|
226
|
+
if len(matching) != 1:
|
|
227
|
+
raise ValueError("Pipedrive project connection is missing or duplicated")
|
|
228
|
+
if matching[0].provider != CONNECTOR_ID:
|
|
229
|
+
raise ValueError("Pipedrive project connection provider differs")
|
|
230
|
+
config = _decode_config(matching[0].configuration)
|
|
231
|
+
http_client = http_client or httpx.AsyncClient()
|
|
232
|
+
client = Client(config, _ProjectCredentialSource(project, key, http_client, matching[0].configuration), http_client)
|
|
233
|
+
return new_connection(client, reference)
|
|
234
|
+
|
|
235
|
+
setattr(new_project_connection, '__module__', 'dex_connectors.pipedrive.connection')
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def _decode_config(value: dict[str, Any]) -> Config:
|
|
239
|
+
if set(value) - {"endpoint", "maxResponseBytes"}:
|
|
240
|
+
raise ValueError("Pipedrive configuration has unknown fields")
|
|
241
|
+
config_arguments: dict[str, Any] = {}
|
|
242
|
+
if "endpoint" in value:
|
|
243
|
+
endpoint = value["endpoint"]
|
|
244
|
+
if not (isinstance(endpoint, str)):
|
|
245
|
+
raise ValueError("Pipedrive configuration endpoint has an invalid type")
|
|
246
|
+
config_arguments['endpoint'] = endpoint
|
|
247
|
+
if "maxResponseBytes" in value:
|
|
248
|
+
max_response_bytes = value["maxResponseBytes"]
|
|
249
|
+
if not (type(max_response_bytes) is int):
|
|
250
|
+
raise ValueError("Pipedrive configuration maxResponseBytes has an invalid type")
|
|
251
|
+
config_arguments['max_response_bytes'] = max_response_bytes
|
|
252
|
+
return Config(**config_arguments)
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Copyright (c) 2026 Super Durable
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
# ruff: noqa
|
|
4
|
+
|
|
5
|
+
from datetime import timedelta
|
|
6
|
+
|
|
7
|
+
from dex_connectors.sdk import (
|
|
8
|
+
BranchDefinition,
|
|
9
|
+
MutationDefinition,
|
|
10
|
+
OperationRef,
|
|
11
|
+
QueryDefinition,
|
|
12
|
+
RetryPolicy,
|
|
13
|
+
StepDefaults,
|
|
14
|
+
default_connector_step_execute_retry_policy,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
CONNECTOR_ID = "pipedrive"
|
|
18
|
+
PROVIDER = "pipedrive"
|
|
19
|
+
SEARCH_OBJECTS_OPERATION_ID = "searchObjects"
|
|
20
|
+
GET_OBJECT_OPERATION_ID = "getObject"
|
|
21
|
+
LIST_OBJECTS_OPERATION_ID = "listObjects"
|
|
22
|
+
UPSERT_OBJECT_OPERATION_ID = "upsertObject"
|
|
23
|
+
CREATE_OBJECT_OPERATION_ID = "createObject"
|
|
24
|
+
UPDATE_OBJECT_OPERATION_ID = "updateObject"
|
|
25
|
+
CREATED = "created"
|
|
26
|
+
DEFECT = "defect"
|
|
27
|
+
FOUND = "found"
|
|
28
|
+
INVALID_RESPONSE = "invalidResponse"
|
|
29
|
+
LISTED = "listed"
|
|
30
|
+
MULTIPLE_MATCHES = "multipleMatches"
|
|
31
|
+
NOT_FOUND = "notFound"
|
|
32
|
+
PROVIDER_REJECTED = "providerRejected"
|
|
33
|
+
SEARCHED = "searched"
|
|
34
|
+
UNCERTAIN = "uncertain"
|
|
35
|
+
UPDATED = "updated"
|
|
36
|
+
UPSERTED = "upserted"
|
|
37
|
+
|
|
38
|
+
SEARCH_OBJECTS_DEFINITION = QueryDefinition(
|
|
39
|
+
OperationRef(CONNECTOR_ID, SEARCH_OBJECTS_OPERATION_ID),
|
|
40
|
+
(
|
|
41
|
+
BranchDefinition(SEARCHED, "Pipedrive returned one bounded page of matching partial records; the page may be empty.", False),
|
|
42
|
+
BranchDefinition(PROVIDER_REJECTED, "Pipedrive conclusively rejected the search, such as a revoked token, a missing scope or an invalid term.", True),
|
|
43
|
+
BranchDefinition(INVALID_RESPONSE, "Pipedrive returned an invalid or oversized search page.", True),
|
|
44
|
+
BranchDefinition(DEFECT, "Local input, connection configuration, or connector definition is invalid.", True),
|
|
45
|
+
),
|
|
46
|
+
StepDefaults(
|
|
47
|
+
timedelta(seconds=30),
|
|
48
|
+
2,
|
|
49
|
+
execute_retry=default_connector_step_execute_retry_policy(),
|
|
50
|
+
),
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
GET_OBJECT_DEFINITION = QueryDefinition(
|
|
54
|
+
OperationRef(CONNECTOR_ID, GET_OBJECT_OPERATION_ID),
|
|
55
|
+
(
|
|
56
|
+
BranchDefinition(FOUND, "The record exists and was returned.", False),
|
|
57
|
+
BranchDefinition(NOT_FOUND, "No record of that object type has the ID, or the connection's user cannot see it.", True),
|
|
58
|
+
BranchDefinition(PROVIDER_REJECTED, "Pipedrive conclusively rejected the read, such as a revoked token, or a missing scope.", True),
|
|
59
|
+
BranchDefinition(INVALID_RESPONSE, "Pipedrive returned an invalid or oversized record.", True),
|
|
60
|
+
BranchDefinition(DEFECT, "Local input, connection configuration, or connector definition is invalid.", True),
|
|
61
|
+
),
|
|
62
|
+
StepDefaults(
|
|
63
|
+
timedelta(seconds=30),
|
|
64
|
+
2,
|
|
65
|
+
execute_retry=default_connector_step_execute_retry_policy(),
|
|
66
|
+
),
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
LIST_OBJECTS_DEFINITION = QueryDefinition(
|
|
70
|
+
OperationRef(CONNECTOR_ID, LIST_OBJECTS_OPERATION_ID),
|
|
71
|
+
(
|
|
72
|
+
BranchDefinition(LISTED, "Pipedrive returned one bounded page of full records; the page may be empty.", False),
|
|
73
|
+
BranchDefinition(PROVIDER_REJECTED, "Pipedrive conclusively rejected the list, such as a revoked token, a missing scope or an expired cursor.", True),
|
|
74
|
+
BranchDefinition(INVALID_RESPONSE, "Pipedrive returned an invalid or oversized page.", True),
|
|
75
|
+
BranchDefinition(DEFECT, "Local input, connection configuration, or connector definition is invalid.", True),
|
|
76
|
+
),
|
|
77
|
+
StepDefaults(
|
|
78
|
+
timedelta(seconds=30),
|
|
79
|
+
2,
|
|
80
|
+
execute_retry=default_connector_step_execute_retry_policy(),
|
|
81
|
+
),
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
UPSERT_OBJECT_DEFINITION = MutationDefinition(
|
|
85
|
+
OperationRef(CONNECTOR_ID, UPSERT_OBJECT_OPERATION_ID),
|
|
86
|
+
(
|
|
87
|
+
BranchDefinition(UPSERTED, "Pipedrive created the record or updated the one record that carries the identity value.", False),
|
|
88
|
+
BranchDefinition(MULTIPLE_MATCHES, "More than one record carries the identity value, so the connector changed nothing; the Result lists their IDs.", True),
|
|
89
|
+
BranchDefinition(PROVIDER_REJECTED, "Pipedrive conclusively rejected the search or the write, such as an invalid field value, a revoked token, or a missing scope; nothing was created.", True),
|
|
90
|
+
BranchDefinition(INVALID_RESPONSE, "Pipedrive returned an invalid or oversized search page or updated record.", True),
|
|
91
|
+
BranchDefinition(UNCERTAIN, "A create sent in this or an earlier attempt was not confirmed, and identity read-back finds no record or cannot complete; the record may exist, so the connector does not create it again.", True),
|
|
92
|
+
BranchDefinition(DEFECT, "Local input, connection configuration, or connector definition is invalid.", True),
|
|
93
|
+
),
|
|
94
|
+
StepDefaults(
|
|
95
|
+
timedelta(seconds=30),
|
|
96
|
+
1,
|
|
97
|
+
execute_retry=RetryPolicy(timedelta(seconds=1), 2, timedelta(seconds=30), 5, timedelta(seconds=120)),
|
|
98
|
+
),
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
CREATE_OBJECT_DEFINITION = MutationDefinition(
|
|
102
|
+
OperationRef(CONNECTOR_ID, CREATE_OBJECT_OPERATION_ID),
|
|
103
|
+
(
|
|
104
|
+
BranchDefinition(CREATED, "Pipedrive created the record and returned it.", False),
|
|
105
|
+
BranchDefinition(PROVIDER_REJECTED, "Pipedrive conclusively rejected the create, such as a missing title or name, an unknown stage or owner, or a revoked token; nothing was created.", True),
|
|
106
|
+
BranchDefinition(UNCERTAIN, "The create was sent but its outcome cannot be confirmed, so the record may exist; the connector never sends it again.", True),
|
|
107
|
+
BranchDefinition(DEFECT, "Local input, connection configuration, or connector definition is invalid.", True),
|
|
108
|
+
),
|
|
109
|
+
StepDefaults(
|
|
110
|
+
timedelta(seconds=30),
|
|
111
|
+
1,
|
|
112
|
+
execute_retry=RetryPolicy(timedelta(seconds=1), 2, timedelta(seconds=30), 5, timedelta(seconds=120)),
|
|
113
|
+
),
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
UPDATE_OBJECT_DEFINITION = MutationDefinition(
|
|
117
|
+
OperationRef(CONNECTOR_ID, UPDATE_OBJECT_OPERATION_ID),
|
|
118
|
+
(
|
|
119
|
+
BranchDefinition(UPDATED, "Pipedrive updated the record and returned it.", False),
|
|
120
|
+
BranchDefinition(NOT_FOUND, "No record of that object type has the ID, or the connection's user cannot see it.", True),
|
|
121
|
+
BranchDefinition(PROVIDER_REJECTED, "Pipedrive conclusively rejected the update, such as an invalid field value, an unknown stage or owner, or a revoked token.", True),
|
|
122
|
+
BranchDefinition(INVALID_RESPONSE, "Pipedrive applied or rejected the update but returned an invalid or oversized record.", True),
|
|
123
|
+
BranchDefinition(DEFECT, "Local input, connection configuration, or connector definition is invalid.", True),
|
|
124
|
+
),
|
|
125
|
+
StepDefaults(
|
|
126
|
+
timedelta(seconds=30),
|
|
127
|
+
2,
|
|
128
|
+
execute_retry=default_connector_step_execute_retry_policy(),
|
|
129
|
+
),
|
|
130
|
+
)
|