Skip to content

Commit

Permalink
release v0.1.0; update docs; return error from send_message
Browse files Browse the repository at this point in the history
  • Loading branch information
tomquirk committed Sep 9, 2018
1 parent 6dd24bf commit a4fb926
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 18 deletions.
54 changes: 44 additions & 10 deletions DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ One of:
* `public_id`<str> - public identifier i.e. tom-quirk-1928345
* `urn_id`<str> - id provided by the Linkedin URN

__Return__
* <dict>

__Example__

```python
linkedin = Linkedin(credentials['username'], credentials['password'])

linkedin.get_profile('tom-quirk')
profile = linkedin.get_profile('tom-quirk')
```

---------------------------------------
Expand All @@ -46,12 +49,15 @@ Returns a Linkedin profile's first degree (direct) connections
__Arguments__
* `urn_id`<str> - id provided by the Linkedin URN

__Return__
* <list>

__Example__

```python
linkedin = Linkedin(credentials['username'], credentials['password'])

linkedin.get_profile_connections('AC000102305')
connections = linkedin.get_profile_connections('AC000102305')
```

---------------------------------------
Expand All @@ -66,12 +72,15 @@ One of:
* `public_id`<str> - public identifier i.e. tom-quirk-1928345
* `urn_id`<str> - id provided by the Linkedin URN

__Return__
* <dict>

__Example__

```python
linkedin = Linkedin(credentials['username'], credentials['password'])

linkedin.get_profile_contact_info('tom-quirk')
profile_info = linkedin.get_profile_contact_info('tom-quirk')
```

---------------------------------------
Expand All @@ -84,12 +93,15 @@ Returns a school's Linkedin profile.
__Arguments__
* `public_id`<str> - public identifier i.e. university-of-queensland

__Return__
* <dict>

__Example__

```python
linkedin = Linkedin(credentials['username'], credentials['password'])

linkedin.get_school('university-of-queensland')
school = linkedin.get_school('university-of-queensland')
```

---------------------------------------
Expand All @@ -102,12 +114,15 @@ Returns a company's Linkedin profile.
__Arguments__
* `public_id`<str> - public identifier i.e. linkedin

__Return__
* <dict>

__Example__

```python
linkedin = Linkedin(credentials['username'], credentials['password'])

linkedin.get_company('linkedin')
company = linkedin.get_company('linkedin')
```

---------------------------------------
Expand All @@ -121,12 +136,15 @@ __Arguments__
* `params`<dict> - search parameters (see implementation of [search_people](#search_people) for a reference)
* `max_results`<int> - the max number of results to return

__Return__
* <list>

__Example__

```python
linkedin = Linkedin(credentials['username'], credentials['password'])

linkedin.search({keywords: 'software'}, 200)
results = linkedin.search({'keywords': 'software'}, 200)
```

---------------------------------------
Expand All @@ -136,12 +154,15 @@ linkedin.search({keywords: 'software'}, 200)

Return a list of metadata of the user's conversations.

__Return__
* <list>

__Example__

```python
linkedin = Linkedin(credentials['username'], credentials['password'])

linkedin.get_conversations()
conversations = linkedin.get_conversations()
```

---------------------------------------
Expand All @@ -155,6 +176,9 @@ Use this endpoint to get the `conversation id` to send messages (see example).
__Arguments__
* `profile_urn_id`<str> - the urn id of the profile

__Return__
* <dict>

__Example__

```python
Expand All @@ -164,6 +188,7 @@ profile = linkedin.get_profile('bill-g')
profile_urn_id = profile['profile_id']

conversation = linkedin.get_conversation_details(profile_urn_id)
# example: getting the conversation_id
conversation_id = conversation['id']
```

Expand All @@ -178,6 +203,9 @@ __Arguments__
* `conversation_urn_id`<str> - the urn id of the conversation
* `message_body`<str> - the message to send

__Return__
* <boolean> - True if error

__Example__

```python
Expand All @@ -189,7 +217,10 @@ profile_urn_id = profile['profile_id']
conversation = linkedin.get_conversation_details(profile_urn_id)
conversation_id = conversation['id']

linkedin.send_message(conversation_id, "Can I haz job??")
err = linkedin.send_message(conversation_id, "No I will not be your technical cofounder")
if err:
# handle error
return
```

---------------------------------------
Expand All @@ -204,7 +235,7 @@ __Example__
```python
linkedin = Linkedin(credentials['username'], credentials['password'])

linkedin.get_current_profile_views()
views = linkedin.get_current_profile_views()
```

---------------------------------------
Expand All @@ -221,12 +252,15 @@ __Arguments__
* `regions`<list> - list of Linkedin region ids
* `industries`<list> - list of Linkedin industry ids

__Return__
* <list>

__Example__

```python
linkedin = Linkedin(credentials['username'], credentials['password'])

linkedin.search_people(
results = linkedin.search_people(
keywords='software,lol',
connection_of='AC000120303',
network_depth='F',
Expand Down
2 changes: 1 addition & 1 deletion linkedin_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .linkedin import Linkedin

__title__ = "linkedin_api"
__version__ = "0.0.1"
__version__ = "0.1.0"
__description__ = "Python Wrapper for the Linkedin API"

__license__ = "MIT"
Expand Down
11 changes: 5 additions & 6 deletions linkedin_api/linkedin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Linkedin(object):
Class for accessing Linkedin API.
"""

_MAX_UPDATE_COUNT = 100 # max seems to be 100
_MAX_UPDATE_COUNT = 100 # max seems to be 100
_MAX_SEARCH_COUNT = 49 # max seems to be 49
_MAX_REPEATED_REQUESTS = (
200
Expand Down Expand Up @@ -257,7 +257,7 @@ def get_company_updates(self, public_id=None, urn_id=None, max_results=None, res
)

data = res.json()

if (
len(data["elements"]) == 0
or (max_results is not None and len(results) >= max_results)
Expand Down Expand Up @@ -294,7 +294,7 @@ def get_profile_updates(self, public_id=None, urn_id=None, max_results=None, res
)

data = res.json()

if (
len(data["elements"]) == 0
or (max_results is not None and len(results) >= max_results)
Expand All @@ -319,7 +319,6 @@ def get_current_profile_views(self):

return data['elements'][0]['value']['com.linkedin.voyager.identity.me.ProfileViewsByTimePanel']


def get_school(self, public_id):
"""
Return data for a single school.
Expand Down Expand Up @@ -451,7 +450,7 @@ def get_conversation(self, conversation_urn_id):

def send_message(self, conversation_urn_id, message_body):
"""
Return the full conversation at a given [conversation_urn_id]
Send a message to a given conversation. If error, return true.
"""
params = {"action": "create"}

Expand All @@ -476,4 +475,4 @@ def send_message(self, conversation_urn_id, message_body):
data=payload,
)

return res.status_code == 201
return res.status_code != 201
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="linkedin_api",
version="0.0.1",
version="0.1.0",
author="Tom Quirk",
author_email="[email protected]",
description="Python wrapper for the Linkedin API",
Expand Down

0 comments on commit a4fb926

Please sign in to comment.