Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
icepick4 committed Mar 12, 2023
2 parents 24956ab + d039d0e commit 48e0a12
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 34 deletions.
Binary file modified onepyece/__pycache__/common.cpython-39.pyc
Binary file not shown.
Binary file modified onepyece/__pycache__/functions.cpython-39.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions onepyece/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"luffy/techniques": ["id", "count", "name", "translation", "gear_id"],
"locates": ["id", "count", "name", "sea", "affiliation"],
"fruits": ["id", "count", "type"],
"swords": ["id", "count", "name"],
"swords": ["id", "count", "name", "destroy"],
"boats": ["id", "count", "name", "type", "crew_id", "captain_id"],
"crews": ["id", "count", "name", "status", "yonko"],
}
Expand Down Expand Up @@ -104,7 +104,7 @@ def adding_search(endpoint, search, resource=None):
return f"{URL}{endpoint}/search/{resource}"
if "title" in search:
return f"{URL}{endpoint}/{search[:-6]}/search/{resource}"
return f"{URL}{endpoint}/{resource}"
return f"{URL}{endpoint}/{search}/{resource}"


def convert_resource(resource):
Expand Down
76 changes: 44 additions & 32 deletions onepyece/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,13 +735,25 @@ def sword_by_name(resource):
return API("swords", "name", resource)


def sword_by_destroy(resource):
"""
Get sword by type
See https://api-onepiece.com/documentation/8-sword for more information
:param resource: type of the sword (int) (1 = is destroyed, 0 = is not destroyed)
:return: API list object (with swords matching the type search)
"""
return API("swords", "destroy", resource)


def count_swords():
"""
Get count of swords
See https://api-onepiece.com/documentation/8-sword for more information
See https: // api - onepiece.com / documentation / 8 - sword for more information
:return: API unique object (with the count of swords)
: return: API unique object(with the count of swords)
"""
return API("swords", "count")

Expand All @@ -750,10 +762,10 @@ def boat_by_id(resource):
"""
Get boat by id
See https://api-onepiece.com/documentation/14-boat for more information
See https: // api - onepiece.com / documentation / 14 - boat for more information
:param resource: id of the boat (int)
:return: API unique object
: param resource: id of the boat(int)
: return: API unique object
"""
return API("boats", "id", resource)

Expand All @@ -762,10 +774,10 @@ def boat_by_name(resource):
"""
Get boat by name
See https://api-onepiece.com/documentation/14-boat for more information
See https: // api - onepiece.com / documentation / 14 - boat for more information
:param resource: name of the boat (str)
:return: API list object (with boats matching the name search)
: param resource: name of the boat(str)
: return: API list object(with boats matching the name search)
"""
return API("boats", "name", resource)

Expand All @@ -774,10 +786,10 @@ def boat_by_type(resource):
"""
Get boat by type
See https://api-onepiece.com/documentation/14-boat for more information
See https: // api - onepiece.com / documentation / 14 - boat for more information
:param resource: type of the boat (str) (pirate, gouvernement)
:return: API list object (with boats matching the type search)
: param resource: type of the boat(str)(pirate, gouvernement)
: return: API list object(with boats matching the type search)
"""
return API("boats", "type", resource)

Expand All @@ -786,10 +798,10 @@ def boat_by_crew_id(resource):
"""
Get boat by crew id
See https://api-onepiece.com/documentation/14-boat for more information
See https: // api - onepiece.com / documentation / 14 - boat for more information
:param resource: crew id of the boat (int)
:return: API list object (with boats matching the crew id search)
: param resource: crew id of the boat(int)
: return: API list object(with boats matching the crew id search)
"""
return API("boats", "crew_id", resource)

Expand All @@ -798,10 +810,10 @@ def boat_by_captain_id(resource):
"""
Get boat by captain id
See https://api-onepiece.com/documentation/14-boat for more information
See https: // api - onepiece.com / documentation / 14 - boat for more information
:param resource: captain id of the boat (int)
:return: API list object (with boats matching the captain id search)
: param resource: captain id of the boat(int)
: return: API list object(with boats matching the captain id search)
"""
return API("boats", "captain_id", resource)

Expand All @@ -810,9 +822,9 @@ def count_boats():
"""
Get count of boats
See https://api-onepiece.com/documentation/14-boat for more information
See https: // api - onepiece.com / documentation / 14 - boat for more information
:return: API unique object (with the count of boats)
: return: API unique object(with the count of boats)
"""
return API("boats", "count")

Expand All @@ -821,10 +833,10 @@ def crew_by_id(resource):
"""
Get crew by id
See https://api-onepiece.com/documentation/12-crew for more information
See https: // api - onepiece.com / documentation / 12 - crew for more information
:param resource: id of the crew (int)
:return: API unique object
: param resource: id of the crew(int)
: return: API unique object
"""
return API("crews", "id", resource)

Expand All @@ -833,10 +845,10 @@ def crew_by_name(resource):
"""
Get crew by name
See https://api-onepiece.com/documentation/12-crew for more information
See https: // api - onepiece.com / documentation / 12 - crew for more information
:param resource: name of the crew (str)
:return: API list object (with crews matching the name search)
: param resource: name of the crew(str)
: return: API list object(with crews matching the name search)
"""
return API("crews", "name", resource)

Expand All @@ -845,10 +857,10 @@ def crew_by_status(resource):
"""
Get crew by status
See https://api-onepiece.com/documentation/12-crew for more information
See https: // api - onepiece.com / documentation / 12 - crew for more information
:param resource: status of the crew (str) (inconnu, actif, inactif)
:return: API list object (with crews matching the status search)
: param resource: status of the crew(str)(inconnu, actif, inactif)
: return: API list object(with crews matching the status search)
"""
return API("crews", "status", resource)

Expand All @@ -857,9 +869,9 @@ def yonko_crews():
"""
Get yonko crews
See https://api-onepiece.com/documentation/12-crew for more information
See https: // api - onepiece.com / documentation / 12 - crew for more information
:return: API list object (with crews which are yonko)
: return: API list object(with crews which are yonko)
"""
return API("crews", "yonko")

Expand All @@ -868,8 +880,8 @@ def count_crews():
"""
Get count of crews
See https://api-onepiece.com/documentation/12-crew for more information
See https: // api - onepiece.com / documentation / 12 - crew for more information
:return: API unique object (with the count of crews)
: return: API unique object(with the count of crews)
"""
return API("crews", "count")
Binary file modified tests/__pycache__/test_functions.cpython-39.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ def test_functions(self):
function_name = f"{current_endpoint}_by_{search}"
else:
function_name = f"{search}_{current_endpoint}s"

self.assertTrue(hasattr(functions, function_name))

0 comments on commit 48e0a12

Please sign in to comment.