maplestory-openapi 3.6.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. maplestory_openapi/__init__.py +3 -0
  2. maplestory_openapi/api/__init__.py +3 -0
  3. maplestory_openapi/api/common/__init__.py +6 -0
  4. maplestory_openapi/api/common/enum/__init__.py +3 -0
  5. maplestory_openapi/api/common/enum/character_image.py +89 -0
  6. maplestory_openapi/api/common/maplestory_api.py +263 -0
  7. maplestory_openapi/api/common/maplestory_api_error.py +19 -0
  8. maplestory_openapi/api/common/maplestory_friends_api.py +99 -0
  9. maplestory_openapi/api/common/param/__init__.py +3 -0
  10. maplestory_openapi/api/common/param/character_image_option.py +11 -0
  11. maplestory_openapi/api/kms/__init__.py +5 -0
  12. maplestory_openapi/api/kms/dto/__init__.py +0 -0
  13. maplestory_openapi/api/kms/dto/character/__init__.py +0 -0
  14. maplestory_openapi/api/kms/dto/character/character.py +13 -0
  15. maplestory_openapi/api/kms/dto/character/character_ability.py +70 -0
  16. maplestory_openapi/api/kms/dto/character/character_android_equipment.py +250 -0
  17. maplestory_openapi/api/kms/dto/character/character_basic.py +56 -0
  18. maplestory_openapi/api/kms/dto/character/character_beauty_equipment.py +101 -0
  19. maplestory_openapi/api/kms/dto/character/character_cashitem_equipment.py +148 -0
  20. maplestory_openapi/api/kms/dto/character/character_dojang.py +24 -0
  21. maplestory_openapi/api/kms/dto/character/character_hexamatrix.py +58 -0
  22. maplestory_openapi/api/kms/dto/character/character_hexamatrix_stat.py +68 -0
  23. maplestory_openapi/api/kms/dto/character/character_hyper_stat.py +61 -0
  24. maplestory_openapi/api/kms/dto/character/character_image.py +41 -0
  25. maplestory_openapi/api/kms/dto/character/character_item_equipment.py +605 -0
  26. maplestory_openapi/api/kms/dto/character/character_link_skill.py +66 -0
  27. maplestory_openapi/api/kms/dto/character/character_other_stat.py +52 -0
  28. maplestory_openapi/api/kms/dto/character/character_pet_equipment.py +179 -0
  29. maplestory_openapi/api/kms/dto/character/character_popularity.py +15 -0
  30. maplestory_openapi/api/kms/dto/character/character_propensity.py +26 -0
  31. maplestory_openapi/api/kms/dto/character/character_ring_exchange_skill_equipment.py +22 -0
  32. maplestory_openapi/api/kms/dto/character/character_set_effect.py +73 -0
  33. maplestory_openapi/api/kms/dto/character/character_skill.py +48 -0
  34. maplestory_openapi/api/kms/dto/character/character_stat.py +40 -0
  35. maplestory_openapi/api/kms/dto/character/character_symbol_equipment.py +64 -0
  36. maplestory_openapi/api/kms/dto/character/character_vmatrix.py +51 -0
  37. maplestory_openapi/api/kms/dto/guild/__init__.py +0 -0
  38. maplestory_openapi/api/kms/dto/guild/guild.py +13 -0
  39. maplestory_openapi/api/kms/dto/guild/guild_basic.py +60 -0
  40. maplestory_openapi/api/kms/dto/history/__init__.py +0 -0
  41. maplestory_openapi/api/kms/dto/history/cube_history.py +90 -0
  42. maplestory_openapi/api/kms/dto/history/potential_history.py +90 -0
  43. maplestory_openapi/api/kms/dto/history/starforce_history.py +90 -0
  44. maplestory_openapi/api/kms/dto/notice/__init__.py +0 -0
  45. maplestory_openapi/api/kms/dto/notice/cashshop_notice_detail.py +32 -0
  46. maplestory_openapi/api/kms/dto/notice/cashshop_notice_list.py +48 -0
  47. maplestory_openapi/api/kms/dto/notice/event_notice_detail.py +22 -0
  48. maplestory_openapi/api/kms/dto/notice/event_notice_list.py +39 -0
  49. maplestory_openapi/api/kms/dto/notice/notice_detail.py +18 -0
  50. maplestory_openapi/api/kms/dto/notice/notice_list.py +35 -0
  51. maplestory_openapi/api/kms/dto/notice/update_notice_detail.py +18 -0
  52. maplestory_openapi/api/kms/dto/notice/update_notice_list.py +35 -0
  53. maplestory_openapi/api/kms/dto/ranking/__init__.py +0 -0
  54. maplestory_openapi/api/kms/dto/ranking/achievement_ranking.py +38 -0
  55. maplestory_openapi/api/kms/dto/ranking/dojang_ranking.py +40 -0
  56. maplestory_openapi/api/kms/dto/ranking/guild_ranking.py +38 -0
  57. maplestory_openapi/api/kms/dto/ranking/overall_ranking.py +42 -0
  58. maplestory_openapi/api/kms/dto/ranking/theseed_ranking.py +40 -0
  59. maplestory_openapi/api/kms/dto/ranking/union_ranking.py +38 -0
  60. maplestory_openapi/api/kms/dto/union/__init__.py +0 -0
  61. maplestory_openapi/api/kms/dto/union/union.py +23 -0
  62. maplestory_openapi/api/kms/dto/union/union_artifact.py +73 -0
  63. maplestory_openapi/api/kms/dto/union/union_champion.py +58 -0
  64. maplestory_openapi/api/kms/dto/union/union_raider.py +147 -0
  65. maplestory_openapi/api/kms/dto/user/__init__.py +0 -0
  66. maplestory_openapi/api/kms/dto/user/achievement.py +48 -0
  67. maplestory_openapi/api/kms/dto/user/character_list.py +55 -0
  68. maplestory_openapi/api/kms/maplestory_api.py +1184 -0
  69. maplestory_openapi/api/kms/maplestory_friends_api.py +136 -0
  70. maplestory_openapi/api/kms/param/__init__.py +0 -0
  71. maplestory_openapi/api/kms/param/character_image_option.py +17 -0
  72. maplestory_openapi/api/msea/__init__.py +4 -0
  73. maplestory_openapi/api/msea/dto/__init__.py +0 -0
  74. maplestory_openapi/api/msea/dto/character/__init__.py +0 -0
  75. maplestory_openapi/api/msea/dto/character/character.py +13 -0
  76. maplestory_openapi/api/msea/dto/character/character_ability.py +70 -0
  77. maplestory_openapi/api/msea/dto/character/character_android_equipment.py +224 -0
  78. maplestory_openapi/api/msea/dto/character/character_basic.py +63 -0
  79. maplestory_openapi/api/msea/dto/character/character_beauty_equipment.py +83 -0
  80. maplestory_openapi/api/msea/dto/character/character_cashitem_equipment.py +138 -0
  81. maplestory_openapi/api/msea/dto/character/character_dojang.py +24 -0
  82. maplestory_openapi/api/msea/dto/character/character_hexamatrix.py +58 -0
  83. maplestory_openapi/api/msea/dto/character/character_hexamatrix_stat.py +68 -0
  84. maplestory_openapi/api/msea/dto/character/character_hyper_stat.py +61 -0
  85. maplestory_openapi/api/msea/dto/character/character_image.py +39 -0
  86. maplestory_openapi/api/msea/dto/character/character_item_equipment.py +556 -0
  87. maplestory_openapi/api/msea/dto/character/character_link_skill.py +66 -0
  88. maplestory_openapi/api/msea/dto/character/character_pet_equipment.py +179 -0
  89. maplestory_openapi/api/msea/dto/character/character_popularity.py +16 -0
  90. maplestory_openapi/api/msea/dto/character/character_propensity.py +26 -0
  91. maplestory_openapi/api/msea/dto/character/character_set_effect.py +73 -0
  92. maplestory_openapi/api/msea/dto/character/character_skill.py +48 -0
  93. maplestory_openapi/api/msea/dto/character/character_stat.py +40 -0
  94. maplestory_openapi/api/msea/dto/character/character_symbol_equipment.py +64 -0
  95. maplestory_openapi/api/msea/dto/character/character_vmatrix.py +52 -0
  96. maplestory_openapi/api/msea/dto/guild/__init__.py +0 -0
  97. maplestory_openapi/api/msea/dto/guild/guild.py +13 -0
  98. maplestory_openapi/api/msea/dto/guild/guild_basic.py +60 -0
  99. maplestory_openapi/api/msea/dto/union/__init__.py +0 -0
  100. maplestory_openapi/api/msea/dto/union/union.py +23 -0
  101. maplestory_openapi/api/msea/dto/union/union_artifact.py +73 -0
  102. maplestory_openapi/api/msea/dto/union/union_raider.py +152 -0
  103. maplestory_openapi/api/msea/maplestory_api.py +713 -0
  104. maplestory_openapi/api/msea/param/__init__.py +0 -0
  105. maplestory_openapi/api/msea/param/character_image_option.py +25 -0
  106. maplestory_openapi/api/tms/__init__.py +4 -0
  107. maplestory_openapi/api/tms/dto/__init__.py +0 -0
  108. maplestory_openapi/api/tms/dto/character/__init__.py +0 -0
  109. maplestory_openapi/api/tms/dto/character/character.py +13 -0
  110. maplestory_openapi/api/tms/dto/character/character_ability.py +56 -0
  111. maplestory_openapi/api/tms/dto/character/character_android_equipment.py +224 -0
  112. maplestory_openapi/api/tms/dto/character/character_basic.py +56 -0
  113. maplestory_openapi/api/tms/dto/character/character_beauty_equipment.py +83 -0
  114. maplestory_openapi/api/tms/dto/character/character_cashitem_equipment.py +140 -0
  115. maplestory_openapi/api/tms/dto/character/character_dojang.py +24 -0
  116. maplestory_openapi/api/tms/dto/character/character_hexamatrix.py +58 -0
  117. maplestory_openapi/api/tms/dto/character/character_hexamatrix_stat.py +68 -0
  118. maplestory_openapi/api/tms/dto/character/character_hyper_stat.py +61 -0
  119. maplestory_openapi/api/tms/dto/character/character_image.py +39 -0
  120. maplestory_openapi/api/tms/dto/character/character_item_equipment.py +556 -0
  121. maplestory_openapi/api/tms/dto/character/character_link_skill.py +66 -0
  122. maplestory_openapi/api/tms/dto/character/character_pet_equipment.py +179 -0
  123. maplestory_openapi/api/tms/dto/character/character_popularity.py +16 -0
  124. maplestory_openapi/api/tms/dto/character/character_propensity.py +26 -0
  125. maplestory_openapi/api/tms/dto/character/character_set_effect.py +73 -0
  126. maplestory_openapi/api/tms/dto/character/character_skill.py +48 -0
  127. maplestory_openapi/api/tms/dto/character/character_stat.py +40 -0
  128. maplestory_openapi/api/tms/dto/character/character_symbol_equipment.py +64 -0
  129. maplestory_openapi/api/tms/dto/character/character_vmatrix.py +52 -0
  130. maplestory_openapi/api/tms/dto/guild/__init__.py +0 -0
  131. maplestory_openapi/api/tms/dto/guild/guild.py +13 -0
  132. maplestory_openapi/api/tms/dto/guild/guild_basic.py +60 -0
  133. maplestory_openapi/api/tms/dto/union/__init__.py +0 -0
  134. maplestory_openapi/api/tms/dto/union/union.py +23 -0
  135. maplestory_openapi/api/tms/dto/union/union_artifact.py +73 -0
  136. maplestory_openapi/api/tms/dto/union/union_raider.py +147 -0
  137. maplestory_openapi/api/tms/maplestory_api.py +713 -0
  138. maplestory_openapi/api/tms/param/__init__.py +0 -0
  139. maplestory_openapi/api/tms/param/character_image_option.py +25 -0
  140. maplestory_openapi/api/utils.py +9 -0
  141. maplestory_openapi-3.6.0.dist-info/METADATA +129 -0
  142. maplestory_openapi-3.6.0.dist-info/RECORD +161 -0
  143. maplestory_openapi-3.6.0.dist-info/WHEEL +5 -0
  144. maplestory_openapi-3.6.0.dist-info/top_level.txt +2 -0
  145. test/__init__.py +0 -0
  146. test/kms/__init__.py +0 -0
  147. test/kms/character_api_test.py +727 -0
  148. test/kms/guild_api_test.py +73 -0
  149. test/kms/history_api_test.py +136 -0
  150. test/kms/notice_api_test.py +96 -0
  151. test/kms/ranking_api_test.py +268 -0
  152. test/kms/union_api_test.py +124 -0
  153. test/kms/user_api_test.py +32 -0
  154. test/msea/__init__.py +0 -0
  155. test/msea/character_api_test.py +557 -0
  156. test/msea/guild_api_test.py +73 -0
  157. test/msea/union_api_test.py +99 -0
  158. test/tms/__init__.py +0 -0
  159. test/tms/character_api_test.py +557 -0
  160. test/tms/guild_api_test.py +73 -0
  161. test/tms/union_api_test.py +99 -0
