Skip to content

Commit 7c8cb3d

Browse files
Add manage conversation actions
1 parent d3269bb commit 7c8cb3d

10 files changed

Lines changed: 62 additions & 1 deletion

File tree

linkedapi/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@
4141
FetchPersonMapper,
4242
FetchPost,
4343
FetchPostMapper,
44+
ManageConversation,
4445
NvFetchCompany,
4546
NvFetchCompanyMapper,
4647
NvFetchPerson,
4748
NvFetchPersonMapper,
49+
NvManageConversation,
4850
NvSearchCompanies,
4951
NvSearchPeople,
5052
NvSendMessage,
@@ -105,11 +107,13 @@
105107
"LinkedApiErrorType",
106108
"LinkedApiHttpClient",
107109
"LinkedApiWorkflowTimeoutError",
110+
"ManageConversation",
108111
"MappedResponse",
109112
"NvFetchCompany",
110113
"NvFetchCompanyMapper",
111114
"NvFetchPerson",
112115
"NvFetchPersonMapper",
116+
"NvManageConversation",
113117
"NvSearchCompanies",
114118
"NvSearchPeople",
115119
"NvSendMessage",

linkedapi/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
FetchJob,
1717
FetchPerson,
1818
FetchPost,
19+
ManageConversation,
1920
NvFetchCompany,
2021
NvFetchPerson,
22+
NvManageConversation,
2123
NvSearchCompanies,
2224
NvSearchPeople,
2325
NvSendMessage,
@@ -62,6 +64,7 @@ def __init__(self, config: LinkedApiConfig | HttpClient[Any]) -> None:
6264
self.send_message = SendMessage(self.http_client)
6365
self.sync_conversation = SyncConversation(self.http_client)
6466
self.sync_inbox = SyncInbox(self.http_client)
67+
self.manage_conversation = ManageConversation(self.http_client)
6568
self.check_connection_status = CheckConnectionStatus(self.http_client)
6669
self.send_connection_request = SendConnectionRequest(self.http_client)
6770
self.withdraw_connection_request = WithdrawConnectionRequest(self.http_client)
@@ -83,6 +86,7 @@ def __init__(self, config: LinkedApiConfig | HttpClient[Any]) -> None:
8386
self.nv_send_message = NvSendMessage(self.http_client)
8487
self.nv_sync_conversation = NvSyncConversation(self.http_client)
8588
self.nv_sync_inbox = NvSyncInbox(self.http_client)
89+
self.nv_manage_conversation = NvManageConversation(self.http_client)
8690
self.nv_search_companies = NvSearchCompanies(self.http_client)
8791
self.nv_search_people = NvSearchPeople(self.http_client)
8892
self.nv_fetch_company = NvFetchCompany(self.http_client)
@@ -93,6 +97,7 @@ def __init__(self, config: LinkedApiConfig | HttpClient[Any]) -> None:
9397
self.send_message,
9498
self.sync_conversation,
9599
self.sync_inbox,
100+
self.manage_conversation,
96101
self.check_connection_status,
97102
self.send_connection_request,
98103
self.withdraw_connection_request,
@@ -114,6 +119,7 @@ def __init__(self, config: LinkedApiConfig | HttpClient[Any]) -> None:
114119
self.nv_send_message,
115120
self.nv_sync_conversation,
116121
self.nv_sync_inbox,
122+
self.nv_manage_conversation,
117123
self.nv_search_companies,
118124
self.nv_search_people,
119125
self.nv_fetch_company,

linkedapi/errors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"noPostingPermission",
2424
"noSalesNavigator",
2525
"conversationsNotSynced",
26+
"threadNotFound",
2627
]
2728
LINKED_API_ACTION_ERROR_TYPES: tuple[str, ...] = (
2829
"personNotFound",
@@ -45,6 +46,7 @@
4546
"noPostingPermission",
4647
"noSalesNavigator",
4748
"conversationsNotSynced",
49+
"threadNotFound",
4850
)
4951

