Skip to content

Commit

Permalink
Fixes #41 Renamed get_user to user
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFriendlyCoder committed Apr 17, 2018
1 parent 671c3a7 commit faccfb6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
15 changes: 4 additions & 11 deletions src/friendlypins/api.py
Expand Up @@ -17,20 +17,13 @@ def __init__(self, personal_access_token):
self._log = logging.getLogger(__name__)
self._io = RestIO(personal_access_token)

def get_user(self, username=None):
"""Gets all primitives associated with a particular Pinterest user
:param str username:
Optional name of a user to look up
If not provided, the currently authentcated user will be returned
:returns: Pinterest user with the given name
@property
def user(self):
"""Gets all primitives associated with the authenticated user
:returns: currently authenticated pinterest user
:rtype: :class:`friendlypins.user.User`
"""
self._log.debug("Getting authenticated user details...")
if username:
raise NotImplementedError(
"Querying arbitrary Pinerest users is not yet supported.")

fields = "id,username,first_name,last_name,bio,created_at,counts,image"
result = self._io.get("me", {"fields": fields})
Expand Down
4 changes: 2 additions & 2 deletions src/friendlypins/utils/console_actions.py
Expand Up @@ -60,7 +60,7 @@ def download_thumbnails(api_token, board_name, output_folder, delete):
"""
log = logging.getLogger(__name__)
obj = API(api_token)
user = obj.get_user()
user = obj.user

selected_board = None
for cur_board in user.boards:
Expand Down Expand Up @@ -97,7 +97,7 @@ def delete_board(api_token, board_name):
"""
log = logging.getLogger(__name__)
obj = API(api_token)
user = obj.get_user()
user = obj.user

selected_board = None
for cur_board in user.boards:
Expand Down
2 changes: 1 addition & 1 deletion unit_tests/test_api.py
Expand Up @@ -21,7 +21,7 @@ def test_get_user():
mock_io.return_value = mock_obj

obj = API('abcd1234')
result = obj.get_user()
result = obj.user

assert expected_url == result.url
assert expected_firstname == result.first_name
Expand Down

0 comments on commit faccfb6

Please sign in to comment.