maplestory-openapi 3.5.1 → 3.7.0

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 (35) hide show
  1. package/README.md +1 -0
  2. package/dist/cjs/maplestory/api/common/mapleStoryApiError.js +2 -0
  3. package/dist/cjs/maplestory/api/common/mapleStoryFriendsApi.js +120 -0
  4. package/dist/cjs/maplestory/api/kms/dto/character/characterCashItemEquipment.js +42 -1
  5. package/dist/cjs/maplestory/api/kms/dto/character/characterSymbolEquipment.js +6 -1
  6. package/dist/cjs/maplestory/api/kms/dto/character/characterVMatrix.js +4 -0
  7. package/dist/cjs/maplestory/api/kms/dto/notice/cashshopNoticeList.js +6 -1
  8. package/dist/cjs/maplestory/api/kms/dto/notice/eventNoticeList.js +6 -1
  9. package/dist/cjs/maplestory/api/kms/kms.js +3 -0
  10. package/dist/cjs/maplestory/api/kms/mapleStoryFriendsApi.js +116 -0
  11. package/dist/esm/maplestory/api/common/mapleStoryApiError.js +2 -0
  12. package/dist/esm/maplestory/api/common/mapleStoryFriendsApi.js +111 -0
  13. package/dist/esm/maplestory/api/kms/dto/character/characterCashItemEquipment.js +42 -2
  14. package/dist/esm/maplestory/api/kms/dto/character/characterSymbolEquipment.js +6 -1
  15. package/dist/esm/maplestory/api/kms/dto/character/characterVMatrix.js +4 -0
  16. package/dist/esm/maplestory/api/kms/dto/notice/cashshopNoticeList.js +6 -1
  17. package/dist/esm/maplestory/api/kms/dto/notice/eventNoticeList.js +6 -1
  18. package/dist/esm/maplestory/api/kms/kms.js +2 -1
  19. package/dist/esm/maplestory/api/kms/mapleStoryFriendsApi.js +112 -0
  20. package/dist/index.min.js +1 -1
  21. package/package.json +1 -1
  22. package/types/maplestory/api/common/dto/character/characterVMatrix.d.ts +1 -1
  23. package/types/maplestory/api/common/mapleStoryApiError.d.ts +2 -1
  24. package/types/maplestory/api/common/mapleStoryFriendsApi.d.ts +49 -0
  25. package/types/maplestory/api/kms/dto/character/characterCashItemEquipment.d.ts +31 -1
  26. package/types/maplestory/api/kms/dto/character/characterSymbolEquipment.d.ts +4 -0
  27. package/types/maplestory/api/kms/dto/character/characterVMatrix.d.ts +5 -1
  28. package/types/maplestory/api/kms/dto/notice/cashshopNoticeList.d.ts +4 -0
  29. package/types/maplestory/api/kms/dto/notice/eventNoticeList.d.ts +4 -0
  30. package/types/maplestory/api/kms/index.d.ts +1 -0
  31. package/types/maplestory/api/kms/mapleStoryFriendsApi.d.ts +115 -0
  32. package/types/maplestory/api/kms/response/character/characterCashItemEquipmentBody.d.ts +8 -0
  33. package/types/maplestory/api/kms/response/character/characterSymbolEquipmentBody.d.ts +1 -0
  34. package/types/maplestory/api/kms/response/notice/cashshopNoticeListBody.d.ts +1 -0
  35. package/types/maplestory/api/kms/response/notice/eventNoticeListBody.d.ts +1 -0
package/README.md CHANGED
@@ -113,6 +113,7 @@ This library supports all apis published in the MapleStory OpenAPI official docs
113
113
  Some features are supported only in specific regions. Please refer to the official documentation for each region for details.
114
114
 