5052
LinkedApiErrorType = Literal[

linkedapi/operations/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
from linkedapi.operations.fetch_job import FetchJob, FetchJobMapper
77
from linkedapi.operations.fetch_person import FetchPerson, FetchPersonMapper
88
from linkedapi.operations.fetch_post import FetchPost, FetchPostMapper
9+
from linkedapi.operations.manage_conversation import ManageConversation
910
from linkedapi.operations.nv_fetch_company import NvFetchCompany, NvFetchCompanyMapper
1011
from linkedapi.operations.nv_fetch_person import NvFetchPerson, NvFetchPersonMapper
12+
from linkedapi.operations.nv_manage_conversation import NvManageConversation
1113
from linkedapi.operations.nv_search_companies import NvSearchCompanies
1214
from linkedapi.operations.nv_search_people import NvSearchPeople
1315
from linkedapi.operations.nv_send_message import NvSendMessage
@@ -41,10 +43,12 @@
4143
"FetchPersonMapper",
4244
"FetchPost",
4345
"FetchPostMapper",
46+
"ManageConversation",
4447
"NvFetchCompany",
4548
"NvFetchCompanyMapper",
4649
"NvFetchPerson",
4750
"NvFetchPersonMapper",
51+
"NvManageConversation",
4852
"NvSearchCompanies",
4953
"NvSearchPeople",
5054
"NvSendMessage",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from __future__ import annotations
2+
3+
from linkedapi.core import Operation
4+
from linkedapi.mappers import VoidWorkflowMapper
5+
from linkedapi.types import ManageConversationParams
6+
7+
8+
class ManageConversation(Operation[ManageConversationParams, None]):
9+
"""Manage a standard LinkedIn conversation thread."""
10+
11+
operation_name = "manageConversation"
12+
mapper = VoidWorkflowMapper[ManageConversationParams]("st.manageConversation")
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from __future__ import annotations
2+
3+
from linkedapi.core import Operation
4+
from linkedapi.mappers import VoidWorkflowMapper
5+
from linkedapi.types import NvManageConversationParams
6+
7+
8+
class NvManageConversation(Operation[NvManageConversationParams, None]):
9+
"""Manage a Sales Navigator conversation thread."""
10+
11+
operation_name = "nvManageConversation"
12+
mapper = VoidWorkflowMapper[NvManageConversationParams]("nv.manageConversation")

linkedapi/types/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@
103103
ConversationType,
104104
InboxMessage,
105105
InboxPollRequest,
106+
ManageConversationParams,
106107
Message,
107108
MessageSender,
109+
NvManageConversationParams,
108110
NvSendMessageParams,
109111
NvSyncConversationParams,
110112
NvSyncInboxParams,
@@ -298,6 +300,7 @@
298300
"LinkedApiRequestError",
299301
"LinkedApiResponse",
300302
"LocationType",
303+
"ManageConversationParams",
301304
"MaxAnnualRevenue",
302305
"Message",
303306
"MessageSender",
@@ -313,6 +316,7 @@
313316
"NvCompanyEmployeeRetrievalConfig",
314317
"NvFetchCompanyParams",
315318
"NvFetchCompanyResult",
319+
"NvManageConversationParams",
316320
"NvOpenPersonPageParams",
317321
"NvOpenPersonPageResult",
318322
"NvSearchCompaniesFilter",

linkedapi/types/message.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ class SyncInboxParams(BaseActionParams):
2323
pass
2424

2525

26+
class ManageConversationParams(BaseActionParams):
27+
thread_id: str
28+
operation: str
29+
30+
2631
class NvSendMessageParams(BaseActionParams):
2732
text: str
2833
person_url: str | None = None
@@ -38,6 +43,11 @@ class NvSyncInboxParams(BaseActionParams):
3843
pass
3944

4045

46+
class NvManageConversationParams(BaseActionParams):
47+
thread_id: str
48+
operation: str
49+
50+
4151
class ConversationPollRequest(LinkedApiModel):
4252
person_url: str
4353
type: ConversationType

tests/test_errors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def test_error_type_sets_match_node_contract() -> None:
4949
"noPostingPermission",
5050
"noSalesNavigator",
5151
"conversationsNotSynced",
52+
"threadNotFound",
5253
)
5354

5455

tests/test_operations.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ def test_linked_api_exposes_all_predefined_operations() -> None:
3535
"send_message",
3636
"sync_conversation",
3737
"sync_inbox",
38+
"manage_conversation",
3839
"nv_send_message",
3940
"nv_sync_conversation",
4041
"nv_sync_inbox",
42+
"nv_manage_conversation",
4143
"react_to_post",
4244
"comment_on_post",
4345
"create_post",
@@ -50,7 +52,7 @@ def test_linked_api_exposes_all_predefined_operations() -> None:
5052
assert hasattr(operation, "execute")
5153
assert hasattr(operation, "result")
5254
assert hasattr(operation, "cancel")
53-
assert len(linkedapi.operations) == 29
55+
assert len(linkedapi.operations) == 31
5456

5557

5658
def test_operation_mappers_match_node_contract() -> None:
@@ -70,6 +72,10 @@ def test_operation_mappers_match_node_contract() -> None:
7072
assert linkedapi.sync_inbox.mapper.action_type == "st.syncInbox"
7173
assert isinstance(linkedapi.nv_sync_inbox.mapper, VoidWorkflowMapper)
7274
assert linkedapi.nv_sync_inbox.mapper.action_type == "nv.syncInbox"
75+
assert isinstance(linkedapi.manage_conversation.mapper, VoidWorkflowMapper)
76+
assert linkedapi.manage_conversation.mapper.action_type == "st.manageConversation"
77+
assert isinstance(linkedapi.nv_manage_conversation.mapper, VoidWorkflowMapper)
78+
assert linkedapi.nv_manage_conversation.mapper.action_type == "nv.manageConversation"
7379

7480

7581
def test_execute_and_result_flow_returns_pydantic_data(

0 commit comments

Comments
 (0)