Repository: SnarkAttack/pybgg-json

Issue:
Guilds Requests

Discussion:

Patch:
diff --git a/pybgg_json/pybgg_json.py b/pybgg_json/pybgg_json.py
index c54103a..ebd9649 100755
--- a/pybgg_json/pybgg_json.py
+++ b/pybgg_json/pybgg_json.py
@@ -74,10 +74,21 @@ class PyBggInterface(object):
     def user_request(self, name, buddies=0, guilds=0, hot=0, top=0, domain='boardgame', page=1):
 
         user_url = (
-                  f"user?id={id}&buddies={buddies}&guilds={guilds}&hot={hot}&top={top}&domain={domain}&page={page}"
+                  f"user?name={name}&buddies={buddies}&guilds={guilds}&hot={hot}&top={top}&domain={domain}&page={page}"
         )
 
         root = pybgg_utils._make_request(user_url)
 
         return json.dumps(pybgg_utils._generate_dict_from_element_tree(root))
 
+    def guild_request(self, id, members=0, sorttype='username', page=1):
+
+        guild_url = (
+                   f"guild?id={id}&members={members}&sort={sorttype}&page={page}"
+        )
+
+        root = pybgg_utils._make_request(guild_url)
+
+        return json.dumps(pybgg_utils._generate_dict_from_element_tree(root))
+
+


Test patch:
diff --git a/tests/test_pybgg_json.py b/tests/test_pybgg_json.py
index 47addf7..e1eb2c0 100644
--- a/tests/test_pybgg_json.py
+++ b/tests/test_pybgg_json.py
@@ -60,6 +60,11 @@ expected_keys = {
     'guild': ['id', 'name'],
     'hot': ['domain', 'item'],
     'top': ['domain', 'item'],
+    'guild': ['id', 'name', 'created', 'termsofuse', 'category', 'website', 'manager', 'description',
+                'location', 'members'],
+    'location': ['addr1', 'addr2', 'city', 'stateorprovince', 'postalcode', 'country'],
+    'members': ['count', 'page', 'member'],
+    'member': ['name', 'date'],
 }
 
 
@@ -189,3 +194,11 @@ def test_user_request_top():
 def test_user_request_page():
     bgg_int = PyBggInterface()
     assert check_json(bgg_int.user_request(name='mcpat0226', page=2)) == True
+
+def test_guild_request_basic():
+    bgg_int = PyBggInterface()
+    assert check_json(bgg_int.guild_request(id=1622)) == True
+
+def test_guild_request_members():
+    bgg_int = PyBggInterface()
+    assert check_json(bgg_int.guild_request(id=1622, members=1)) == True