Skip to content

Commit a8890d0

Browse files
Retrieve contact info
1 parent 6651793 commit a8890d0

4 files changed

Lines changed: 83 additions & 0 deletions

File tree

‎linkedapi/operations/fetch_person.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def __init__(self) -> None:
1313
ActionConfig("retrieve_education", "st.retrievePersonEducation"),
1414
ActionConfig("retrieve_skills", "st.retrievePersonSkills"),
1515
ActionConfig("retrieve_languages", "st.retrievePersonLanguages"),
16+
ActionConfig("retrieve_contact_info", "st.retrievePersonContactInfo"),
1617
ActionConfig("retrieve_posts", "st.retrievePersonPosts", "posts_retrieval_config"),
1718
ActionConfig(
1819
"retrieve_comments", "st.retrievePersonComments", "comments_retrieval_config"
@@ -26,6 +27,7 @@ def __init__(self) -> None:
2627
ResponseMapping("st.retrievePersonEducation", "education"),
2728
ResponseMapping("st.retrievePersonSkills", "skills"),
2829
ResponseMapping("st.retrievePersonLanguages", "languages"),
30+
ResponseMapping("st.retrievePersonContactInfo", "contactInfo"),
2931
ResponseMapping("st.retrievePersonPosts", "posts"),
3032
ResponseMapping("st.retrievePersonComments", "comments"),
3133
ResponseMapping("st.retrievePersonReactions", "reactions"),

‎linkedapi/types/__init__.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@
188188
LanguageProficiency,
189189
LocationType,
190190
Person,
191+
PersonBirthday,
192+
PersonContactInfo,
191193
PersonEducation,
192194
PersonExperience,
193195
PersonLanguage,
@@ -555,6 +557,8 @@
555557
"NvUnsaveLeadParams",
556558
"PendingConnectionSession",
557559
"Person",
560+
"PersonBirthday",
561+
"PersonContactInfo",
558562
"PersonEducation",
559563
"PersonExperience",
560564
"PersonLanguage",

‎linkedapi/types/person.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class BaseFetchPersonParams(BaseActionParams):
3434
retrieve_education: bool | None = None
3535
retrieve_skills: bool | None = None
3636
retrieve_languages: bool | None = None
37+
retrieve_contact_info: bool | None = None
3738
retrieve_posts: bool | None = None
3839
retrieve_comments: bool | None = None
3940
retrieve_reactions: bool | None = None
@@ -44,6 +45,7 @@ class BaseFetchPersonParamsWide(BaseFetchPersonParams):
4445
retrieve_education: Literal[True] = True
4546
retrieve_skills: Literal[True] = True
4647
retrieve_languages: Literal[True] = True
48+
retrieve_contact_info: Literal[True] = True
4749
retrieve_posts: Literal[True] = True
4850
retrieve_comments: Literal[True] = True
4951
retrieve_reactions: Literal[True] = True
@@ -99,6 +101,19 @@ class PersonLanguage(BaseActionParams):
99101
proficiency: LanguageProficiency | str | None = None
100102

101103

104+
class PersonBirthday(BaseActionParams):
105+
month: int | None = None
106+
day: int | None = None
107+
108+
109+
class PersonContactInfo(BaseActionParams):
110+
email: str | None = None
111+
phones: list[str] | None = None
112+
websites: list[str] | None = None
113+
birthday: PersonBirthday | None = None
114+
connected_at: str | None = None
115+
116+
102117
class Person(BaseActionParams):
103118
name: str | None = None
104119
urn: str | None = None
@@ -118,6 +133,7 @@ class Person(BaseActionParams):
118133
education: list[PersonEducation] | None = None
119134
skills: list[PersonSkill] | None = None
120135
languages: list[PersonLanguage] | None = None
136+
contact_info: PersonContactInfo | None = None
121137
posts: list[Post] | None = None
122138
comments: list[Comment] | None = None
123139
reactions: list[Reaction] | None = None

‎tests/test_operations.py‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,3 +422,64 @@ def test_execute_and_result_flow_returns_pydantic_data(
422422
)
423423
assert result.data is not None
424424
assert result.data.public_url == "https://www.linkedin.com/in/jane-doe"
425+
426+
427+
def test_fetch_person_retrieves_and_maps_contact_info(
428+
fake_http_client: FakeHttpClient,
429+
person_data: dict[str, object],
430+
) -> None:
431+
linkedapi = LinkedApi(fake_http_client)
432+
contact_info = {
433+
"email": "person@example.com",
434+
"phones": ["555-0100"],
435+
"websites": ["https://example.com/"],
436+
"birthday": {"month": 11, "day": 13},
437+
"connectedAt": "2026-11-11T00:00:00.000Z",
438+
}
439+
fake_http_client.queue_response(result={"workflowId": "wf1", "workflowStatus": "pending"})
440+
fake_http_client.queue_response(
441+
result={
442+
"workflowStatus": "completed",
443+
"completion": {
444+
"actionType": "st.openPersonPage",
445+
"success": True,
446+
"data": {
447+
**person_data,
448+
"then": [
449+
{
450+
"actionType": "st.retrievePersonContactInfo",
451+
"success": True,
452+
"data": contact_info,
453+
}
454+
],
455+
},
456+
},
457+
}
458+
)
459+
460+
workflow = linkedapi.fetch_person.execute(
461+
FetchPersonParams(person_url="u", retrieve_contact_info=True)
462+
)
463+
result = linkedapi.fetch_person.result(workflow.workflow_id, poll_interval=0.001, timeout=1.0)
464+
465+
assert fake_http_client.calls[0] == (
466+
"POST",
467+
"/workflows",
468+
{
469+
"actionType": "st.openPersonPage",
470+
"basicInfo": True,
471+
"personUrl": "u",
472+
"then": [{"actionType": "st.retrievePersonContactInfo"}],
473+
},
474+
)
475+
assert result.data is not None
476+
assert result.data.contact_info is not None
477+
assert result.data.contact_info.email == "person@example.com"
478+
assert result.data.contact_info.phones == ["555-0100"]
479+
assert result.data.contact_info.websites == ["https://example.com/"]
480+
assert result.data.contact_info.birthday is not None
481+
assert (result.data.contact_info.birthday.month, result.data.contact_info.birthday.day) == (
482+
11,
483+
13,
484+
)
485+
assert result.data.contact_info.connected_at == "2026-11-11T00:00:00.000Z"

0 commit comments

Comments
 (0)