Repository: takeontom/PyPeri

Issue:
Retrieve user information by User ID
Implement `get_user_info(user_id)` to retrieve user information by a specific User ID.

Discussion:

Patch:
diff --git a/pyperi/pyperi.py b/pyperi/pyperi.py
index 7132c51..b919ee8 100644
--- a/pyperi/pyperi.py
+++ b/pyperi/pyperi.py
@@ -37,3 +37,11 @@ class PyPeri(object):
         endpoint = 'accessVideoPublic'
         result = self.request_api(endpoint, broadcast_id=broadcast_id)
         return result['broadcast']
+
+    def get_user_info(self, user_id):
+        """
+        Retrieve a dict of information about a specific User.
+        """
+        endpoint = 'getUserPublic'
+        result = self.request_api(endpoint, user_id=user_id)
+        return result['user']


Test patch:
diff --git a/tests/responses/getUserPublic.txt b/tests/responses/getUserPublic.txt
new file mode 100644
index 0000000..a32fab8
--- /dev/null
+++ b/tests/responses/getUserPublic.txt
@@ -0,0 +1,1 @@
+{"user":{"class_name":"User","id":"376827","created_at":"2015-03-28T19:52:59.150319197-07:00","is_beta_user":false,"is_employee":false,"is_twitter_verified":true,"twitter_screen_name":"george_clinton","username":"george_clinton","display_name":"George Clinton","description":"It's always gotten better by Thursday. www.georgeclinton.com","profile_image_urls":[{"url":"http://pbs.twimg.com/profile_images/482413674338869248/7GBlIsEm_reasonably_small.jpeg","ssl_url":"https://pbs.twimg.com/profile_images/482413674338869248/7GBlIsEm_reasonably_small.jpeg","width":128,"height":128},{"url":"http://pbs.twimg.com/profile_images/482413674338869248/7GBlIsEm_200x200.jpeg","ssl_url":"https://pbs.twimg.com/profile_images/482413674338869248/7GBlIsEm_200x200.jpeg","width":200,"height":200},{"url":"http://pbs.twimg.com/profile_images/482413674338869248/7GBlIsEm_400x400.jpeg","ssl_url":"https://pbs.twimg.com/profile_images/482413674338869248/7GBlIsEm_400x400.jpeg","width":400,"height":400}],"twitter_id":"23177270","initials":"","n_followers":14536,"n_following":739,"n_hearts":2768177}}
diff --git a/tests/test_pyperi.py b/tests/test_pyperi.py
index 6af1cde..d9f4db1 100644
--- a/tests/test_pyperi.py
+++ b/tests/test_pyperi.py
@@ -56,7 +56,24 @@ def test_get_broadcast_info():
     httpretty.register_uri(httpretty.GET, mock_url, mock_body)
 
     pp = PyPeri()
-    result = pp.get_broadcast_info('1zqKVWybqeDGB')
+    result = pp.get_broadcast_info(broadcast_id)
     assert result['id'] == broadcast_id
     assert result['user_id'] == '376827'
     assert result['username'] == 'george_clinton'
+
+
+@httpretty.activate
+def test_get_user_info():
+    user_id = '376827'
+    mock_url = (
+        'https://api.periscope.tv/api/v2/getUserPublic?'
+        'user_id={user_id}'
+    ).format(user_id=user_id)
+    mock_body_file = open('tests/responses/getUserPublic.txt', 'r')
+    mock_body = mock_body_file.read()
+    httpretty.register_uri(httpretty.GET, mock_url, mock_body)
+
+    pp = PyPeri()
+    result = pp.get_user_info(user_id)
+    assert result['id'] == user_id
+    assert result['username'] == 'george_clinton'