Skip to content

Commit d039d0e

Browse files
authored
Merge pull request #4 from icepick4/fix-sword-endpoint
Adding missing endpoint for swords Closing #3
2 parents b7ea2e7 + 7cbeaff commit d039d0e

File tree

6 files changed

+47
-34
lines changed

6 files changed

+47
-34
lines changed
15 Bytes
Binary file not shown.
519 Bytes
Binary file not shown.

onepyece/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"luffy/techniques": ["id", "count", "name", "translation", "gear_id"],
1919
"locates": ["id", "count", "name", "sea", "affiliation"],
2020
"fruits": ["id", "count", "type"],
21-
"swords": ["id", "count", "name"],
21+
"swords": ["id", "count", "name", "destroy"],
2222
"boats": ["id", "count", "name", "type", "crew_id", "captain_id"],
2323
"crews": ["id", "count", "name", "status", "yonko"],
2424
}
@@ -104,7 +104,7 @@ def adding_search(endpoint, search, resource=None):
104104
return f"{URL}{endpoint}/search/{resource}"
105105
if "title" in search:
106106
return f"{URL}{endpoint}/{search[:-6]}/search/{resource}"
107-
return f"{URL}{endpoint}/{resource}"
107+
return f"{URL}{endpoint}/{search}/{resource}"
108108

109109

110110
def convert_resource(resource):

onepyece/functions.py

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -735,13 +735,25 @@ def sword_by_name(resource):
735735
return API("swords", "name", resource)
736736

737737

738+
def sword_by_destroy(resource):
739+
"""
740+
Get sword by type
741+
742+
See https://api-onepiece.com/documentation/8-sword for more information
743+
744+
:param resource: type of the sword (int) (1 = is destroyed, 0 = is not destroyed)
745+
:return: API list object (with swords matching the type search)
746+
"""
747+
return API("swords", "destroy", resource)
748+
749+
738750
def count_swords():
739751
"""
740752
Get count of swords
741753
742-
See https://api-onepiece.com/documentation/8-sword for more information
754+
See https: // api - onepiece.com / documentation / 8 - sword for more information
743755
744-
:return: API unique object (with the count of swords)
756+
: return: API unique object(with the count of swords)
745757
"""
746758
return API("swords", "count")
747759

@@ -750,10 +762,10 @@ def boat_by_id(resource):
750762
"""
751763
Get boat by id
752764
753-
See https://api-onepiece.com/documentation/14-boat for more information
765+
See https: // api - onepiece.com / documentation / 14 - boat for more information
754766
755-
:param resource: id of the boat (int)
756-
:return: API unique object
767+
: param resource: id of the boat(int)
768+
: return: API unique object
757769
"""
758770
return API("boats", "id", resource)
759771

@@ -762,10 +774,10 @@ def boat_by_name(resource):
762774
"""
763775
Get boat by name
764776
765-
See https://api-onepiece.com/documentation/14-boat for more information
777+
See https: // api - onepiece.com / documentation / 14 - boat for more information
766778
767-
:param resource: name of the boat (str)
768-
:return: API list object (with boats matching the name search)
779+
: param resource: name of the boat(str)
780+
: return: API list object(with boats matching the name search)
769781
"""
770782
return API("boats", "name", resource)
771783

@@ -774,10 +786,10 @@ def boat_by_type(resource):
774786
"""
775787
Get boat by type
776788
777-
See https://api-onepiece.com/documentation/14-boat for more information
789+
See https: // api - onepiece.com / documentation / 14 - boat for more information
778790
779-
:param resource: type of the boat (str) (pirate, gouvernement)
780-
:return: API list object (with boats matching the type search)
791+
: param resource: type of the boat(str)(pirate, gouvernement)
792+
: return: API list object(with boats matching the type search)
781793
"""
782794
return API("boats", "type", resource)
783795

