Skip to content

Commit

Permalink
feat(company): add follow_company method to follow a company (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
mekahell authored Aug 26, 2024
1 parent b6af474 commit 72ecd29
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
19 changes: 19 additions & 0 deletions linkedin_api/linkedin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,25 @@ def get_company(self, public_id):

return company

def follow_company(self, following_state_urn, following = True):
"""Follow a company from its ID.
:param following_state_urn: LinkedIn State URN to append to URL to follow the company
:type following_state_urn: str
:param following: The following state to set. True by default for following the company
:type following: bool, optional
:return: Error state. If True, an error occured.
:rtype: boolean
"""
payload = json.dumps({"patch": {"$set": {"following": following}}})

res = self._post(
f"/feed/dash/followingStates/{following_state_urn}", data=payload
)

return res.status_code != 200

def get_conversation_details(self, profile_urn_id):
"""Fetch conversation (message thread) details for a given LinkedIn profile.
Expand Down
11 changes: 11 additions & 0 deletions tests/test_linkedin_api_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ def test_get_company(linkedin):
assert company["name"] == "LinkedIn"


def test_follow_company(linkedin):
company = linkedin.get_company("linkedin")
assert company
assert company["name"] == "LinkedIn"
assert company["followingInfo"]
assert "following" in company["followingInfo"]
assert "dashFollowingStateUrn" in company["followingInfo"]
done = linkedin.follow_company(company["followingInfo"]["dashFollowingStateUrn"], not company["followingInfo"]["following"])
assert done is True


def test_search(linkedin):
results = linkedin.search(
{"keywords": "software"},
Expand Down

0 comments on commit 72ecd29

Please sign in to comment.