Skip to content

Commit b9dbe50

Browse files
add comment interaction API
1 parent 3901c4a commit b9dbe50

12 files changed

Lines changed: 99 additions & 7 deletions

File tree

linkedapi/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@
5454
NvSendMessage,
5555
NvSyncConversation,
5656
NvSyncInbox,
57+
ReactToComment,
5758
ReactToPost,
5859
RemoveConnection,
60+
ReplyToComment,
5961
RetrieveConnections,
6062
RetrieveFeed,
6163
RetrieveInvitations,
@@ -76,7 +78,7 @@
7678
from linkedapi.types import __all__ as _types_all
7779
from linkedapi.webhooks import parse_webhook_event
7880

79-
__version__ = "1.3.4"
81+
__version__ = "1.3.5"
8082
PredefinedOperation = Operation
8183

8284
__all__ = [
@@ -128,8 +130,10 @@
128130
"NvSyncInbox",
129131
"Operation",
130132
"PredefinedOperation",
133+
"ReactToComment",
131134
"ReactToPost",
132135
"RemoveConnection",
136+
"ReplyToComment",
133137
"ResponseMapping",
134138
"RetrieveInvitations",
135139
"RetrieveConnections",

linkedapi/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@
2727
NvSendMessage,
2828
NvSyncConversation,
2929
NvSyncInbox,
30+
ReactToComment,
3031
ReactToPost,
3132
RemoveConnection,
33+
ReplyToComment,
3234
RetrieveConnections,
3335
RetrieveFeed,
3436
RetrieveInvitations,
@@ -90,6 +92,8 @@ def __init__(self, config: LinkedApiConfig | HttpClient[Any]) -> None:
9092
self.fetch_job = FetchJob(self.http_client)
9193
self.react_to_post = ReactToPost(self.http_client)
9294
self.comment_on_post = CommentOnPost(self.http_client)
95+
self.react_to_comment = ReactToComment(self.http_client)
96+
self.reply_to_comment = ReplyToComment(self.http_client)
9397
self.create_post = CreatePost(self.http_client)
9498
self.retrieve_feed = RetrieveFeed(self.http_client)
9599
self.retrieve_ssi = RetrieveSSI(self.http_client)
@@ -128,6 +132,8 @@ def __init__(self, config: LinkedApiConfig | HttpClient[Any]) -> None:
128132
self.fetch_job,
129133
self.react_to_post,
130134
self.comment_on_post,
135+
self.react_to_comment,
136+
self.reply_to_comment,
131137
self.create_post,
132138
self.retrieve_feed,
133139
self.retrieve_ssi,

linkedapi/errors.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
"postNotFound",
2121
"jobNotFound",
2222
"commentingNotAllowed",
23+
"commentNotFound",
24+
"replyingNotAllowed",
2325
"noPostingPermission",
2426
"noSalesNavigator",
2527
"conversationsNotSynced",
@@ -43,6 +45,8 @@
4345
"postNotFound",
4446
"jobNotFound",
4547
"commentingNotAllowed",
48+
"commentNotFound",
49+
"replyingNotAllowed",
4650
"noPostingPermission",
4751
"noSalesNavigator",
4852
"conversationsNotSynced",

linkedapi/operations/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
from linkedapi.operations.nv_send_message import NvSendMessage
1818
from linkedapi.operations.nv_sync_conversation import NvSyncConversation
1919
from linkedapi.operations.nv_sync_inbox import NvSyncInbox
20+
from linkedapi.operations.react_to_comment import ReactToComment
2021
from linkedapi.operations.react_to_post import ReactToPost
2122
from linkedapi.operations.remove_connection import RemoveConnection
23+
from linkedapi.operations.reply_to_comment import ReplyToComment
2224
from linkedapi.operations.retrieve_connections import RetrieveConnections
2325
from linkedapi.operations.retrieve_feed import RetrieveFeed
2426
from linkedapi.operations.retrieve_invitations import RetrieveInvitations
@@ -61,8 +63,10 @@
6163
"NvSendMessage",
6264
"NvSyncConversation",
6365
"NvSyncInbox",
66+
"ReactToComment",
6467
"ReactToPost",
6568
"RemoveConnection",
69+
"ReplyToComment",
6670
"RetrieveConnections",
6771
"RetrieveFeed",
6872
"RetrieveInvitations",
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
from __future__ import annotations
22

33
from linkedapi.core import Operation
4-
from linkedapi.mappers import VoidWorkflowMapper
5-
from linkedapi.types import CommentOnPostParams
4+
from linkedapi.mappers import SimpleWorkflowMapper
5+
from linkedapi.types import CommentOnPostParams, CommentResult
66

77

8-
class CommentOnPost(Operation[CommentOnPostParams, None]):
8+
class CommentOnPost(Operation[CommentOnPostParams, CommentResult]):
99
"""Comment on a LinkedIn post."""
1010

1111
operation_name = "commentOnPost"
12-
mapper = VoidWorkflowMapper[CommentOnPostParams]("st.commentOnPost")
12+
mapper = SimpleWorkflowMapper[CommentOnPostParams, CommentResult](
13+
"st.commentOnPost",
14+
result_model=CommentResult,
15+
)
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 ReactToCommentParams
6+
7+
8+
class ReactToComment(Operation[ReactToCommentParams, None]):
9+
"""React to a LinkedIn comment."""
10+
11+
operation_name = "reactToComment"
12+
mapper = VoidWorkflowMapper[ReactToCommentParams]("st.reactToComment")
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 CommentResult, ReplyToCommentParams
6+
7+
8+
class ReplyToComment(Operation[ReplyToCommentParams, CommentResult]):
9+
"""Reply to a LinkedIn comment."""
10+
11+
operation_name = "replyToComment"
12+
mapper = SimpleWorkflowMapper[ReplyToCommentParams, CommentResult](
13+
"st.replyToComment",
14+
result_model=CommentResult,
15+
)

linkedapi/types/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@
149149
BaseFetchPostParamsWide,
150150
Comment,
151151
CommentOnPostParams,
152+
CommentOnPostResult,
153+
CommentResult,
152154
CreatePostAttachment,
153155
CreatePostParams,
154156
CreatePostResult,
@@ -168,7 +170,10 @@
168170
PostType,
169171
Reaction,
170172
ReactionType,
173+
ReactToCommentParams,
171174
ReactToPostParams,
175+
ReplyToCommentParams,
176+
ReplyToCommentResult,
172177
)
173178
from linkedapi.types.responses import LinkedApiRequestError, LinkedApiResponse
174179
from linkedapi.types.search_companies import (
@@ -262,6 +267,8 @@
262267
"CheckConnectionStatusResult",
263268
"Comment",
264269
"CommentOnPostParams",
270+
"CommentOnPostResult",
271+
"CommentResult",
265272
"Company",
266273
"ConnectionPerson",
267274
"ConnectionSession",
@@ -372,6 +379,7 @@
372379
"PostReactionsRetrievalConfig",
373380
"PostReposter",
374381
"PostType",
382+
"ReactToCommentParams",
375383
"ReactToPostParams",
376384
"Reaction",
377385
"ReactionType",
@@ -381,6 +389,8 @@
381389
"ReparseAccountInfoParams",
382390
"ReparseAccountInfoResult",
383391
"ReplayWebhookDeliveryParams",
392+
"ReplyToCommentParams",
393+
"ReplyToCommentResult",
384394
"ResetLimitsParams",
385395
"RetrieveConnectionsFilter",
386396
"RetrieveConnectionsParams",

linkedapi/types/post.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,30 @@ class CommentOnPostParams(BaseActionParams):
4040
company_url: str | None = None
4141

4242

43+
class CommentResult(LinkedApiModel):
44+
comment_urn: str | None = None
45+
comment_url: str | None = None
46+
47+
48+
CommentOnPostResult: TypeAlias = CommentResult
49+
50+
51+
class ReactToCommentParams(BaseActionParams):
52+
comment_url: str
53+
type: ReactionType = "like"
54+
55+
56+
class ReplyToCommentParams(BaseActionParams):
57+
comment_url: str
58+
text: str
59+
60+
61+
ReplyToCommentResult: TypeAlias = CommentResult
62+
63+
4364
class PostComment(LinkedApiModel):
65+
comment_urn: str | None = None
66+
comment_url: str | None = None
4467
commenter_url: str | None = None
4568
commenter_name: str | None = None
4669
commenter_headline: str | None = None

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "linkedapi"
7-
version = "1.3.4"
7+
version = "1.3.5"
88
description = "Official synchronous Python SDK for Linked API."
99
readme = "README.md"
1010
requires-python = ">=3.10"

0 commit comments

Comments
 (0)