@@ -786,10 +798,10 @@ def boat_by_crew_id(resource):
786798
"""
787799
Get boat by crew id
788800
789-
See https://api-onepiece.com/documentation/14-boat for more information
801+
See https: // api - onepiece.com / documentation / 14 - boat for more information
790802
791-
:param resource: crew id of the boat (int)
792-
:return: API list object (with boats matching the crew id search)
803+
: param resource: crew id of the boat(int)
804+
: return: API list object(with boats matching the crew id search)
793805
"""
794806
return API("boats", "crew_id", resource)
795807

@@ -798,10 +810,10 @@ def boat_by_captain_id(resource):
798810
"""
799811
Get boat by captain id
800812
801-
See https://api-onepiece.com/documentation/14-boat for more information
813+
See https: // api - onepiece.com / documentation / 14 - boat for more information
802814
803-
:param resource: captain id of the boat (int)
804-
:return: API list object (with boats matching the captain id search)
815+
: param resource: captain id of the boat(int)
816+
: return: API list object(with boats matching the captain id search)
805817
"""
806818
return API("boats", "captain_id", resource)
807819

@@ -810,9 +822,9 @@ def count_boats():
810822
"""
811823
Get count of boats
812824
813-
See https://api-onepiece.com/documentation/14-boat for more information
825+
See https: // api - onepiece.com / documentation / 14 - boat for more information
814826
815-
:return: API unique object (with the count of boats)
827+
: return: API unique object(with the count of boats)
816828
"""
817829
return API("boats", "count")
818830

@@ -821,10 +833,10 @@ def crew_by_id(resource):
821833
"""
822834
Get crew by id
823835
824-
See https://api-onepiece.com/documentation/12-crew for more information
836+
See https: // api - onepiece.com / documentation / 12 - crew for more information
825837
826-
:param resource: id of the crew (int)
827-
:return: API unique object
838+
: param resource: id of the crew(int)
839+
: return: API unique object
828840
"""
829841
return API("crews", "id", resource)
830842

@@ -833,10 +845,10 @@ def crew_by_name(resource):
833845
"""
834846
Get crew by name
835847
836-
See https://api-onepiece.com/documentation/12-crew for more information
848+
See https: // api - onepiece.com / documentation / 12 - crew for more information
837849
838-
:param resource: name of the crew (str)
839-
:return: API list object (with crews matching the name search)
850+
: param resource: name of the crew(str)
851+
: return: API list object(with crews matching the name search)
840852
"""
841853
return API("crews", "name", resource)
842854

@@ -845,10 +857,10 @@ def crew_by_status(resource):
845857
"""
846858
Get crew by status
847859
848-
See https://api-onepiece.com/documentation/12-crew for more information
860+
See https: // api - onepiece.com / documentation / 12 - crew for more information
849861
850-
:param resource: status of the crew (str) (inconnu, actif, inactif)
851-
:return: API list object (with crews matching the status search)
862+
: param resource: status of the crew(str)(inconnu, actif, inactif)
863+
: return: API list object(with crews matching the status search)
852864
"""
853865
return API("crews", "status", resource)
854866

@@ -857,9 +869,9 @@ def yonko_crews():
857869
"""
858870
Get yonko crews
859871
860-
See https://api-onepiece.com/documentation/12-crew for more information
872+
See https: // api - onepiece.com / documentation / 12 - crew for more information
861873
862-
:return: API list object (with crews which are yonko)
874+
: return: API list object(with crews which are yonko)
863875
"""
864876
return API("crews", "yonko")
865877

@@ -868,8 +880,8 @@ def count_crews():
868880
"""
869881
Get count of crews
870882
871-
See https://api-onepiece.com/documentation/12-crew for more information
883+
See https: // api - onepiece.com / documentation / 12 - crew for more information
872884
873-
:return: API unique object (with the count of crews)
885+
: return: API unique object(with the count of crews)
874886
"""
875887
return API("crews", "count")
0 Bytes
Binary file not shown.

tests/test_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ def test_functions(self):
1515
function_name = f"{current_endpoint}_by_{search}"
1616
else:
1717
function_name = f"{search}_{current_endpoint}s"
18+
1819
self.assertTrue(hasattr(functions, function_name))

0 commit comments

Comments
 (0)