@@ -0,0 +1,3 @@
1
+ from .api import kms, msea, tms, common
2
+
3
+ __all__ = ['kms', 'msea', 'tms', 'common']
@@ -0,0 +1,3 @@
1
+ from . import kms, msea, tms, common
2
+
3
+ __all__ = ['kms', 'msea', 'tms', 'common']
@@ -0,0 +1,6 @@
1
+ from . import dto, enum, param
2
+ from .maplestory_api import MapleStoryApi
3
+ from .maplestory_friends_api import MapleStoryFriendsApi
4
+ from .maplestory_api_error import MapleStoryApiError, MapleStoryApiException
5
+
6
+ __all__ = ['dto', 'enum', 'param', 'MapleStoryApi', 'MapleStoryFriendsApi', 'MapleStoryApiError', 'MapleStoryApiException']
@@ -0,0 +1,3 @@
1
+ from .character_image import CharacterImageAction, CharacterImageEmotion, CharacterImageWeaponMotion
2
+
3
+ __all__ = ['CharacterImageAction', 'CharacterImageEmotion', 'CharacterImageWeaponMotion']
@@ -0,0 +1,89 @@
1
+ from enum import Enum
2
+
3
+
4
+ class CharacterImageAction(Enum):
5
+ """
6
+ Character action
7
+ """
8
+ Stand1 = 'A00'
9
+ Stand2 = 'A01'
10
+ Walk1 = 'A02'
11
+ Walk2 = 'A03'
12
+ Prone = 'A04'
13
+ Fly = 'A05'
14
+ Jump = 'A06'
15
+ Sit = 'A07'
16
+ Ladder = 'A08'
17
+ Rope = 'A09'
18
+ Heal = 'A10'
19
+ Alert = 'A11'
20
+ ProneStab = 'A12'
21
+ SwingO1 = 'A13'
22
+ SwingO2 = 'A14'
23
+ SwingO3 = 'A15'
24
+ SwingOF = 'A16'
25
+ SwingP1 = 'A17'
26
+ SwingP2 = 'A18'
27
+ SwingPF = 'A19'
28
+ SwingT1 = 'A20'
29
+ SwingT2 = 'A21'
30
+ SwingT3 = 'A22'
31
+ SwingTF = 'A23'
32
+ StabO1 = 'A24'
33
+ StabO2 = 'A25'
34
+ StabOF = 'A26'
35
+ StabT1 = 'A27'
36
+ StabT2 = 'A28'
37
+ StabTF = 'A29'
38
+ Shoot1 = 'A30'
39
+ Shoot2 = 'A31'
40
+ ShootF = 'A32'
41
+ Dead = 'A33'
42
+ GhostWalk = 'A34'
43
+ GhostStand = 'A35'
44
+ GhostJump = 'A36'
45
+ GhostProneStab = 'A37'
46
+ GhostLadder = 'A38'
47
+ GhostRope = 'A39'
48
+ GhostFly = 'A40'
49
+ GhostSit = 'A41'
50
+
51
+ class CharacterImageEmotion(Enum):
52
+ """
53
+ Character emotion
54
+ """
55
+ Default = 'E00'
56
+ Wink = 'E01'
57
+ Smile = 'E02'
58
+ Cry = 'E03'
59
+ Angry = 'E04'
60
+ Bewildered = 'E05'
61
+ Blink = 'E06'
62
+ Blaze = 'E07'
63
+ Bowing = 'E08'
64
+ Cheers = 'E09'
65
+ Chu = 'E10'
66
+ Dam = 'E11'
67
+ Despair = 'E12'
68
+ Glitter = 'E13'
69
+ Hit = 'E14'
70
+ Hot = 'E15'
71
+ Hum = 'E16'
72
+ Love = 'E17'
73
+ Oops = 'E18'
74
+ Pain = 'E19'
75
+ Troubled = 'E20'
76
+ QBlue = 'E21'
77
+ Shine = 'E22'
78
+ Stunned = 'E23'
79
+ Vomit = 'E24'
80
+
81
+ class CharacterImageWeaponMotion(Enum):
82
+ """
83
+ Character weapon motion
84
+ """
85
+ Default = 'W00'
86
+ OneHand = 'W01'
87
+ TwoHands = 'W02'
88
+ Gun = 'W03'
89
+ Nothing = 'W04'
@@ -0,0 +1,263 @@
1
+ from abc import ABC, abstractmethod
2
+ from datetime import datetime, timedelta
3
+ from zoneinfo import ZoneInfo
4
+ from typing import Any
5
+ from pydantic import BaseModel
6
+ import httpx
7
+
8
+ from maplestory_openapi.api.common.dto.character.character import Character
9
+ from maplestory_openapi.api.common.dto.character.character_basic import CharacterBasic
10
+ from maplestory_openapi.api.common.dto.character.character_popularity import CharacterPopularity
11
+ from maplestory_openapi.api.common.dto.character.character_stat import CharacterStat
12
+ from maplestory_openapi.api.common.dto.character.character_hyper_stat import CharacterHyperStat
13
+ from maplestory_openapi.api.common.dto.character.character_propensity import CharacterPropensity
14
+ from maplestory_openapi.api.common.dto.character.character_ability import CharacterAbility
15
+ from maplestory_openapi.api.common.dto.character.character_item_equipment import CharacterItemEquipment
16
+ from maplestory_openapi.api.common.dto.character.character_cashitem_equipment import CharacterCashitemEquipment
17
+ from maplestory_openapi.api.common.dto.character.character_symbol_equipment import CharacterSymbolEquipment
18
+ from maplestory_openapi.api.common.dto.character.character_set_effect import CharacterSetEffect
19
+ from maplestory_openapi.api.common.dto.character.character_beauty_equipment import CharacterBeautyEquipment
20
+ from maplestory_openapi.api.common.dto.character.character_android_equipment import CharacterAndroidEquipment
21
+ from maplestory_openapi.api.common.dto.character.character_pet_equipment import CharacterPetEquipment
22
+ from maplestory_openapi.api.common.dto.character.character_skill import CharacterSkill
23
+ from maplestory_openapi.api.common.dto.character.character_link_skill import CharacterLinkSkill
24
+ from maplestory_openapi.api.common.dto.character.character_vmatrix import CharacterVMatrix
25
+ from maplestory_openapi.api.common.dto.character.character_hexamatrix import CharacterHexaMatrix
26
+ from maplestory_openapi.api.common.dto.character.character_hexamatrix_stat import CharacterHexaMatrixStat
27
+ from maplestory_openapi.api.common.dto.character.character_dojang import CharacterDojang
28
+ from maplestory_openapi.api.common.dto.character.character_image import CharacterImage
29
+
30
+ from maplestory_openapi.api.common.dto.union.union import Union
31
+ from maplestory_openapi.api.common.dto.union.union_artifact import UnionArtifact
32
+ from maplestory_openapi.api.common.dto.union.union_raider import UnionRaider
33
+
34
+ from maplestory_openapi.api.common.dto.guild.guild import Guild
35
+ from maplestory_openapi.api.common.dto.guild.guild_basic import GuildBasic
36
+
37
+ from maplestory_openapi.api.common.maplestory_api_error import MapleStoryApiError, MapleStoryApiException
38
+
39
+ from maplestory_openapi.api.common.param.character_image_option import CharacterImageOption
40
+
41
+
42
+ class MapleStoryApi(ABC, BaseModel):
43
+ api_key: str
44
+ BASE_URL: str = 'https://open.api.nexon.com/'
45
+ timeout: int
46
+ timezone: str
47
+ sub_url: str
48
+
49
+ def __init__(self, api_key: str, timezone: str, sub_url: str, timeout:int):
50
+ super().__init__(
51
+ api_key=api_key,
52
+ timezone=timezone,
53
+ sub_url=sub_url,
54
+ timeout=timeout,
55
+ )
56
+
57
+ #region Character Information Retrieval
58
+
59
+ @abstractmethod
60
+ async def get_character_id(self, character_name: str) -> Character:
61
+ pass
62
+
63
+ @abstractmethod
64
+ async def get_character_basic(self, ocid: str, date: datetime | None = None) -> CharacterBasic | None:
65
+ pass
66
+
67
+ @abstractmethod
68
+ async def get_character_image(self, ocid: str, option: CharacterImageOption | None = None, date: datetime | None = None) -> CharacterImage | None:
69
+ pass
70
+
71
+ @abstractmethod
72
+ async def get_character_popularity(self, ocid: str, date: datetime | None = None) -> CharacterPopularity | None:
73
+ pass
74
+
75
+ @abstractmethod
76
+ async def get_character_stat(self, ocid: str, date: datetime | None = None) -> CharacterStat | None:
77
+ pass
78
+
79
+ @abstractmethod
80
+ async def get_character_hyper_stat(self, ocid: str, date: datetime | None = None) -> CharacterHyperStat | None:
81
+ pass
82
+
83
+ @abstractmethod
84
+ async def get_character_propensity(self, ocid: str, date: datetime | None = None) -> CharacterPropensity | None:
85
+ pass
86
+
87
+ @abstractmethod
88
+ async def get_character_ability(self, ocid: str, date: datetime | None = None) -> CharacterAbility | None:
89
+ pass
90
+
91
+ @abstractmethod
92
+ async def get_character_item_equipment(self, ocid: str, date: datetime | None = None) -> CharacterItemEquipment | None:
93
+ pass
94
+
95
+ @abstractmethod
96
+ async def get_character_cashitem_equipment(self, ocid: str, date: datetime | None = None) -> CharacterCashitemEquipment | None:
97
+ pass
98
+
99
+ @abstractmethod
100
+ async def get_character_symbol_equipment(self, ocid: str, date: datetime | None = None) -> CharacterSymbolEquipment | None:
101
+ pass
102
+
103
+ @abstractmethod
104
+ async def get_character_set_effect(self, ocid: str, date: datetime | None = None) -> CharacterSetEffect | None:
105
+ pass
106
+
107
+ @abstractmethod
108
+ async def get_character_beauty_equipment(self, ocid: str, date: datetime | None = None) -> CharacterBeautyEquipment | None:
109
+ pass
110
+
111
+ @abstractmethod
112
+ async def get_character_android_equipment(self, ocid: str, date: datetime | None = None) -> CharacterAndroidEquipment | None:
113
+ pass
114
+
115
+ @abstractmethod
116
+ async def get_character_pet_equipment(self, ocid: str, date: datetime | None = None) -> CharacterPetEquipment | None:
117
+ pass
118
+
119
+ @abstractmethod
120
+ async def get_character_skill(self, ocid: str, character_skill_grade: str, date: datetime | None = None) -> CharacterSkill | None:
121
+ pass
122
+
123
+ @abstractmethod
124
+ async def get_character_link_skill(self, ocid: str, date: datetime | None = None) -> CharacterLinkSkill | None:
125
+ pass
126
+
127
+ @abstractmethod
128
+ async def get_character_vmatrix(self, ocid: str, date: datetime | None = None) -> CharacterVMatrix | None:
129
+ pass
130
+
131
+ @abstractmethod
132
+ async def get_character_hexamatrix(self, ocid: str, date: datetime | None = None) -> CharacterHexaMatrix | None:
133
+ pass
134
+
135
+ @abstractmethod
136
+ async def get_character_hexamatrix_stat(self, ocid: str, date: datetime | None = None) -> CharacterHexaMatrixStat | None:
137
+ pass
138
+
139
+ @abstractmethod
140
+ async def get_character_dojang(self, ocid: str, date: datetime | None = None) -> CharacterDojang | None:
141
+ pass
142
+
143
+ #endregion
144
+
145
+ #region Union Information Retrieval
146
+
147
+ @abstractmethod
148
+ async def get_union(self, ocid: str, date: datetime | None = None) -> Union | None:
149
+ pass
150
+
151
+ @abstractmethod
152
+ async def get_union_raider(self, ocid: str, date: datetime | None = None) -> UnionRaider | None:
153
+ pass
154
+
155
+ @abstractmethod
156
+ async def get_union_artifact(self, ocid: str, date: datetime | None = None) -> UnionArtifact | None:
157
+ pass
158
+
159
+ #endregion
160
+
161
+ #region Guild Information Retrieval
162
+
163
+ @abstractmethod
164
+ async def get_guild_id(self, guild_name: str, world_name: str) -> Guild | None:
165
+ pass
166
+
167
+ @abstractmethod
168
+ async def get_guild_basic(self, oguid_id: str, date: datetime | None = None) -> GuildBasic | None:
169
+ pass
170
+
171
+ #endregion
172
+
173
+ async def fetch(self, path: str, query: dict) -> Any:
174
+
175
+ params = {key: value for key, value in query.items() if value is not None}
176
+
177
+ async with httpx.AsyncClient(timeout=self.timeout) as client:
178
+ response = await client.get(
179
+ f'{self.BASE_URL}{path}',
180
+ params=params,
181
+ headers={
182
+ 'x-nxopen-api-key': self.api_key,
183
+ },
184
+ )
185
+
186
+ r = response.json()
187
+
188
+ if (r.get('error')):
189
+ raise MapleStoryApiException(MapleStoryApiError(**r.get('error')))
190
+
191
+ return r
192
+
193
+ def _is_empty_response(self, response: dict) -> bool:
194
+ """
195
+ API 응답 데이터가 비어있는지 확인 합니다.
196
+ API 요청 시 날짜에 해당하는 데이터가 없을 경우 date 필드만 값이 존재하는 상황을 검증할 때 사용 합니다.
197
+ 일반적으로 API 지원 시작일과 캐릭터 생성일 사이의 날짜를 조회할 때 발생 합니다.
198
+ """
199
+ for key, value in response.items():
200
+ if key == 'date':
201
+ continue
202
+ if value is None:
203
+ continue
204
+ if isinstance(value, list) and len(value) == 0:
205
+ continue
206
+ return False
207
+ return True
208
+
209
+ def _to_date_string(self, date: datetime, min: datetime | None = None) -> str:
210
+ """
211
+ 날짜 정보를 API 서버에서 요구하는 포맷으로 변환합니다.
212
+
213
+ Args:
214
+ date (datetime): 조회 하려는 날짜
215
+ min (datetime or None): API 호출 가능한 최소 날짜
216
+ """
217
+
218
+ target_date = self.__get_datetime(date)
219
+ date_str = target_date.strftime('%Y-%m-%d')
220
+
221
+ if min is not None:
222
+ min_date = self.__get_datetime(min)
223
+ if target_date < min_date:
224
+ raise ValueError(
225
+ f'You can only retrieve data after {min_date.strftime("%Y-%m-%d")}')
226
+
227
+ return date_str
228
+
229
+ def __get_datetime(self, date: datetime) -> datetime:
230
+ """
231
+ datetime 객체를 timezone이 지정된 datetime 객체로 변환합니다.
232
+
233
+ datetime.astimezone()을 사용하면 지역에 따라 다른 결과가 나오고 date.replace()에도 버그가 존재하므로 datetime으로 재설정합니다.
234
+ """
235
+ return datetime(year=date.year, month=date.month, day=date.day, tzinfo=ZoneInfo(self.timezone))
236
+
237
+ def _get_proper_default_datetime(self, day_offset: int, update_hour: int = 0, update_minute: int = 0) -> datetime:
238
+ """
239
+ API 서버의 데이터 갱신 시간에 따라 데이터가 조회 가능한 최신 날짜를 반환합니다.
240
+
241
+ Args:
242
+ day_offset(int): 갱신시간에 갱신되는 데이터가 오늘인지 어제인지에 따라 숫자를 지정합니다 (0: 오늘, 1: 어제)
243
+ update_hour(int): 갱신 시간의 시간을 지정합니다
244
+ update_minute(int): 갱신 시간의 분을 지정합니다
245
+ """
246
+ now = datetime.now(
247
+ tz=ZoneInfo(self.timezone))
248
+ update_time = datetime(
249
+ year=now.year,
250
+ month=now.month,
251
+ day=now.day,
252
+ hour=update_hour,
253
+ minute=update_minute,
254
+ tzinfo=ZoneInfo(self.timezone))
255
+
256
+ adjusted_time: datetime
257
+
258
+ if now > update_time:
259
+ adjusted_time = update_time - timedelta(days=day_offset)
260
+ else:
261
+ adjusted_time = update_time - timedelta(days=day_offset + 1)
262
+
263
+ return adjusted_time
@@ -0,0 +1,19 @@
1
+ from pydantic import BaseModel
2
+
3
+
4
+ class MapleStoryApiError(BaseModel):
5
+ name: str
6
+ message: str
7
+
8
+
9
+ class MapleStoryApiException(Exception):
10
+ """
11
+ MapleStory API Exception
12
+
13
+ https://openapi.nexon.com/guide/request-api/#error-code-table
14
+ """
15
+
16
+ def __init__(self, error: MapleStoryApiError) -> None:
17
+ self.error_code = error.name
18
+ self.message = error.message
19
+ super().__init__(error.message)
@@ -0,0 +1,99 @@
1
+ from abc import ABC, abstractmethod
2
+ from datetime import datetime, timedelta
3
+ from zoneinfo import ZoneInfo
4
+ from typing import Any
5
+ from pydantic import BaseModel
6
+ import httpx
7
+
8
+ from maplestory_openapi.api.common.maplestory_api_error import MapleStoryApiError, MapleStoryApiException
9
+
10
+ class MapleStoryFriendsApi(ABC, BaseModel):
11
+ access_token: str
12
+ BASE_URL: str = 'https://open.api.nexon.com/'
13
+ timeout: int
14
+ timezone: str
15
+ sub_url: str
16
+
17
+ def __init__(self, access_token: str, timezone: str, sub_url: str, timeout: int):
18
+ super().__init__(
19
+ access_token=access_token,
20
+ timezone=timezone,
21
+ sub_url=sub_url,
22
+ timeout=timeout,
23
+ )
24
+
25
+ async def fetch(self, path: str, query: dict) -> Any:
26
+
27
+ params = {key: value for key, value in query.items() if value is not None}
28
+
29
+ async with httpx.AsyncClient(timeout=self.timeout) as client:
30
+ response = await client.get(
31
+ f'{self.BASE_URL}{path}',
32
+ params=params,
33
+ headers={
34
+ 'Authorization': f'Bearer {self.access_token}',
35
+ },
36
+ )
37
+
38
+ r = response.json()
39
+
40
+ if (r.get('error')):
41
+ raise MapleStoryApiException(MapleStoryApiError(**r.get('error')))
42
+
43
+ return r
44
+
45
+ def _to_date_string(self, date: datetime, min: datetime | None = None) -> str:
46
+ """
47
+ 날짜 정보를 API 서버에서 요구하는 포맷으로 변환합니다.
48
+
49
+ Args:
50
+ date (datetime): 조회 하려는 날짜
51
+ min (datetime or None): API 호출 가능한 최소 날짜
52
+ """
53
+
54
+ target_date = self.__get_datetime(date)
55
+ date_str = target_date.strftime('%Y-%m-%d')
56
+
57
+ if min is not None:
58
+ min_date = self.__get_datetime(min)
59
+ if target_date < min_date:
60
+ raise ValueError(
61
+ f'You can only retrieve data after {min_date.strftime("%Y-%m-%d")}')
62
+
63
+ return date_str
64
+
65
+ def __get_datetime(self, date: datetime) -> datetime:
66
+ """
67
+ datetime 객체를 timezone이 지정된 datetime 객체로 변환합니다.
68
+
69
+ datetime.astimezone()을 사용하면 지역에 따라 다른 결과가 나오고 date.replace()에도 버그가 존재하므로 datetime으로 재설정합니다.
70
+ """
71
+ return datetime(year=date.year, month=date.month, day=date.day, tzinfo=ZoneInfo(self.timezone))
72
+
73
+ def _get_proper_default_datetime(self, day_offset: int, update_hour: int = 0, update_minute: int = 0) -> datetime:
74
+ """
75
+ API 서버의 데이터 갱신 시간에 따라 데이터가 조회 가능한 최신 날짜를 반환합니다.
76
+
77
+ Args:
78
+ day_offset(int): 갱신시간에 갱신되는 데이터가 오늘인지 어제인지에 따라 숫자를 지정합니다 (0: 오늘, 1: 어제)
79
+ update_hour(int): 갱신 시간의 시간을 지정합니다
80
+ update_minute(int): 갱신 시간의 분을 지정합니다
81
+ """
82
+ now = datetime.now(
83
+ tz=ZoneInfo(self.timezone))
84
+ update_time = datetime(
85
+ year=now.year,
86
+ month=now.month,
87
+ day=now.day,
88
+ hour=update_hour,
89
+ minute=update_minute,
90
+ tzinfo=ZoneInfo(self.timezone))
91
+
92
+ adjusted_time: datetime
93
+
94
+ if now > update_time:
95
+ adjusted_time = update_time - timedelta(days=day_offset)
96
+ else:
97
+ adjusted_time = update_time - timedelta(days=day_offset + 1)
98
+
99
+ return adjusted_time
@@ -0,0 +1,3 @@
1
+ from .character_image_option import CharacterImageOption
2
+
3
+ __all__ = ['CharacterImageOption']
@@ -0,0 +1,11 @@
1
+ from pydantic import BaseModel
2
+
3
+ from maplestory_openapi.api.common.enum.character_image import CharacterImageAction, CharacterImageEmotion, CharacterImageWeaponMotion
4
+
5
+
6
+ class CharacterImageOption(BaseModel):
7
+ action: CharacterImageAction
8
+ emotion: CharacterImageEmotion
9
+ wmotion: CharacterImageWeaponMotion
10
+ action_frame: int
11
+ emotion_frame: int
@@ -0,0 +1,5 @@
1
+ from . import dto
2
+ from .maplestory_api import MapleStoryApi
3
+ from .maplestory_friends_api import MapleStoryFriendsApi
4
+
5
+ __all__ = ['dto', 'MapleStoryApi', 'MapleStoryFriendsApi']
File without changes
File without changes
@@ -0,0 +1,13 @@
1
+ from pydantic import BaseModel
2
+
3
+ from maplestory_openapi.api.common.dto.character.character import Character as BaseCharacter
4
+
5
+
6
+ class Character(BaseModel, BaseCharacter):
7
+ """
8
+ 캐릭터 식별자(ocid)
9
+
10
+ Attributes:
11
+ ocid (str): 캐릭터 식별자
12
+ """
13
+ ocid: str
@@ -0,0 +1,70 @@
1
+ from datetime import datetime
2
+ from pydantic import BaseModel, field_validator
3
+
4
+ from maplestory_openapi.api.common.dto.character.character_ability import CharacterAbilityInfo as BaseCharacterAbilityInfo
5
+ from maplestory_openapi.api.common.dto.character.character_ability import CharacterAbilityPreset as BaseCharacterAbilityPreset
6
+ from maplestory_openapi.api.common.dto.character.character_ability import CharacterAbility as BaseCharacterAbility
7
+
8
+
9
+ class CharacterAbilityInfo(BaseModel, BaseCharacterAbilityInfo):
10
+ """
11
+ 캐릭터 어빌리티 상세 정보
12
+
13
+ Attributes:
14
+ ability_no (str): 어빌리티 번호
15
+ ability_grade (str): 어빌리티 등급
16
+ ability_value (str): 어빌리티 값
17
+ """
18
+ ability_no: str
19
+ ability_grade: str
20
+ ability_value: str
21
+
22
+
23
+ class CharacterAbilityPreset(BaseModel, BaseCharacterAbilityPreset):
24
+ """
25
+ 캐릭터 어빌리티 프리셋 정보
26
+
27
+ Attributes:
28
+ ability_preset_grade (str): 프리셋의 어빌리티 등급
29
+ ability_info (list[CharacterAbilityInfo]): 프리셋의 어빌리티 정보
30
+ """
31
+ ability_preset_grade: str
32
+ ability_info: list[CharacterAbilityInfo]
33
+
34
+ @field_validator("ability_info", mode="before")
35
+ @classmethod
36
+ def null_as_empty(cls, v):
37
+ if v is None:
38
+ return []
39
+ return v
40
+
41
+
42
+ class CharacterAbility(BaseModel, BaseCharacterAbility):
43
+ """
44
+ 캐릭터 어빌리티 정보
45
+
46
+ Attributes:
47
+ date (datetime or None): 조회 기준일 (KST, 일 단위 데이터로 시, 분은 일괄 0으로 표기)
48
+ ability_grade (str): 어빌리티 등급
49
+ ability_info (list[CharacterAbilityInfo]): 어빌리티 정보
50
+ remain_fame (int): 보유 명성치
51
+ preset_no (int or None): 적용 중인 어빌리티 프리셋 번호
52
+ ability_preset_1 (CharacterAbilityPreset or None): 어빌리티 1번 프리셋 전체 정보
53
+ ability_preset_2 (CharacterAbilityPreset or None): 어빌리티 2번 프리셋 전체 정보
54
+ ability_preset_3 (CharacterAbilityPreset or None): 어빌리티 3번 프리셋 전체 정보
55
+ """
56
+ date: datetime | None
57
+ ability_grade: str
58
+ ability_info: list[CharacterAbilityInfo]
59
+ remain_fame: int
60
+ preset_no: int | None
61
+ ability_preset_1: CharacterAbilityPreset | None
62
+ ability_preset_2: CharacterAbilityPreset | None
63
+ ability_preset_3: CharacterAbilityPreset | None
64
+
65
+ @field_validator("ability_info", mode="before")
66
+ @classmethod
67
+ def null_as_empty(cls, v):
68
+ if v is None:
69
+ return []
70
+ return v