linkedapi 1.0.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.
Files changed (72) hide show
  1. linkedapi/__init__.py +127 -0
  2. linkedapi/admin/__init__.py +13 -0
  3. linkedapi/admin/accounts.py +91 -0
  4. linkedapi/admin/admin.py +22 -0
  5. linkedapi/admin/http_client.py +73 -0
  6. linkedapi/admin/limits.py +70 -0
  7. linkedapi/admin/subscription.py +69 -0
  8. linkedapi/client.py +160 -0
  9. linkedapi/config.py +10 -0
  10. linkedapi/core/__init__.py +4 -0
  11. linkedapi/core/operation.py +89 -0
  12. linkedapi/core/polling.py +48 -0
  13. linkedapi/errors.py +119 -0
  14. linkedapi/http/__init__.py +4 -0
  15. linkedapi/http/base.py +22 -0
  16. linkedapi/http/linked_api_http_client.py +74 -0
  17. linkedapi/mappers/__init__.py +16 -0
  18. linkedapi/mappers/array.py +49 -0
  19. linkedapi/mappers/base.py +70 -0
  20. linkedapi/mappers/simple.py +56 -0
  21. linkedapi/mappers/then.py +175 -0
  22. linkedapi/mappers/void.py +33 -0
  23. linkedapi/operations/__init__.py +58 -0
  24. linkedapi/operations/check_connection_status.py +15 -0
  25. linkedapi/operations/comment_on_post.py +12 -0
  26. linkedapi/operations/create_post.py +15 -0
  27. linkedapi/operations/custom_workflow.py +22 -0
  28. linkedapi/operations/fetch_company.py +35 -0
  29. linkedapi/operations/fetch_person.py +43 -0
  30. linkedapi/operations/fetch_post.py +33 -0
  31. linkedapi/operations/nv_fetch_company.py +33 -0
  32. linkedapi/operations/nv_fetch_person.py +23 -0
  33. linkedapi/operations/nv_search_companies.py +15 -0
  34. linkedapi/operations/nv_search_people.py +15 -0
  35. linkedapi/operations/nv_send_message.py +12 -0
  36. linkedapi/operations/nv_sync_conversation.py +12 -0
  37. linkedapi/operations/react_to_post.py +12 -0
  38. linkedapi/operations/remove_connection.py +12 -0
  39. linkedapi/operations/retrieve_connections.py +15 -0
  40. linkedapi/operations/retrieve_pending_requests.py +15 -0
  41. linkedapi/operations/retrieve_performance.py +15 -0
  42. linkedapi/operations/retrieve_ssi.py +15 -0
  43. linkedapi/operations/search_companies.py +15 -0
  44. linkedapi/operations/search_people.py +15 -0
  45. linkedapi/operations/send_connection_request.py +12 -0
  46. linkedapi/operations/send_message.py +12 -0
  47. linkedapi/operations/sync_conversation.py +12 -0
  48. linkedapi/operations/withdraw_connection_request.py +12 -0
  49. linkedapi/py.typed +1 -0
  50. linkedapi/types/__init__.py +336 -0
  51. linkedapi/types/account.py +8 -0
  52. linkedapi/types/admin/__init__.py +91 -0
  53. linkedapi/types/admin/accounts.py +71 -0
  54. linkedapi/types/admin/config.py +8 -0
  55. linkedapi/types/admin/limits.py +77 -0
  56. linkedapi/types/admin/subscription.py +58 -0
  57. linkedapi/types/base.py +47 -0
  58. linkedapi/types/company.py +140 -0
  59. linkedapi/types/connection.py +86 -0
  60. linkedapi/types/message.py +48 -0
  61. linkedapi/types/params.py +15 -0
  62. linkedapi/types/person.py +105 -0
  63. linkedapi/types/post.py +119 -0
  64. linkedapi/types/responses.py +18 -0
  65. linkedapi/types/search_companies.py +72 -0
  66. linkedapi/types/search_people.py +46 -0
  67. linkedapi/types/statistics.py +27 -0
  68. linkedapi/types/workflow.py +55 -0
  69. linkedapi-1.0.0.dist-info/METADATA +125 -0
  70. linkedapi-1.0.0.dist-info/RECORD +72 -0
  71. linkedapi-1.0.0.dist-info/WHEEL +4 -0
  72. linkedapi-1.0.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,175 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Callable