115
115
  - KMS: [https://openapi.nexon.com/game/maplestory](https://openapi.nexon.com/game/maplestory)
116
+ - KMS(for Nexon Friends Exclusive APIs): [https://openapi.nexon.com/ko/friends/maplestory](https://openapi.nexon.com/ko/friends/maplestory)
116
117
  - TMS: [https://openapi.nexon.com/game/maplestorytw](https://openapi.nexon.com/game/maplestorytw)
117
118
  - MSEA: [https://openapi.nexon.com/game/maplestorysea](https://openapi.nexon.com/game/maplestorysea)
118
119
 
@@ -33,6 +33,7 @@ exports.MapleStoryApiErrorCode = void 0;
33
33
  MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00009"] = 7] = "OPENAPI00009";
34
34
  MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00010"] = 8] = "OPENAPI00010";
35
35
  MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00011"] = 9] = "OPENAPI00011";
36
+ MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00012"] = 10] = "OPENAPI00012";
36
37
  })(exports.MapleStoryApiErrorCode || (exports.MapleStoryApiErrorCode = {}));
37
38
  const ERROR_MAP = {
38
39
  ['OPENAPI00001']: exports.MapleStoryApiErrorCode.OPENAPI00001,
@@ -45,6 +46,7 @@ const ERROR_MAP = {
45
46
  ['OPENAPI00009']: exports.MapleStoryApiErrorCode.OPENAPI00009,
46
47
  ['OPENAPI00010']: exports.MapleStoryApiErrorCode.OPENAPI00010,
47
48
  ['OPENAPI00011']: exports.MapleStoryApiErrorCode.OPENAPI00011,
49
+ ['OPENAPI00012']: exports.MapleStoryApiErrorCode.OPENAPI00012,
48
50
  };
49
51
 
50
52
  exports.MapleStoryApiError = MapleStoryApiError;
@@ -0,0 +1,120 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var axios = require('axios');
6
+ var dayjs = require('dayjs');
7
+ var timezone = require('../../../node_modules/dayjs/plugin/timezone.js');
8
+ var utc = require('../../../node_modules/dayjs/plugin/utc.js');
9
+ var mapleStoryApiError = require('./mapleStoryApiError.js');
10
+
11
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
+
13
+ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
14
+ var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
15
+
16
+ dayjs__default["default"].extend(timezone);
17
+ dayjs__default["default"].extend(utc);
18
+ /**
19
+ * MapleStory Friends API client.
20
+ */
21
+ class MapleStoryFriendsApi {
22
+ accessToken;
23
+ client;
24
+ static BASE_URL = 'https://open.api.nexon.com/';
25
+ static DEFAULT_TIMEOUT = 5000;
26
+ get timeout() {
27
+ return this.client.defaults.timeout;
28
+ }
29
+ set timeout(value) {
30
+ this.client.defaults.timeout = value;
31
+ }
32
+ constructor(accessToken) {
33
+ this.accessToken = accessToken;
34
+ this.client = axios__default["default"].create({
35
+ baseURL: MapleStoryFriendsApi.BASE_URL,
36
+ timeout: MapleStoryFriendsApi.DEFAULT_TIMEOUT,
37
+ headers: {
38
+ 'Authorization': `Bearer ${this.accessToken}`,
39
+ },
40
+ });
41
+ this.client.interceptors.response.use((response) => response, (error) => {
42
+ if (error instanceof axios.AxiosError) {
43
+ const errorBody = error.response
44
+ .data;
45
+ throw new mapleStoryApiError.MapleStoryApiError(errorBody);
46
+ }
47
+ throw error;
48
+ });
49
+ }
50
+ /**
51
+ * API 서버의 데이터 갱신 시간에 따라 데이터가 조회 가능한 최신 날짜를 반환합니다.
52
+ *
53
+ * @param options
54
+ */
55
+ getProperDefaultDateOptions(options) {
56
+ const { hour, minute, dateOffset } = options;
57
+ const nowInTimezone = dayjs__default["default"]().utcOffset(this.timezoneOffset);
58
+ const updateDate = dayjs__default["default"]().utcOffset(this.timezoneOffset).hour(hour).minute(minute);
59
+ let adjustedDate;
60
+ if (nowInTimezone.isAfter(updateDate)) {
61
+ adjustedDate = nowInTimezone;
62
+ }
63
+ else {
64
+ adjustedDate = nowInTimezone.subtract(1, 'day');
65
+ }
66
+ adjustedDate = adjustedDate.subtract(dateOffset ?? 0, 'day');
67
+ return {
68
+ year: adjustedDate.year(),
69
+ month: adjustedDate.month() + 1,
70
+ day: adjustedDate.date(),
71
+ };
72
+ }
73
+ ;
74
+ /**
75
+ * 날짜 정보를 API 서버에서 요구하는 포맷으로 변환합니다.
76
+ *
77
+ * @param dateOptions 조회 하려는 날짜
78
+ * @param minDateOptions API 호출 가능한 최소 날짜
79
+ */
80
+ toDateString(dateOptions, minDateOptions) {
81
+ const convert = (dateOptions) => {
82
+ let year;
83
+ let month;
84
+ let day;
85
+ let d;
86
+ if (dateOptions instanceof Date) {
87
+ d = dayjs__default["default"](dateOptions).utcOffset(this.timezoneOffset);
88
+ year = d.year();
89
+ month = d.month() + 1;
90
+ day = d.date();
91
+ }
92
+ else {
93
+ year = dateOptions.year;
94
+ month = dateOptions.month;
95
+ day = dateOptions.day;
96
+ d = dayjs__default["default"](`${year}-${month}-${day}`).utcOffset(this.timezoneOffset);
97
+ }
98
+ return {
99
+ year,
100
+ month,
101
+ day,
102
+ d,
103
+ };
104
+ };
105
+ const { year, month, day, d } = convert(dateOptions);
106
+ const str = d.format('YYYY-MM-DD');
107
+ if (minDateOptions) {
108
+ const { year: minYear, month: minMonth, day: minDay, } = convert(minDateOptions);
109
+ if (year < minYear ||
110
+ (year === minYear && month < minMonth) ||
111
+ (year === minYear && month === minMonth && day < minDay)) {
112
+ throw new Error(`You can only retrieve data after ${dayjs__default["default"](`${minYear}-${minMonth}-${minDay}`).format('YYYY-MM-DD')}.`);
113
+ }
114
+ }
115
+ return str;
116
+ }
117
+ ;
118
+ }
119
+
120
+ exports.MapleStoryFriendsApi = MapleStoryFriendsApi;
@@ -111,6 +111,34 @@ class CharacterCashItemEquipmentColoringPrismDto extends characterCashItemEquipm
111
111
  this.value = value;
112
112
  }
113
113
  }
114
+ /**
115
+ * 캐릭터 캐시 장비(무기) 이펙트 프리즘
116
+ */
117
+ class CharacterCashItemEquipmentEffectPrismDto {
118
+ /**
119
+ * 이펙트 프리즘 색상 범위
120
+ */
121
+ colorRange;
122
+ /**
123
+ * 이펙트 프리즘 색조
124
+ */
125
+ hue;
126
+ /**
127
+ * 이펙트 프리즘 채도
128
+ */
129
+ saturation;
130
+ /**
131
+ * 이펙트 프리즘 명도
132
+ */
133
+ value;
134
+ constructor(obj) {
135
+ const { color_range, hue, saturation, value } = obj;
136
+ this.colorRange = color_range;
137
+ this.hue = hue;
138
+ this.saturation = saturation;
139
+ this.value = value;
140
+ }
141
+ }
114
142
  /**
115
143
  * 캐릭터 캐시 장비 옵션
116
144
  */
@@ -182,6 +210,10 @@ class CharacterCashItemEquipmentPresetDto extends characterCashItemEquipment.Cha
182
210
  * 캐시 장비 컬러링프리즘 정보
183
211
  */
184
212
  cashItemColoringPrism;
213
+ /**
214
+ * 캐시 장비(무기) 이펙트 프리즘 정보
215
+ */
216
+ cashItemEffectPrism;
185
217
  /**
186
218
  * 아이템 장착 가능 성별
187
219
  */
@@ -194,9 +226,13 @@ class CharacterCashItemEquipmentPresetDto extends characterCashItemEquipment.Cha
194
226
  * 프리스타일 쿠폰 적용 여부 (0:미적용, 1:적용)
195
227
  */
196
228
  freestyleFlag;
229
+ /**
230
+ * 표정 합성 정보
231
+ */
232
+ emotion_name;
197
233
  constructor(obj) {
198
234
  super();
199
- const { cash_item_equipment_part, cash_item_equipment_slot, cash_item_name, cash_item_icon, cash_item_description, cash_item_option, date_expire, date_option_expire, cash_item_label, cash_item_coloring_prism, item_gender, skills, freestyle_flag, } = obj;
235
+ const { cash_item_equipment_part, cash_item_equipment_slot, cash_item_name, cash_item_icon, cash_item_description, cash_item_option, date_expire, date_option_expire, cash_item_label, cash_item_coloring_prism, cash_item_effect_prism, item_gender, skills, freestyle_flag, emotion_name, } = obj;
200
236
  this.cashItemEquipmentPart = cash_item_equipment_part;
201
237
  this.cashItemEquipmentSlot = cash_item_equipment_slot;
202
238
  this.cashItemName = cash_item_name;
@@ -207,9 +243,13 @@ class CharacterCashItemEquipmentPresetDto extends characterCashItemEquipment.Cha
207
243
  this.cashItemColoringPrism = cash_item_coloring_prism
208
244
  ? new CharacterCashItemEquipmentColoringPrismDto(cash_item_coloring_prism)
209
245
  : null;
246
+ this.cashItemEffectPrism = cash_item_effect_prism
247
+ ? new CharacterCashItemEquipmentEffectPrismDto(cash_item_effect_prism)
248
+ : null;
210
249
  this.itemGender = item_gender;
211
250
  this.skills = skills;
212
251
  this.freestyleFlag = freestyle_flag;
252
+ this.emotion_name = emotion_name;
213
253
  if (date_expire === 'expired') {
214
254
  this.isExpired = true;
215
255
  }
@@ -235,5 +275,6 @@ class CharacterCashItemEquipmentPresetDto extends characterCashItemEquipment.Cha
235
275
 
236
276
  exports.CharacterCashItemEquipmentColoringPrismDto = CharacterCashItemEquipmentColoringPrismDto;
237
277
  exports.CharacterCashItemEquipmentDto = CharacterCashItemEquipmentDto;
278
+ exports.CharacterCashItemEquipmentEffectPrismDto = CharacterCashItemEquipmentEffectPrismDto;
238
279
  exports.CharacterCashItemEquipmentOptionDto = CharacterCashItemEquipmentOptionDto;
239
280
  exports.CharacterCashItemEquipmentPresetDto = CharacterCashItemEquipmentPresetDto;
@@ -44,6 +44,10 @@ class CharacterSymbolEquipmentInfoDto extends characterSymbolEquipment.Character
44
44
  * 심볼 설명
45
45
  */
46
46
  symbolDescription;
47
+ /**
48
+ * 심볼 부가 효과 설명
49
+ */
50
+ symbolOtherEffectDescription;
47
51
  /**
48
52
  * 심볼로 인한 증가 수치
49
53
  */
@@ -94,10 +98,11 @@ class CharacterSymbolEquipmentInfoDto extends characterSymbolEquipment.Character
94
98
  symbolRequireGrowthCount;
95
99
  constructor(obj) {
96
100
  super();
97
- const { symbol_name, symbol_icon, symbol_description, symbol_force, symbol_level, symbol_str, symbol_dex, symbol_int, symbol_luk, symbol_hp, symbol_drop_rate, symbol_meso_rate, symbol_exp_rate, symbol_growth_count, symbol_require_growth_count, } = obj;
101
+ const { symbol_name, symbol_icon, symbol_description, symbol_other_effect_description, symbol_force, symbol_level, symbol_str, symbol_dex, symbol_int, symbol_luk, symbol_hp, symbol_drop_rate, symbol_meso_rate, symbol_exp_rate, symbol_growth_count, symbol_require_growth_count, } = obj;
98
102
  this.symbolName = symbol_name;
99
103
  this.symbolIcon = symbol_icon;
100
104
  this.symbolDescription = symbol_description;
105
+ this.symbolOtherEffectDescription = symbol_other_effect_description;
101
106
  this.symbolForce = symbol_force;
102
107
  this.symbolLevel = symbol_level;
103
108
  this.symbolStr = symbol_str;
@@ -44,6 +44,7 @@ class CharacterVMatrixCodeEquipmentDto extends characterVMatrix.CharacterVMatrix
44
44
  slotId;
45
45
  /**
46
46
  * 슬롯 레벨
47
+ * @deprecated 2025년 12월 18일 점검 이후부터 사용하지 않는 항목입니다.
47
48
  */
48
49
  slotLevel;
49
50
  /**
@@ -60,14 +61,17 @@ class CharacterVMatrixCodeEquipmentDto extends characterVMatrix.CharacterVMatrix
60
61
  vCoreLevel;
61
62
  /**
62
63
  * 코어에 해당하는 스킬 명
64
+ * @deprecated 2025년 12월 18일 점검 이후부터 사용하지 않는 항목입니다.
63
65
  */
64
66
  vCoreSkill1;
65
67
  /**
66
68
  * (강화 코어인 경우) 코어에 해당하는 두 번째 스킬 명
69
+ * @deprecated 2025년 12월 18일 점검 이후부터 사용하지 않는 항목입니다.
67
70
  */
68
71
  vCoreSkill2;
69
72
  /**
70
73
  * (강화 코어인 경우) 코어에 해당하는 세 번째 스킬 명
74
+ * @deprecated 2025년 12월 18일 점검 이후부터 사용하지 않는 항목입니다.
71
75
  */
72
76
  vCoreSkill3;
73
77
  constructor(obj) {
@@ -27,6 +27,10 @@ class CashshopNoticeListItemDto {
27
27
  * 공지 링크
28
28
  */
29
29
  url;
30
+ /**
31
+ * 썸네일 링크
32
+ */
33
+ thumbnailUrl;
30
34
  /**
31
35
  * 공지 식별자
32
36
  */
@@ -48,9 +52,10 @@ class CashshopNoticeListItemDto {
48
52
  */
49
53
  ongoingFlag;
50
54
  constructor(obj) {
51
- const { title, url, notice_id, date, date_sale_start, date_sale_end, ongoing_flag, } = obj;
55
+ const { title, url, thumbnail_url, notice_id, date, date_sale_start, date_sale_end, ongoing_flag, } = obj;
52
56
  this.title = title;
53
57
  this.url = url;
58
+ this.thumbnailUrl = thumbnail_url;
54
59
  this.noticeId = notice_id;
55
60
  this.date = new Date(date);
56
61
  this.dateSaleStart = date_sale_start ? new Date(date_sale_start) : null;
@@ -27,6 +27,10 @@ class EventNoticeListItemDto {
27
27
  * 공지 링크
28
28
  */
29
29
  url;
30
+ /**
31
+ * 썸네일 링크
32
+ */
33
+ thumbnailUrl;
30
34
  /**
31
35
  * 공지 식별자
32
36
  */
@@ -44,9 +48,10 @@ class EventNoticeListItemDto {
44
48
  */
45
49
  dateEventEnd;
46
50
  constructor(obj) {
47
- const { title, url, notice_id, date, date_event_start, date_event_end } = obj;
51
+ const { title, url, thumbnail_url, notice_id, date, date_event_start, date_event_end } = obj;
48
52
  this.title = title;
49
53
  this.url = url;
54
+ this.thumbnailUrl = thumbnail_url;
50
55
  this.noticeId = notice_id;
51
56
  this.date = new Date(date);
52
57
  this.dateEventStart = new Date(date_event_start);
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var mapleStoryApi = require('./mapleStoryApi.js');
6
+ var mapleStoryFriendsApi = require('./mapleStoryFriendsApi.js');
6
7
  var character = require('./dto/character/character.js');
7
8
  var characterAbility = require('./dto/character/characterAbility.js');
8
9
  var characterAndroidEquipment = require('./dto/character/characterAndroidEquipment.js');
@@ -55,6 +56,7 @@ var inspectionInfo = require('./dto/inspectionInfo.js');
55
56
 
56
57
 
57
58
  exports.MapleStoryApi = mapleStoryApi.MapleStoryApi;
59
+ exports.MapleStoryFriendsApi = mapleStoryFriendsApi.MapleStoryFriendsApi;
58
60
  exports.CharacterDto = character.CharacterDto;
59
61
  exports.CharacterAbilityDto = characterAbility.CharacterAbilityDto;
60
62
  exports.CharacterAbilityInfoDto = characterAbility.CharacterAbilityInfoDto;
@@ -74,6 +76,7 @@ exports.CharacterBeautyEquipmentHairDto = characterBeautyEquipment.CharacterBeau
74
76
  exports.CharacterBeautyEquipmentSkinDto = characterBeautyEquipment.CharacterBeautyEquipmentSkinDto;
75
77
  exports.CharacterCashItemEquipmentColoringPrismDto = characterCashItemEquipment.CharacterCashItemEquipmentColoringPrismDto;
76
78
  exports.CharacterCashItemEquipmentDto = characterCashItemEquipment.CharacterCashItemEquipmentDto;
79
+ exports.CharacterCashItemEquipmentEffectPrismDto = characterCashItemEquipment.CharacterCashItemEquipmentEffectPrismDto;
77
80
  exports.CharacterCashItemEquipmentOptionDto = characterCashItemEquipment.CharacterCashItemEquipmentOptionDto;
78
81
  exports.CharacterCashItemEquipmentPresetDto = characterCashItemEquipment.CharacterCashItemEquipmentPresetDto;
79
82
  exports.CharacterDojangDto = characterDojang.CharacterDojangDto;
@@ -0,0 +1,116 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var cubeHistory = require('./dto/history/cubeHistory.js');
6
+ var potentialHistory = require('./dto/history/potentialHistory.js');
7
+ var starforceHistory = require('./dto/history/starforceHistory.js');
8
+ var achievement = require('./dto/user/achievement.js');
9
+ var characterList = require('./dto/user/characterList.js');
10
+ var mapleStoryFriendsApi = require('../common/mapleStoryFriendsApi.js');
11
+
12
+ /**
13
+ * MapleStory Friends API client for KMS<br>
14
+ * This is an implementation of <a href="https://openapi.nexon.com/ko/friends/maplestory/?id=36">MapleStory Friends API</a>
15
+ */
16
+ class MapleStoryFriendsApi extends mapleStoryFriendsApi.MapleStoryFriendsApi {
17
+ subUrl = 'maplestory';
18
+ timezoneOffset = 540;
19
+ constructor(accessToken) {
20
+ super(accessToken);
21
+ }
22
+ //#region 계정 정보 조회
23
+ /**
24
+ * 계정의 보유 캐릭터 목록을 조회합니다.
25
+ * - 이 항목을 조회하시려면 NEXON Open ID 클라이언트 설정에서 '캐릭터 목록'을 활용 데이터 항목으로 선택해주세요.
26
+ * - 이후 자세한 데이터 호출 및 활용 방법은 <a href="https://openapi.nexon.com/ko/open-id/development-guide/">NEXON Open ID 개발 가이드 문서</a>를 참조해주세요.
27
+ */
28
+ async getCharacterList() {
29
+ const path = `${this.subUrl}/v1/character/list`;
30
+ const { data } = await this.client.get(path);
31
+ return new characterList.CharacterListDto(data);
32
+ }
33
+ /**
34
+ * 계정의 업적 정보를 조회합니다.
35
+ * - 이 항목을 조회하시려면 NEXON Open ID 클라이언트 설정에서 '업적 정보'를 활용 데이터 항목으로 선택해주세요.
36
+ * - 이후 자세한 데이터 호출 및 활용 방법은 <a href="https://openapi.nexon.com/ko/open-id/development-guide/">NEXON Open ID 개발 가이드 문서</a>를 참조해주세요.
37
+ */
38
+ async getAchievement() {
39
+ const path = `${this.subUrl}/v1/user/achievement`;
40
+ const { data } = await this.client.get(path);
41
+ return new achievement.AchievementDto(data);
42
+ }
43
+ async getStarforceHistory(count, parameter) {
44
+ const path = `${this.subUrl}/v1/history/starforce`;
45
+ const query = {
46
+ count,
47
+ };
48
+ if (typeof parameter === 'string') {
49
+ query.cursor = parameter;
50
+ }
51
+ else if (typeof parameter === 'object' || parameter === undefined) {
52
+ query.date = this.toDateString(parameter ??
53
+ this.getProperDefaultDateOptions({
54
+ hour: 0,
55
+ minute: 0,
56
+ dateOffset: 0,
57
+ }), {
58
+ year: 2023,
59
+ month: 12,
60
+ day: 27,
61
+ });
62
+ }
63
+ const { data } = await this.client.get(path, {
64
+ params: query,
65
+ });
66
+ return new starforceHistory.StarforceHistoryResponseDto(data);
67
+ }
68
+ async getCubeHistory(count, parameter) {
69
+ const path = `${this.subUrl}/v1/history/cube`;
70
+ const query = {
71
+ count,
72
+ };
73
+ if (typeof parameter === 'string') {
74
+ query.cursor = parameter;
75
+ }
76
+ else if (typeof parameter === 'object' || parameter === undefined) {
77
+ query.date = this.toDateString(parameter ??
78
+ this.getProperDefaultDateOptions({
79
+ hour: 0,
80
+ minute: 0,
81
+ dateOffset: 0,
82
+ }));
83
+ }
84
+ const { data } = await this.client.get(path, {
85
+ params: query,
86
+ });
87
+ return new cubeHistory.CubeHistoryResponseDto(data);
88
+ }
89
+ async getPotentialHistory(count, parameter) {
90
+ const path = `${this.subUrl}/v1/history/potential`;
91
+ const query = {
92
+ count,
93
+ };
94
+ if (typeof parameter === 'string') {
95
+ query.cursor = parameter;
96
+ }
97
+ else if (typeof parameter === 'object' || parameter === undefined) {
98
+ query.date = this.toDateString(parameter ??
99
+ this.getProperDefaultDateOptions({
100
+ hour: 0,
101
+ minute: 0,
102
+ dateOffset: 0,
103
+ }), {
104
+ year: 2024,
105
+ month: 1,
106
+ day: 25,
107
+ });
108
+ }
109
+ const { data } = await this.client.get(path, {
110
+ params: query,
111
+ });
112
+ return new potentialHistory.PotentialHistoryResponseDto(data);
113
+ }
114
+ }
115
+
116
+ exports.MapleStoryFriendsApi = MapleStoryFriendsApi;
@@ -29,6 +29,7 @@ var MapleStoryApiErrorCode;
29
29
  MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00009"] = 7] = "OPENAPI00009";
30
30
  MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00010"] = 8] = "OPENAPI00010";
31
31
  MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00011"] = 9] = "OPENAPI00011";
32
+ MapleStoryApiErrorCode[MapleStoryApiErrorCode["OPENAPI00012"] = 10] = "OPENAPI00012";
32
33
  })(MapleStoryApiErrorCode || (MapleStoryApiErrorCode = {}));
33
34
  const ERROR_MAP = {
34
35
  ['OPENAPI00001']: MapleStoryApiErrorCode.OPENAPI00001,
@@ -41,6 +42,7 @@ const ERROR_MAP = {
41
42
  ['OPENAPI00009']: MapleStoryApiErrorCode.OPENAPI00009,
42
43
  ['OPENAPI00010']: MapleStoryApiErrorCode.OPENAPI00010,
43
44
  ['OPENAPI00011']: MapleStoryApiErrorCode.OPENAPI00011,
45
+ ['OPENAPI00012']: MapleStoryApiErrorCode.OPENAPI00012,
44
46
  };
45
47
 
46
48
  export { MapleStoryApiError, MapleStoryApiErrorCode };
@@ -0,0 +1,111 @@
1
+ import axios, { AxiosError } from 'axios';
2
+ import dayjs from 'dayjs';
3
+ import timezone from '../../../node_modules/dayjs/plugin/timezone.js';
4
+ import utc from '../../../node_modules/dayjs/plugin/utc.js';
5
+ import { MapleStoryApiError } from './mapleStoryApiError.js';
6
+
7
+ dayjs.extend(timezone);
8
+ dayjs.extend(utc);
9
+ /**
10
+ * MapleStory Friends API client.
11
+ */
12
+ class MapleStoryFriendsApi {
13
+ accessToken;
14
+ client;
15
+ static BASE_URL = 'https://open.api.nexon.com/';
16
+ static DEFAULT_TIMEOUT = 5000;
17
+ get timeout() {
18
+ return this.client.defaults.timeout;
19
+ }
20
+ set timeout(value) {
21
+ this.client.defaults.timeout = value;
22
+ }
23
+ constructor(accessToken) {
24
+ this.accessToken = accessToken;
25
+ this.client = axios.create({
26
+ baseURL: MapleStoryFriendsApi.BASE_URL,
27
+ timeout: MapleStoryFriendsApi.DEFAULT_TIMEOUT,
28
+ headers: {
29
+ 'Authorization': `Bearer ${this.accessToken}`,
30
+ },
31
+ });
32
+ this.client.interceptors.response.use((response) => response, (error) => {
33
+ if (error instanceof AxiosError) {
34
+ const errorBody = error.response
35
+ .data;
36
+ throw new MapleStoryApiError(errorBody);
37
+ }
38
+ throw error;
39
+ });
40
+ }
41
+ /**
42
+ * API 서버의 데이터 갱신 시간에 따라 데이터가 조회 가능한 최신 날짜를 반환합니다.
43
+ *
44
+ * @param options
45
+ */
46
+ getProperDefaultDateOptions(options) {
47
+ const { hour, minute, dateOffset } = options;
48
+ const nowInTimezone = dayjs().utcOffset(this.timezoneOffset);
49
+ const updateDate = dayjs().utcOffset(this.timezoneOffset).hour(hour).minute(minute);
50
+ let adjustedDate;
51
+ if (nowInTimezone.isAfter(updateDate)) {
52
+ adjustedDate = nowInTimezone;
53
+ }
54
+ else {
55
+ adjustedDate = nowInTimezone.subtract(1, 'day');
56
+ }
57
+ adjustedDate = adjustedDate.subtract(dateOffset ?? 0, 'day');
58
+ return {
59
+ year: adjustedDate.year(),
60
+ month: adjustedDate.month() + 1,
61
+ day: adjustedDate.date(),
62
+ };
63
+ }
64
+ ;
65
+ /**
66
+ * 날짜 정보를 API 서버에서 요구하는 포맷으로 변환합니다.
67
+ *
68
+ * @param dateOptions 조회 하려는 날짜
69
+ * @param minDateOptions API 호출 가능한 최소 날짜
70
+ */
71
+ toDateString(dateOptions, minDateOptions) {
72
+ const convert = (dateOptions) => {
73
+ let year;
74
+ let month;
75
+ let day;
76
+ let d;
77
+ if (dateOptions instanceof Date) {
78
+ d = dayjs(dateOptions).utcOffset(this.timezoneOffset);
79
+ year = d.year();
80
+ month = d.month() + 1;
81
+ day = d.date();
82
+ }
83
+ else {
84
+ year = dateOptions.year;
85
+ month = dateOptions.month;
86
+ day = dateOptions.day;
87
+ d = dayjs(`${year}-${month}-${day}`).utcOffset(this.timezoneOffset);
88
+ }
89
+ return {
90
+ year,
91
+ month,
92
+ day,
93
+ d,
94
+ };
95
+ };
96
+ const { year, month, day, d } = convert(dateOptions);
97
+ const str = d.format('YYYY-MM-DD');
98
+ if (minDateOptions) {
99
+ const { year: minYear, month: minMonth, day: minDay, } = convert(minDateOptions);
100
+ if (year < minYear ||
101
+ (year === minYear && month < minMonth) ||
102
+ (year === minYear && month === minMonth && day < minDay)) {
103
+ throw new Error(`You can only retrieve data after ${dayjs(`${minYear}-${minMonth}-${minDay}`).format('YYYY-MM-DD')}.`);
104
+ }
105
+ }
106
+ return str;
107
+ }
108
+ ;
109
+ }
110
+
111
+ export { MapleStoryFriendsApi };
@@ -107,6 +107,34 @@ class CharacterCashItemEquipmentColoringPrismDto extends CharacterCashItemEquipm
107
107
  this.value = value;
108
108
  }
109
109
  }
110
+ /**
111
+ * 캐릭터 캐시 장비(무기) 이펙트 프리즘
112
+ */
113
+ class CharacterCashItemEquipmentEffectPrismDto {
114
+ /**
115
+ * 이펙트 프리즘 색상 범위
116
+ */
117
+ colorRange;
118
+ /**
119
+ * 이펙트 프리즘 색조
120
+ */
121
+ hue;
122
+ /**
123
+ * 이펙트 프리즘 채도
124
+ */
125
+ saturation;
126
+ /**
127
+ * 이펙트 프리즘 명도
128
+ */
129
+ value;
130
+ constructor(obj) {
131
+ const { color_range, hue, saturation, value } = obj;
132
+ this.colorRange = color_range;
133
+ this.hue = hue;
134
+ this.saturation = saturation;
135
+ this.value = value;
136
+ }
137
+ }
110
138
  /**
111
139
  * 캐릭터 캐시 장비 옵션
112
140
  */
@@ -178,6 +206,10 @@ class CharacterCashItemEquipmentPresetDto extends CharacterCashItemEquipmentPres
178
206
  * 캐시 장비 컬러링프리즘 정보
179
207
  */
180
208
  cashItemColoringPrism;
209
+ /**
210
+ * 캐시 장비(무기) 이펙트 프리즘 정보
211
+ */
212
+ cashItemEffectPrism;
181
213
  /**
182
214
  * 아이템 장착 가능 성별
183
215
  */
@@ -190,9 +222,13 @@ class CharacterCashItemEquipmentPresetDto extends CharacterCashItemEquipmentPres
190
222
  * 프리스타일 쿠폰 적용 여부 (0:미적용, 1:적용)
191
223
  */
192
224
  freestyleFlag;
225
+ /**
226
+ * 표정 합성 정보
227
+ */
228
+ emotion_name;
193
229
  constructor(obj) {
194
230
  super();
195
- const { cash_item_equipment_part, cash_item_equipment_slot, cash_item_name, cash_item_icon, cash_item_description, cash_item_option, date_expire, date_option_expire, cash_item_label, cash_item_coloring_prism, item_gender, skills, freestyle_flag, } = obj;
231
+ const { cash_item_equipment_part, cash_item_equipment_slot, cash_item_name, cash_item_icon, cash_item_description, cash_item_option, date_expire, date_option_expire, cash_item_label, cash_item_coloring_prism, cash_item_effect_prism, item_gender, skills, freestyle_flag, emotion_name, } = obj;
196
232
  this.cashItemEquipmentPart = cash_item_equipment_part;
197
233
  this.cashItemEquipmentSlot = cash_item_equipment_slot;
198
234
  this.cashItemName = cash_item_name;
@@ -203,9 +239,13 @@ class CharacterCashItemEquipmentPresetDto extends CharacterCashItemEquipmentPres
203
239
  this.cashItemColoringPrism = cash_item_coloring_prism
204
240
  ? new CharacterCashItemEquipmentColoringPrismDto(cash_item_coloring_prism)
205
241
  : null;
242
+ this.cashItemEffectPrism = cash_item_effect_prism
243
+ ? new CharacterCashItemEquipmentEffectPrismDto(cash_item_effect_prism)
244
+ : null;
206
245
  this.itemGender = item_gender;
207
246
  this.skills = skills;
208
247
  this.freestyleFlag = freestyle_flag;
248
+ this.emotion_name = emotion_name;
209
249
  if (date_expire === 'expired') {
210
250
  this.isExpired = true;
211
251
  }
@@ -229,4 +269,4 @@ class CharacterCashItemEquipmentPresetDto extends CharacterCashItemEquipmentPres
229
269
  }
230
270
  }
231
271
 
232
- export { CharacterCashItemEquipmentColoringPrismDto, CharacterCashItemEquipmentDto, CharacterCashItemEquipmentOptionDto, CharacterCashItemEquipmentPresetDto };
272
+ export { CharacterCashItemEquipmentColoringPrismDto, CharacterCashItemEquipmentDto, CharacterCashItemEquipmentEffectPrismDto, CharacterCashItemEquipmentOptionDto, CharacterCashItemEquipmentPresetDto };