4
+ from dataclasses import dataclass
5
+ from typing import Any, Generic, TypeVar, cast
6
+
7
+ from pydantic import BaseModel
8
+
9
+ from linkedapi.errors import LinkedApiError
10
+ from linkedapi.mappers.base import (
11
+ BaseMapper,
12
+ MappedResponse,
13
+ as_action_dict,
14
+ collect_action_errors,
15
+ parse_action_error,
16
+ parse_result,
17
+ )
18
+ from linkedapi.types import (
19
+ WorkflowCompletion,
20
+ WorkflowDefinition,
21
+ dump_model_by_name,
22
+ serialize_model,
23
+ )
24
+ from linkedapi.types.base import to_camel
25
+
26
+ TParams = TypeVar("TParams")
27
+ TResult = TypeVar("TResult")
28
+
29
+
30
+ @dataclass(frozen=True)
31
+ class ActionConfig:
32
+ param_name: str
33
+ action_type: str
34
+ config_source: str | None = None
35
+
36
+
37
+ @dataclass(frozen=True)
38
+ class ResponseMapping:
39
+ action_type: str
40
+ target_property: str
41
+
42
+
43
+ class ThenWorkflowMapper(BaseMapper[TParams, TResult], Generic[TParams, TResult]):
44
+ def __init__(
45
+ self,
46
+ action_configs: list[ActionConfig],
47
+ response_mappings: list[ResponseMapping],
48
+ base_action_type: str,
49
+ default_params: dict[str, Any] | None = None,
50
+ result_model: type[BaseModel] | None = None,
51
+ ) -> None:
52
+ self.action_configs = action_configs
53
+ self.response_mappings = response_mappings
54
+ self.base_action_type = base_action_type
55
+ self.default_params = default_params or {}
56
+ self.result_model = result_model
57
+
58
+ def map_request(self, params: TParams | None = None) -> WorkflowDefinition:
59
+ alias_params = serialize_model(params)
60
+ name_params = dump_model_by_name(params)
61
+ resolve_alias = _make_alias_resolver(params)
62
+ then = self._build_then_for_request(alias_params, name_params, resolve_alias)
63
+ clear_params = self._clear_params(alias_params, resolve_alias)
64
+ return {
65
+ "actionType": self.base_action_type,
66
+ **self.default_params,
67
+ **clear_params,
68
+ "then": then,
69
+ }
70
+
71
+ def map_response(self, completion: WorkflowCompletion) -> MappedResponse[TResult]:
72
+ if isinstance(completion, list):
73
+ data = [
74
+ as_action_dict(action).get("data")
75
+ for action in completion
76
+ if as_action_dict(action).get("data")
77
+ ]
78
+ errors = collect_action_errors(
79
+ [as_action_dict(action).get("error") for action in completion]
80
+ )
81
+ return MappedResponse(
82
+ data=cast(TResult, parse_result(data, self.result_model)), errors=errors
83
+ )
84
+
85
+ action = as_action_dict(completion)
86
+ error = parse_action_error(action.get("error"))
87
+ if error is not None:
88
+ return MappedResponse(data=None, errors=[error])
89
+ single_data = action.get("data")
90
+ if single_data is not None:
91
+ return self._map_then_from_response(as_action_dict(single_data))
92
+ raise LinkedApiError.unknown_error()
93
+
94
+ def _map_then_from_response(self, data: dict[str, Any]) -> MappedResponse[TResult]:
95
+ result = {**data}
96
+ then_actions = data.get("then")
97
+ errors: list[Any] = []
98
+
99
+ if not then_actions:
100
+ result.pop("then", None)
101
+ return MappedResponse(
102
+ data=cast(TResult, parse_result(result, self.result_model)),
103
+ errors=[],
104
+ )
105
+
106
+ for mapping in self.response_mappings:
107
+ if isinstance(then_actions, list) and then_actions:
108
+ then_action = self._find_then_action(then_actions, mapping.action_type)
109
+ if then_action is not None:
110
+ result[mapping.target_property] = then_action.get("data")
111
+ errors.append(then_action.get("error"))
112
+ continue
113
+
114
+ then_action = as_action_dict(then_actions)
115
+ if then_action.get("actionType") == mapping.action_type:
116
+ result[mapping.target_property] = then_action.get("data")
117
+ errors.append(then_action.get("error"))
118
+
119
+ result.pop("then", None)
120
+ return MappedResponse(
121
+ data=cast(TResult, parse_result(result, self.result_model)),
122
+ errors=collect_action_errors(errors),
123
+ )
124
+
125
+ def _build_then_for_request(
126
+ self,
127
+ alias_params: dict[str, Any],
128
+ name_params: dict[str, Any],
129
+ resolve_alias: AliasResolver,
130
+ ) -> list[dict[str, Any]]:
131
+ actions: list[dict[str, Any]] = []
132
+ for config in self.action_configs:
133
+ if name_params.get(config.param_name) is True:
134
+ action = {"actionType": config.action_type}
135
+ if config.config_source:
136
+ action.update(alias_params.get(resolve_alias(config.config_source), {}))
137
+ actions.append(action)
138
+ return actions
139
+
140
+ def _clear_params(
141
+ self,
142
+ params: dict[str, Any],
143
+ resolve_alias: AliasResolver,
144
+ ) -> dict[str, Any]:
145
+ cleaned_params = {**params}
146
+ for config in self.action_configs:
147
+ cleaned_params.pop(resolve_alias(config.param_name), None)
148
+ if config.config_source:
149
+ cleaned_params.pop(resolve_alias(config.config_source), None)
150
+ return cleaned_params
151
+
152
+ def _find_then_action(self, actions: list[Any], action_type: str) -> dict[str, Any] | None:
153
+ for action in actions:
154
+ action_dict = as_action_dict(action)
155
+ if action_dict.get("actionType") == action_type:
156
+ return action_dict
157
+ return None
158
+
159
+
160
+ AliasResolver = Callable[[str], str]
161
+
162
+
163
+ def _make_alias_resolver(params: Any) -> AliasResolver:
164
+ """Resolve a field's serialized key from the params model, mirroring its
165
+ explicit pydantic alias (e.g. ``retrieve_dms`` -> ``retrieveDMs``) and
166
+ falling back to ``to_camel`` for fields without one."""
167
+ fields = type(params).model_fields if isinstance(params, BaseModel) else {}
168
+
169
+ def resolve(name: str) -> str:
170
+ field = fields.get(name)
171
+ if field is not None and field.alias:
172
+ return field.alias
173
+ return to_camel(name)
174
+
175
+ return resolve
@@ -0,0 +1,33 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Generic, TypeVar
4
+
5
+ from linkedapi.mappers.base import (
6
+ BaseMapper,
7
+ MappedResponse,
8
+ as_action_dict,
9
+ collect_action_errors,
10
+ parse_action_error,
11
+ )
12
+ from linkedapi.types import WorkflowCompletion, WorkflowDefinition, serialize_model
13
+
14
+ TParams = TypeVar("TParams")
15
+
16
+
17
+ class VoidWorkflowMapper(BaseMapper[TParams, None], Generic[TParams]):
18
+ def __init__(self, action_type: str) -> None:
19
+ self.action_type = action_type
20
+
21
+ def map_request(self, params: TParams | None = None) -> WorkflowDefinition:
22
+ return {"actionType": self.action_type, **serialize_model(params)}
23
+
24
+ def map_response(self, completion: WorkflowCompletion) -> MappedResponse[None]:
25
+ if isinstance(completion, list):
26
+ errors = collect_action_errors(
27
+ [as_action_dict(action).get("error") for action in completion]
28
+ )
29
+ return MappedResponse(data=None, errors=errors)
30
+
31
+ action = as_action_dict(completion)
32
+ error = parse_action_error(action.get("error"))
33
+ return MappedResponse(data=None, errors=[] if error is None else [error])
@@ -0,0 +1,58 @@
1
+ from linkedapi.operations.check_connection_status import CheckConnectionStatus
2
+ from linkedapi.operations.comment_on_post import CommentOnPost
3
+ from linkedapi.operations.create_post import CreatePost
4
+ from linkedapi.operations.custom_workflow import CustomWorkflow
5
+ from linkedapi.operations.fetch_company import FetchCompany, FetchCompanyMapper
6
+ from linkedapi.operations.fetch_person import FetchPerson, FetchPersonMapper
7
+ from linkedapi.operations.fetch_post import FetchPost, FetchPostMapper
8
+ from linkedapi.operations.nv_fetch_company import NvFetchCompany, NvFetchCompanyMapper
9
+ from linkedapi.operations.nv_fetch_person import NvFetchPerson, NvFetchPersonMapper
10
+ from linkedapi.operations.nv_search_companies import NvSearchCompanies
11
+ from linkedapi.operations.nv_search_people import NvSearchPeople
12
+ from linkedapi.operations.nv_send_message import NvSendMessage
13
+ from linkedapi.operations.nv_sync_conversation import NvSyncConversation
14
+ from linkedapi.operations.react_to_post import ReactToPost
15
+ from linkedapi.operations.remove_connection import RemoveConnection
16
+ from linkedapi.operations.retrieve_connections import RetrieveConnections
17
+ from linkedapi.operations.retrieve_pending_requests import RetrievePendingRequests
18
+ from linkedapi.operations.retrieve_performance import RetrievePerformance
19
+ from linkedapi.operations.retrieve_ssi import RetrieveSSI
20
+ from linkedapi.operations.search_companies import SearchCompanies
21
+ from linkedapi.operations.search_people import SearchPeople
22
+ from linkedapi.operations.send_connection_request import SendConnectionRequest
23
+ from linkedapi.operations.send_message import SendMessage
24
+ from linkedapi.operations.sync_conversation import SyncConversation
25
+ from linkedapi.operations.withdraw_connection_request import WithdrawConnectionRequest
26
+
27
+ __all__ = [
28
+ "CheckConnectionStatus",
29
+ "CommentOnPost",
30
+ "CreatePost",
31
+ "CustomWorkflow",
32
+ "FetchCompany",
33
+ "FetchCompanyMapper",
34
+ "FetchPerson",
35
+ "FetchPersonMapper",
36
+ "FetchPost",
37
+ "FetchPostMapper",
38
+ "NvFetchCompany",
39
+ "NvFetchCompanyMapper",
40
+ "NvFetchPerson",
41
+ "NvFetchPersonMapper",
42
+ "NvSearchCompanies",
43
+ "NvSearchPeople",
44
+ "NvSendMessage",
45
+ "NvSyncConversation",
46
+ "ReactToPost",
47
+ "RemoveConnection",
48
+ "RetrieveConnections",
49
+ "RetrievePendingRequests",
50
+ "RetrievePerformance",
51
+ "RetrieveSSI",
52
+ "SearchCompanies",
53
+ "SearchPeople",
54
+ "SendConnectionRequest",
55
+ "SendMessage",
56
+ "SyncConversation",
57
+ "WithdrawConnectionRequest",
58
+ ]
@@ -0,0 +1,15 @@
1
+ from __future__ import annotations
2
+
3
+ from linkedapi.core import Operation
4
+ from linkedapi.mappers import SimpleWorkflowMapper
5
+ from linkedapi.types import CheckConnectionStatusParams, CheckConnectionStatusResult
6
+
7
+
8
+ class CheckConnectionStatus(Operation[CheckConnectionStatusParams, CheckConnectionStatusResult]):
9
+ """Check a standard LinkedIn connection status."""
10
+
11
+ operation_name = "checkConnectionStatus"
12
+ mapper = SimpleWorkflowMapper[CheckConnectionStatusParams, CheckConnectionStatusResult](
13
+ "st.checkConnectionStatus",
14
+ result_model=CheckConnectionStatusResult,
15
+ )
@@ -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 CommentOnPostParams
6
+
7
+
8
+ class CommentOnPost(Operation[CommentOnPostParams, None]):
9
+ """Comment on a LinkedIn post."""
10
+
11
+ operation_name = "commentOnPost"
12
+ mapper = VoidWorkflowMapper[CommentOnPostParams]("st.commentOnPost")
@@ -0,0 +1,15 @@
1
+ from __future__ import annotations
2
+
3
+ from linkedapi.core import Operation
4
+ from linkedapi.mappers import SimpleWorkflowMapper
5
+ from linkedapi.types import CreatePostParams, CreatePostResult
6
+
7
+
8
+ class CreatePost(Operation[CreatePostParams, CreatePostResult]):
9
+ """Create a LinkedIn post."""
10
+
11
+ operation_name = "createPost"
12
+ mapper = SimpleWorkflowMapper[CreatePostParams, CreatePostResult](
13
+ "st.createPost",
14
+ result_model=CreatePostResult,
15
+ )
@@ -0,0 +1,22 @@
1
+ from __future__ import annotations
2
+
3
+ from linkedapi.core import Operation
4
+ from linkedapi.mappers import BaseMapper, MappedResponse
5
+ from linkedapi.types import WorkflowCompletion, WorkflowDefinition
6
+
7
+
8
+ class _CustomWorkflowMapper(BaseMapper[WorkflowDefinition, WorkflowCompletion]):
9
+ def map_request(self, params: WorkflowDefinition | None = None) -> WorkflowDefinition:
10
+ if params is None:
11
+ return {}
12
+ return params
13
+
14
+ def map_response(self, completion: WorkflowCompletion) -> MappedResponse[WorkflowCompletion]:
15
+ return MappedResponse(data=completion, errors=[])
16
+
17
+
18
+ class CustomWorkflow(Operation[WorkflowDefinition, WorkflowCompletion]):
19
+ """Execute raw Linked API workflow definitions."""
20
+
21
+ operation_name = "customWorkflow"
22
+ mapper = _CustomWorkflowMapper()
@@ -0,0 +1,35 @@
1
+ from __future__ import annotations
2
+
3
+ from linkedapi.core import Operation
4
+ from linkedapi.mappers import ActionConfig, ResponseMapping, ThenWorkflowMapper
5
+ from linkedapi.types import Company, FetchCompanyParams
6
+
7
+
8
+ class FetchCompanyMapper(ThenWorkflowMapper[FetchCompanyParams, Company]):
9
+ def __init__(self) -> None:
10
+ super().__init__(
11
+ action_configs=[
12
+ ActionConfig(
13
+ "retrieve_employees",
14
+ "st.retrieveCompanyEmployees",
15
+ "employees_retrieval_config",
16
+ ),
17
+ ActionConfig("retrieve_dms", "st.retrieveCompanyDMs", "dms_retrieval_config"),
18
+ ActionConfig("retrieve_posts", "st.retrieveCompanyPosts", "posts_retrieval_config"),
19
+ ],
20
+ response_mappings=[
21
+ ResponseMapping("st.retrieveCompanyEmployees", "employees"),
22
+ ResponseMapping("st.retrieveCompanyDMs", "dms"),
23
+ ResponseMapping("st.retrieveCompanyPosts", "posts"),
24
+ ],
25
+ base_action_type="st.openCompanyPage",
26
+ default_params={"basicInfo": True},
27
+ result_model=Company,
28
+ )
29
+
30
+
31
+ class FetchCompany(Operation[FetchCompanyParams, Company]):
32
+ """Fetch a standard LinkedIn company page."""
33
+
34
+ operation_name = "fetchCompany"
35
+ mapper = FetchCompanyMapper()
@@ -0,0 +1,43 @@
1
+ from __future__ import annotations
2
+
3
+ from linkedapi.core import Operation
4
+ from linkedapi.mappers import ActionConfig, ResponseMapping, ThenWorkflowMapper
5
+ from linkedapi.types import FetchPersonParams, Person
6
+
7
+
8
+ class FetchPersonMapper(ThenWorkflowMapper[FetchPersonParams, Person]):
9
+ def __init__(self) -> None:
10
+ super().__init__(
11
+ action_configs=[
12
+ ActionConfig("retrieve_experience", "st.retrievePersonExperience"),
13
+ ActionConfig("retrieve_education", "st.retrievePersonEducation"),
14
+ ActionConfig("retrieve_skills", "st.retrievePersonSkills"),
15
+ ActionConfig("retrieve_languages", "st.retrievePersonLanguages"),
16
+ ActionConfig("retrieve_posts", "st.retrievePersonPosts", "posts_retrieval_config"),
17
+ ActionConfig(
18
+ "retrieve_comments", "st.retrievePersonComments", "comments_retrieval_config"
19
+ ),
20
+ ActionConfig(
21
+ "retrieve_reactions", "st.retrievePersonReactions", "reactions_retrieval_config"
22
+ ),
23
+ ],
24
+ response_mappings=[
25
+ ResponseMapping("st.retrievePersonExperience", "experiences"),
26
+ ResponseMapping("st.retrievePersonEducation", "education"),
27
+ ResponseMapping("st.retrievePersonSkills", "skills"),
28
+ ResponseMapping("st.retrievePersonLanguages", "languages"),
29
+ ResponseMapping("st.retrievePersonPosts", "posts"),
30
+ ResponseMapping("st.retrievePersonComments", "comments"),
31
+ ResponseMapping("st.retrievePersonReactions", "reactions"),
32
+ ],
33
+ base_action_type="st.openPersonPage",
34
+ default_params={"basicInfo": True},
35
+ result_model=Person,
36
+ )
37
+
38
+
39
+ class FetchPerson(Operation[FetchPersonParams, Person]):
40
+ """Fetch a standard LinkedIn person profile."""
41
+
42
+ operation_name = "fetchPerson"
43
+ mapper = FetchPersonMapper()
@@ -0,0 +1,33 @@
1
+ from __future__ import annotations
2
+
3
+ from linkedapi.core import Operation
4
+ from linkedapi.mappers import ActionConfig, ResponseMapping, ThenWorkflowMapper
5
+ from linkedapi.types import FetchPostParams, Post
6
+
7
+
8
+ class FetchPostMapper(ThenWorkflowMapper[FetchPostParams, Post]):
9
+ def __init__(self) -> None:
10
+ super().__init__(
11
+ action_configs=[
12
+ ActionConfig(
13
+ "retrieve_comments", "st.retrievePostComments", "comments_retrieval_config"
14
+ ),
15
+ ActionConfig(
16
+ "retrieve_reactions", "st.retrievePostReactions", "reactions_retrieval_config"
17
+ ),
18
+ ],
19
+ response_mappings=[
20
+ ResponseMapping("st.retrievePostComments", "comments"),
21
+ ResponseMapping("st.retrievePostReactions", "reactions"),
22
+ ],
23
+ base_action_type="st.openPost",
24
+ default_params={"basicInfo": True},
25
+ result_model=Post,
26
+ )
27
+
28
+
29
+ class FetchPost(Operation[FetchPostParams, Post]):
30
+ """Fetch a LinkedIn post."""
31
+
32
+ operation_name = "fetchPost"
33
+ mapper = FetchPostMapper()
@@ -0,0 +1,33 @@
1
+ from __future__ import annotations
2
+
3
+ from linkedapi.core import Operation
4
+ from linkedapi.mappers import ActionConfig, ResponseMapping, ThenWorkflowMapper
5
+ from linkedapi.types import NvCompany, NvFetchCompanyParams
6
+
7
+
8
+ class NvFetchCompanyMapper(ThenWorkflowMapper[NvFetchCompanyParams, NvCompany]):
9
+ def __init__(self) -> None:
10
+ super().__init__(
11
+ action_configs=[
12
+ ActionConfig(
13
+ "retrieve_employees",
14
+ "nv.retrieveCompanyEmployees",
15
+ "employees_retrieval_config",
16
+ ),
17
+ ActionConfig("retrieve_dms", "nv.retrieveCompanyDMs", "dms_retrieval_config"),
18
+ ],
19
+ response_mappings=[
20
+ ResponseMapping("nv.retrieveCompanyEmployees", "employees"),
21
+ ResponseMapping("nv.retrieveCompanyDMs", "dms"),
22
+ ],
23
+ base_action_type="nv.openCompanyPage",
24
+ default_params={"basicInfo": True},
25
+ result_model=NvCompany,
26
+ )
27
+
28
+
29
+ class NvFetchCompany(Operation[NvFetchCompanyParams, NvCompany]):
30
+ """Fetch a Sales Navigator company page."""
31
+
32
+ operation_name = "nvFetchCompany"
33
+ mapper = NvFetchCompanyMapper()
@@ -0,0 +1,23 @@
1
+ from __future__ import annotations
2
+
3
+ from linkedapi.core import Operation
4
+ from linkedapi.mappers import ThenWorkflowMapper
5
+ from linkedapi.types import NvOpenPersonPageParams, NvOpenPersonPageResult
6
+
7
+
8
+ class NvFetchPersonMapper(ThenWorkflowMapper[NvOpenPersonPageParams, NvOpenPersonPageResult]):
9
+ def __init__(self) -> None:
10
+ super().__init__(
11
+ action_configs=[],
12
+ response_mappings=[],
13
+ base_action_type="nv.openPersonPage",
14
+ default_params={"basicInfo": True},
15
+ result_model=NvOpenPersonPageResult,
16
+ )
17
+
18
+
19
+ class NvFetchPerson(Operation[NvOpenPersonPageParams, NvOpenPersonPageResult]):
20
+ """Fetch a Sales Navigator person profile."""
21
+
22
+ operation_name = "nvFetchPerson"
23
+ mapper = NvFetchPersonMapper()
@@ -0,0 +1,15 @@
1
+ from __future__ import annotations
2
+
3
+ from linkedapi.core import Operation
4
+ from linkedapi.mappers import ArrayWorkflowMapper
5
+ from linkedapi.types import NvSearchCompaniesParams, NvSearchCompanyResult
6
+
7
+
8
+ class NvSearchCompanies(Operation[NvSearchCompaniesParams, list[NvSearchCompanyResult]]):
9
+ """Search companies on Sales Navigator."""
10
+
11
+ operation_name = "nvSearchCompanies"
12
+ mapper = ArrayWorkflowMapper[NvSearchCompaniesParams, NvSearchCompanyResult](
13
+ "nv.searchCompanies",
14
+ NvSearchCompanyResult,
15
+ )
@@ -0,0 +1,15 @@
1
+ from __future__ import annotations
2
+
3
+ from linkedapi.core import Operation
4
+ from linkedapi.mappers import ArrayWorkflowMapper
5
+ from linkedapi.types import NvSearchPeopleParams, NvSearchPeopleResult
6
+
7
+
8
+ class NvSearchPeople(Operation[NvSearchPeopleParams, list[NvSearchPeopleResult]]):
9
+ """Search people on Sales Navigator."""
10
+
11
+ operation_name = "nvSearchPeople"
12
+ mapper = ArrayWorkflowMapper[NvSearchPeopleParams, NvSearchPeopleResult](
13
+ "nv.searchPeople",
14
+ NvSearchPeopleResult,
15
+ )
@@ -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 NvSendMessageParams
6
+
7
+
8
+ class NvSendMessage(Operation[NvSendMessageParams, None]):
9
+ """Send a Sales Navigator message."""
10
+
11
+ operation_name = "nvSendMessage"
12
+ mapper = VoidWorkflowMapper[NvSendMessageParams]("nv.sendMessage")
@@ -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 NvSyncConversationParams
6
+
7
+
8
+ class NvSyncConversation(Operation[NvSyncConversationParams, None]):
9
+ """Sync a Sales Navigator conversation."""
10
+
11
+ operation_name = "nvSyncConversation"
12
+ mapper = VoidWorkflowMapper[NvSyncConversationParams]("nv.syncConversation")
@@ -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 ReactToPostParams
6
+
7
+
8
+ class ReactToPost(Operation[ReactToPostParams, None]):
9
+ """React to a LinkedIn post."""
10
+
11
+ operation_name = "reactToPost"
12
+ mapper = VoidWorkflowMapper[ReactToPostParams]("st.reactToPost")
@@ -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 RemoveConnectionParams
6
+
7
+
8
+ class RemoveConnection(Operation[RemoveConnectionParams, None]):
9
+ """Remove a standard LinkedIn connection."""
10
+
11
+ operation_name = "removeConnection"
12
+ mapper = VoidWorkflowMapper[RemoveConnectionParams]("st.removeConnection")
@@ -0,0 +1,15 @@
1
+ from __future__ import annotations
2
+
3
+ from linkedapi.core import Operation
4
+ from linkedapi.mappers import ArrayWorkflowMapper
5
+ from linkedapi.types import RetrieveConnectionsParams, RetrieveConnectionsResult
6
+
7
+
8
+ class RetrieveConnections(Operation[RetrieveConnectionsParams, list[RetrieveConnectionsResult]]):
9
+ """Retrieve standard LinkedIn connections."""
10
+
11
+ operation_name = "retrieveConnections"
12
+ mapper = ArrayWorkflowMapper[RetrieveConnectionsParams, RetrieveConnectionsResult](
13
+ "st.retrieveConnections",
14
+ RetrieveConnectionsResult,
15
+ )
@@ -0,0 +1,15 @@
1
+ from __future__ import annotations
2
+
3
+ from linkedapi.core import Operation
4
+ from linkedapi.mappers import ArrayWorkflowMapper
5
+ from linkedapi.types import RetrievePendingRequestsResult
6
+
7
+
8
+ class RetrievePendingRequests(Operation[None, list[RetrievePendingRequestsResult]]):
9
+ """Retrieve pending standard LinkedIn connection requests."""
10
+
11
+ operation_name = "retrievePendingRequests"
12
+ mapper = ArrayWorkflowMapper[None, RetrievePendingRequestsResult](
13
+ "st.retrievePendingRequests",
14
+ RetrievePendingRequestsResult,
15
+ )
@@ -0,0 +1,15 @@
1
+ from __future__ import annotations
2
+
3
+ from linkedapi.core import Operation
4
+ from linkedapi.mappers import SimpleWorkflowMapper
5
+ from linkedapi.types import RetrievePerformanceResult
6
+
7
+
8
+ class RetrievePerformance(Operation[None, RetrievePerformanceResult]):
9
+ """Retrieve LinkedIn performance metrics."""
10
+
11
+ operation_name = "retrievePerformance"
12
+ mapper = SimpleWorkflowMapper[None, RetrievePerformanceResult](
13
+ "st.retrievePerformance",
14
+ result_model=RetrievePerformanceResult,
15
+ )
@@ -0,0 +1,15 @@
1
+ from __future__ import annotations
2
+
3
+ from linkedapi.core import Operation
4
+ from linkedapi.mappers import SimpleWorkflowMapper
5
+ from linkedapi.types import RetrieveSSIResult
6
+
7
+
8
+ class RetrieveSSI(Operation[None, RetrieveSSIResult]):
9
+ """Retrieve LinkedIn SSI metrics."""
10
+
11
+ operation_name = "retrieveSSI"
12
+ mapper = SimpleWorkflowMapper[None, RetrieveSSIResult](
13
+ "st.retrieveSSI",
14
+ result_model=RetrieveSSIResult,
15
+ )