maplestory-openapi 1.0.0 → 1.1.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.
- package/README.md +78 -0
- package/dist/index.js +68 -0
- package/dist/index.min.js +1 -1
- package/dist/index.mjs +67 -1
- package/package.json +5 -2
- package/types/index.d.ts +1 -0
- package/types/maplestory/api/dto/inspectionInfoDto.d.ts +24 -0
- package/types/maplestory/api/mapleStoryApi.d.ts +11 -3
- package/types/maplestory/api/response/inspectionInfoSoapBody.d.ts +137 -0
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# MapleStory OpenAPI JavaScript Library
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/maplestory-openapi)
|
|
4
|
+
|
|
5
|
+
This JavaScript library enables the use of the MapleStory OpenAPI provided by Nexon.
|
|
6
|
+
|
|
7
|
+
Packages written in other languages can be found [HERE](https://github.com/SpiralMoon/maplestory.openapi).
|
|
8
|
+
|
|
9
|
+
(한국어 문서는 [이쪽](https://github.com/SpiralMoon/maplestory.openapi/blob/master/js/README-ko.md)입니다.)
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Install the latest version of the JavaScript/TypeScript library in your npm project:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install maplestory-openapi@1.1.0 # Replace with the latest version
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Supports
|
|
22
|
+
|
|
23
|
+
1. **CommonJS, ESM Support**: The library supports both CommonJS and ESM usage.
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
const {MapleStoryApi, MapleStoryApiError} = require('maplestory-openapi'); // CommonJS
|
|
27
|
+
```
|
|
28
|
+
```typescript
|
|
29
|
+
import {MapleStoryApi, MapleStoryApiError} from 'maplestory-openapi'; // ESM
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
2. **TypeScript Support**: TypeScript is fully supported. Type definitions are included.
|
|
33
|
+
|
|
34
|
+
### Sample Code
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
const {MapleStoryApi, MapleStoryApiError} = require('maplestory-openapi');
|
|
38
|
+
|
|
39
|
+
const apiKey = '{Your API Key}';
|
|
40
|
+
const api = new MapleStoryApi(apiKey);
|
|
41
|
+
|
|
42
|
+
api.getCubeResult(1000, {
|
|
43
|
+
year: 2023,
|
|
44
|
+
month: 10,
|
|
45
|
+
day: 15
|
|
46
|
+
})
|
|
47
|
+
.then((dto) => {
|
|
48
|
+
const {count, cubeHistories, nextCursor} = dto;
|
|
49
|
+
|
|
50
|
+
console.log('You used ' + count + ' cubes.');
|
|
51
|
+
})
|
|
52
|
+
.catch((e) => {
|
|
53
|
+
if (e instanceof MapleStoryApiError) {
|
|
54
|
+
// handle MapleStoryApiError
|
|
55
|
+
} else {
|
|
56
|
+
// handle other errors
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
console.log(e);
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Exception Handling
|
|
64
|
+
|
|
65
|
+
Handle `MapleStoryApiError` to safely make calls, ensuring that specific Status defined in the [MapleStory OpenAPI Guide](https://developers.nexon.com/Maplestory/guides) are not encountered.
|
|
66
|
+
|
|
67
|
+
While `MapleStoryApi` is designed to prevent the occurrence of certain Status, exceptions may arise due to developer mistakes.
|
|
68
|
+
|
|
69
|
+
Therefore, it's recommended to use `MapleStoryApiError` for exception handling based on the Status list described in the table below.
|
|
70
|
+
|
|
71
|
+
| Status | Message |
|
|
72
|
+
|--------|---------------------------------------------------------|
|
|
73
|
+
| 400 | Request format error (incorrect parameter input) |
|
|
74
|
+
| 401 | Unauthorized service (unsupported service, service type) |
|
|
75
|
+
| 403 | Unauthorized AccessToken usage |
|
|
76
|
+
| 429 | AccessToken's request allowance (Rate Limit) exceeded |
|
|
77
|
+
| 500 | Internal server error |
|
|
78
|
+
| 504 | Internal server processing timeout |
|
package/dist/index.js
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var axios = require('axios');
|
|
4
4
|
var dayjs = require('dayjs');
|
|
5
|
+
var xml2js = require('xml2js');
|
|
5
6
|
|
|
6
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
7
8
|
|
|
8
9
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
9
10
|
var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
|
|
11
|
+
var xml2js__default = /*#__PURE__*/_interopDefaultLegacy(xml2js);
|
|
10
12
|
|
|
11
13
|
exports.PotentialOptionGrade = void 0;
|
|
12
14
|
(function (PotentialOptionGrade) {
|
|
@@ -191,6 +193,35 @@ class CubeHistoryResponseDto {
|
|
|
191
193
|
}
|
|
192
194
|
}
|
|
193
195
|
|
|
196
|
+
/**
|
|
197
|
+
* 서버 점검 정보
|
|
198
|
+
*/
|
|
199
|
+
class InspectionInfoDto {
|
|
200
|
+
/**
|
|
201
|
+
* 서비스 코드
|
|
202
|
+
*/
|
|
203
|
+
serviceCode;
|
|
204
|
+
/**
|
|
205
|
+
* 점검 시작 시각
|
|
206
|
+
*/
|
|
207
|
+
startDateTime;
|
|
208
|
+
/**
|
|
209
|
+
* 점검 종료 시각
|
|
210
|
+
*/
|
|
211
|
+
endDateTime;
|
|
212
|
+
/**
|
|
213
|
+
* 점검 안내 제목
|
|
214
|
+
*/
|
|
215
|
+
strObstacleContents;
|
|
216
|
+
constructor(obj) {
|
|
217
|
+
const inspectionInfoTag = obj["soap:Envelope"]['soap:Body'][0]['GetInspectionInfoResponse'][0]['GetInspectionInfoResult'][0]['diffgr:diffgram'][0]['NewDataSet'][0]['InspectionInfo'][0];
|
|
218
|
+
this.serviceCode = Number(inspectionInfoTag.serviceCode[0]);
|
|
219
|
+
this.startDateTime = new Date(inspectionInfoTag.startDateTime[0]);
|
|
220
|
+
this.endDateTime = new Date(inspectionInfoTag.endDateTime[0]);
|
|
221
|
+
this.strObstacleContents = inspectionInfoTag.strObstacleContents[0];
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
194
225
|
/**
|
|
195
226
|
* MapleStory OpenAPI error.<br>
|
|
196
227
|
* Please refer to <a href="https://developers.nexon.com/Maplestory/guides">MapleStory API guide</a> for the error details.
|
|
@@ -273,6 +304,42 @@ class MapleStoryApi {
|
|
|
273
304
|
throw e;
|
|
274
305
|
}
|
|
275
306
|
}
|
|
307
|
+
/**
|
|
308
|
+
* 서버 점검 정보를 조회합니다.
|
|
309
|
+
*/
|
|
310
|
+
async getInspectionInfo() {
|
|
311
|
+
const xmlBuilder = new xml2js__default["default"].Builder();
|
|
312
|
+
const soapEnvelop = {
|
|
313
|
+
'soap:Envelope': {
|
|
314
|
+
$: {
|
|
315
|
+
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
|
316
|
+
'xmlns:xsd': 'http://www.w3.org/2001/XMLSchema',
|
|
317
|
+
'xmlns:soap': 'http://schemas.xmlsoap.org/soap/envelope/'
|
|
318
|
+
},
|
|
319
|
+
'soap:Body': {
|
|
320
|
+
'GetInspectionInfo': {
|
|
321
|
+
$: {
|
|
322
|
+
'xmlns': 'https://api.maplestory.nexon.com/soap/'
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
const baseUrl = 'https://api.maplestory.nexon.com/';
|
|
329
|
+
const path = 'soap/maplestory.asmx';
|
|
330
|
+
const headers = {
|
|
331
|
+
'SOAPAction': 'https://api.maplestory.nexon.com/soap/GetInspectionInfo',
|
|
332
|
+
'Content-Type': 'text/xml; charset=utf-8'
|
|
333
|
+
};
|
|
334
|
+
const body = xmlBuilder.buildObject(soapEnvelop);
|
|
335
|
+
const response = await axios__default["default"].post(path, body, {
|
|
336
|
+
baseURL: baseUrl,
|
|
337
|
+
timeout: this.timeout,
|
|
338
|
+
headers,
|
|
339
|
+
});
|
|
340
|
+
const xml = await xml2js__default["default"].parseStringPromise(response.data);
|
|
341
|
+
return new InspectionInfoDto(xml);
|
|
342
|
+
}
|
|
276
343
|
buildHeaders() {
|
|
277
344
|
return {
|
|
278
345
|
'authorization': this.apiKey
|
|
@@ -283,6 +350,7 @@ class MapleStoryApi {
|
|
|
283
350
|
exports.CubeHistoryDto = CubeHistoryDto;
|
|
284
351
|
exports.CubeHistoryResponseDto = CubeHistoryResponseDto;
|
|
285
352
|
exports.CubeResultOptionDto = CubeResultOptionDto;
|
|
353
|
+
exports.InspectionInfoDto = InspectionInfoDto;
|
|
286
354
|
exports.MapleStoryApi = MapleStoryApi;
|
|
287
355
|
exports.MapleStoryApiError = MapleStoryApiError;
|
|
288
356
|
exports.potentialOptionGradeFromString = potentialOptionGradeFromString;
|
package/dist/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("axios"),require("dayjs")):"function"==typeof define&&define.amd?define(["exports","axios","dayjs"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["maplestory-openapi"]={},t.axios,t.dayjs)}(this,(function(t,e,i){"use strict";function
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("axios"),require("dayjs"),require("xml2js")):"function"==typeof define&&define.amd?define(["exports","axios","dayjs","xml2js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["maplestory-openapi"]={},t.axios,t.dayjs,t.xml2js)}(this,(function(t,e,i,a){"use strict";function o(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n,s=o(e),r=o(i),u=o(a);t.PotentialOptionGrade=void 0,(n=t.PotentialOptionGrade||(t.PotentialOptionGrade={}))[n.RARE=0]="RARE",n[n.EPIC=1]="EPIC",n[n.UNIQUE=2]="UNIQUE",n[n.LEGENDARY=3]="LEGENDARY";const l=e=>{const i={"레어":t.PotentialOptionGrade.RARE,"에픽":t.PotentialOptionGrade.EPIC,"유니크":t.PotentialOptionGrade.UNIQUE,"레전드리":t.PotentialOptionGrade.LEGENDARY}[e];if(!i)throw new TypeError("No enum constant for string: "+e);return i};class f{value;grade;constructor(t){const{value:e,grade:i}=t;this.value=e,this.grade=i}get gradeEnum(){return l(this.grade)}}class c{id;characterName;worldName;createDate;cubeType;itemUpgradeResult;miracleTimeFlag;itemEquipPart;itemLevel;targetItem;potentialOptionGrade;additionalPotentialOptionGrade;upgradeGuarantee;upgradeGuaranteeCount;beforePotentialOptions;beforeAdditionalPotentialOptions;afterPotentialOptions;afterAdditionalPotentialOptions;constructor(t){const{id:e,character_name:i,world_name:a,create_date:o,cube_type:n,item_upgrade_result:s,miracle_time_flag:r,item_equip_part:u,item_level:l,target_item:c,potential_option_grade:d,additional_potential_option_grade:p,upgradeguarantee:h,upgradeguaranteecount:m,before_potential_options:g,before_additional_potential_options:v,after_potential_options:$,after_additional_potential_options:O}=t;this.id=e,this.characterName=i,this.worldName=a,this.createDate=o,this.cubeType=n,this.itemUpgradeResult=s,this.miracleTimeFlag=r,this.itemEquipPart=u,this.itemLevel=l,this.targetItem=c,this.potentialOptionGrade=d,this.additionalPotentialOptionGrade=p,this.upgradeGuarantee=h,this.upgradeGuaranteeCount=m,this.beforePotentialOptions=g.map((t=>new f(t))),this.beforeAdditionalPotentialOptions=v.map((t=>new f(t))),this.afterPotentialOptions=$.map((t=>new f(t))),this.afterAdditionalPotentialOptions=O.map((t=>new f(t)))}get isItemUpgrade(){return"성공"===this.itemUpgradeResult}get isMiracleTimeFlag(){return"이벤트 적용되지 않음"!==this.miracleTimeFlag}get potentialOptionGradeEnum(){return l(this.potentialOptionGrade)}get additionalPotentialOptionGradeEnum(){return l(this.additionalPotentialOptionGrade)}}class d{count;cubeHistories;nextCursor;constructor(t){const{count:e,cube_histories:i,next_cursor:a}=t;this.count=e,this.cubeHistories=i.map((t=>new c(t))),this.nextCursor=a}}class p{serviceCode;startDateTime;endDateTime;strObstacleContents;constructor(t){const e=t["soap:Envelope"]["soap:Body"][0].GetInspectionInfoResponse[0].GetInspectionInfoResult[0]["diffgr:diffgram"][0].NewDataSet[0].InspectionInfo[0];this.serviceCode=Number(e.serviceCode[0]),this.startDateTime=new Date(e.startDateTime[0]),this.endDateTime=new Date(e.endDateTime[0]),this.strObstacleContents=e.strObstacleContents[0]}}class h extends Error{name="MapleStoryApiError";status;message;constructor(t){const{status:e,message:i}=t;super(i),this.status=e,this.message=i}}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var m={exports:{}};!function(t,e){var i,a;t.exports=(i={year:0,month:1,day:2,hour:3,minute:4,second:5},a={},function(t,e,o){var n,s=function(t,e,i){void 0===i&&(i={});var o=new Date(t),n=function(t,e){void 0===e&&(e={});var i=e.timeZoneName||"short",o=t+"|"+i,n=a[o];return n||(n=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:t,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:i}),a[o]=n),n}(e,i);return n.formatToParts(o)},r=function(t,e){for(var a=s(t,e),n=[],r=0;r<a.length;r+=1){var u=a[r],l=u.type,f=u.value,c=i[l];c>=0&&(n[c]=parseInt(f,10))}var d=n[3],p=24===d?0:d,h=n[0]+"-"+n[1]+"-"+n[2]+" "+p+":"+n[4]+":"+n[5]+":000",m=+t;return(o.utc(h).valueOf()-(m-=m%1e3))/6e4},u=e.prototype;u.tz=function(t,e){void 0===t&&(t=n);var i=this.utcOffset(),a=this.toDate(),s=a.toLocaleString("en-US",{timeZone:t}),r=Math.round((a-new Date(s))/1e3/60),u=o(s,{locale:this.$L}).$set("millisecond",this.$ms).utcOffset(15*-Math.round(a.getTimezoneOffset()/15)-r,!0);if(e){var l=u.utcOffset();u=u.add(i-l,"minute")}return u.$x.$timezone=t,u},u.offsetName=function(t){var e=this.$x.$timezone||o.tz.guess(),i=s(this.valueOf(),e,{timeZoneName:t}).find((function(t){return"timezonename"===t.type.toLowerCase()}));return i&&i.value};var l=u.startOf;u.startOf=function(t,e){if(!this.$x||!this.$x.$timezone)return l.call(this,t,e);var i=o(this.format("YYYY-MM-DD HH:mm:ss:SSS"),{locale:this.$L});return l.call(i,t,e).tz(this.$x.$timezone,!0)},o.tz=function(t,e,i){var a=i&&e,s=i||e||n,u=r(+o(),s);if("string"!=typeof t)return o(t).tz(s);var l=function(t,e,i){var a=t-60*e*1e3,o=r(a,i);if(e===o)return[a,e];var n=r(a-=60*(o-e)*1e3,i);return o===n?[a,o]:[t-60*Math.min(o,n)*1e3,Math.max(o,n)]}(o.utc(t,a).valueOf(),u,s),f=l[0],c=l[1],d=o(f).utcOffset(c);return d.$x.$timezone=s,d},o.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},o.tz.setDefault=function(t){n=t}})}(m);var g=m.exports,v={exports:{}};!function(t,e){var i,a,o;t.exports=(i="minute",a=/[+-]\d\d(?::?\d\d)?/g,o=/([+-]|\d\d)/g,function(t,e,n){var s=e.prototype;n.utc=function(t){return new e({date:t,utc:!0,args:arguments})},s.utc=function(t){var e=n(this.toDate(),{locale:this.$L,utc:!0});return t?e.add(this.utcOffset(),i):e},s.local=function(){return n(this.toDate(),{locale:this.$L,utc:!1})};var r=s.parse;s.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),r.call(this,t)};var u=s.init;s.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()}else u.call(this)};var l=s.utcOffset;s.utcOffset=function(t,e){var n=this.$utils().u;if(n(t))return this.$u?0:n(this.$offset)?l.call(this):this.$offset;if("string"==typeof t&&(t=function(t){void 0===t&&(t="");var e=t.match(a);if(!e)return null;var i=(""+e[0]).match(o)||["-",0,0],n=i[0],s=60*+i[1]+ +i[2];return 0===s?0:"+"===n?s:-s}(t),null===t))return this;var s=Math.abs(t)<=16?60*t:t,r=this;if(e)return r.$offset=s,r.$u=0===t,r;if(0!==t){var u=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(r=this.local().add(s+u,i)).$offset=s,r.$x.$localOffset=u}else r=this.utc();return r};var f=s.format;s.format=function(t){var e=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return f.call(this,e)},s.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*t},s.isUTC=function(){return!!this.$u},s.toISOString=function(){return this.toDate().toISOString()},s.toString=function(){return this.toDate().toUTCString()};var c=s.toDate;s.toDate=function(t){return"s"===t&&this.$offset?n(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():c.call(this)};var d=s.diff;s.diff=function(t,e,i){if(t&&this.$u===t.$u)return d.call(this,t,e,i);var a=this.local(),o=n(t).local();return d.call(a,o,e,i)}})}(v);var $=v.exports;r.default.extend(g),r.default.extend($);class O{apiKey;static baseUrl="https://public.api.nexon.com/";static kstOffset=540;timeout;constructor(t){this.apiKey=t,this.timeout=5e3}async getCubeResult(t,i){const a={count:t};if("string"==typeof i)a.cursor=i;else if("object"==typeof i){const{year:t,month:e,day:o}=i;if(t<=2022&&e<=11&&o<25)throw new Error("You can only retrieve data after 2022-11-25.");const n=r.default(`${t}-${e}-${o}`).utcOffset(O.kstOffset);a.date=n.format("YYYY-MM-DD")}else{const t=r.default().utcOffset(O.kstOffset);a.date=t.format("YYYY-MM-DD")}try{const t="openapi/maplestory/v1/cube-use-results",e=await s.default.get(t,{baseURL:O.baseUrl,timeout:this.timeout,headers:this.buildHeaders(),params:a});return new d(e.data)}catch(t){if(t instanceof e.AxiosError){const e=t.response.data;throw new h(e)}throw t}}async getInspectionInfo(){const t=(new u.default.Builder).buildObject({"soap:Envelope":{$:{"xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","xmlns:xsd":"http://www.w3.org/2001/XMLSchema","xmlns:soap":"http://schemas.xmlsoap.org/soap/envelope/"},"soap:Body":{GetInspectionInfo:{$:{xmlns:"https://api.maplestory.nexon.com/soap/"}}}}}),e=await s.default.post("soap/maplestory.asmx",t,{baseURL:"https://api.maplestory.nexon.com/",timeout:this.timeout,headers:{SOAPAction:"https://api.maplestory.nexon.com/soap/GetInspectionInfo","Content-Type":"text/xml; charset=utf-8"}}),i=await u.default.parseStringPromise(e.data);return new p(i)}buildHeaders(){return{authorization:this.apiKey}}}t.CubeHistoryDto=c,t.CubeHistoryResponseDto=d,t.CubeResultOptionDto=f,t.InspectionInfoDto=p,t.MapleStoryApi=O,t.MapleStoryApiError=h,t.potentialOptionGradeFromString=l}));
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import axios, { AxiosError } from 'axios';
|
|
2
2
|
import dayjs from 'dayjs';
|
|
3
|
+
import xml2js from 'xml2js';
|
|
3
4
|
|
|
4
5
|
var PotentialOptionGrade;
|
|
5
6
|
(function (PotentialOptionGrade) {
|
|
@@ -184,6 +185,35 @@ class CubeHistoryResponseDto {
|
|
|
184
185
|
}
|
|
185
186
|
}
|
|
186
187
|
|
|
188
|
+
/**
|
|
189
|
+
* 서버 점검 정보
|
|
190
|
+
*/
|
|
191
|
+
class InspectionInfoDto {
|
|
192
|
+
/**
|
|
193
|
+
* 서비스 코드
|
|
194
|
+
*/
|
|
195
|
+
serviceCode;
|
|
196
|
+
/**
|
|
197
|
+
* 점검 시작 시각
|
|
198
|
+
*/
|
|
199
|
+
startDateTime;
|
|
200
|
+
/**
|
|
201
|
+
* 점검 종료 시각
|
|
202
|
+
*/
|
|
203
|
+
endDateTime;
|
|
204
|
+
/**
|
|
205
|
+
* 점검 안내 제목
|
|
206
|
+
*/
|
|
207
|
+
strObstacleContents;
|
|
208
|
+
constructor(obj) {
|
|
209
|
+
const inspectionInfoTag = obj["soap:Envelope"]['soap:Body'][0]['GetInspectionInfoResponse'][0]['GetInspectionInfoResult'][0]['diffgr:diffgram'][0]['NewDataSet'][0]['InspectionInfo'][0];
|
|
210
|
+
this.serviceCode = Number(inspectionInfoTag.serviceCode[0]);
|
|
211
|
+
this.startDateTime = new Date(inspectionInfoTag.startDateTime[0]);
|
|
212
|
+
this.endDateTime = new Date(inspectionInfoTag.endDateTime[0]);
|
|
213
|
+
this.strObstacleContents = inspectionInfoTag.strObstacleContents[0];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
187
217
|
/**
|
|
188
218
|
* MapleStory OpenAPI error.<br>
|
|
189
219
|
* Please refer to <a href="https://developers.nexon.com/Maplestory/guides">MapleStory API guide</a> for the error details.
|
|
@@ -266,6 +296,42 @@ class MapleStoryApi {
|
|
|
266
296
|
throw e;
|
|
267
297
|
}
|
|
268
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* 서버 점검 정보를 조회합니다.
|
|
301
|
+
*/
|
|
302
|
+
async getInspectionInfo() {
|
|
303
|
+
const xmlBuilder = new xml2js.Builder();
|
|
304
|
+
const soapEnvelop = {
|
|
305
|
+
'soap:Envelope': {
|
|
306
|
+
$: {
|
|
307
|
+
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
|
308
|
+
'xmlns:xsd': 'http://www.w3.org/2001/XMLSchema',
|
|
309
|
+
'xmlns:soap': 'http://schemas.xmlsoap.org/soap/envelope/'
|
|
310
|
+
},
|
|
311
|
+
'soap:Body': {
|
|
312
|
+
'GetInspectionInfo': {
|
|
313
|
+
$: {
|
|
314
|
+
'xmlns': 'https://api.maplestory.nexon.com/soap/'
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
const baseUrl = 'https://api.maplestory.nexon.com/';
|
|
321
|
+
const path = 'soap/maplestory.asmx';
|
|
322
|
+
const headers = {
|
|
323
|
+
'SOAPAction': 'https://api.maplestory.nexon.com/soap/GetInspectionInfo',
|
|
324
|
+
'Content-Type': 'text/xml; charset=utf-8'
|
|
325
|
+
};
|
|
326
|
+
const body = xmlBuilder.buildObject(soapEnvelop);
|
|
327
|
+
const response = await axios.post(path, body, {
|
|
328
|
+
baseURL: baseUrl,
|
|
329
|
+
timeout: this.timeout,
|
|
330
|
+
headers,
|
|
331
|
+
});
|
|
332
|
+
const xml = await xml2js.parseStringPromise(response.data);
|
|
333
|
+
return new InspectionInfoDto(xml);
|
|
334
|
+
}
|
|
269
335
|
buildHeaders() {
|
|
270
336
|
return {
|
|
271
337
|
'authorization': this.apiKey
|
|
@@ -273,4 +339,4 @@ class MapleStoryApi {
|
|
|
273
339
|
}
|
|
274
340
|
}
|
|
275
341
|
|
|
276
|
-
export { CubeHistoryDto, CubeHistoryResponseDto, CubeResultOptionDto, MapleStoryApi, MapleStoryApiError, PotentialOptionGrade, potentialOptionGradeFromString };
|
|
342
|
+
export { CubeHistoryDto, CubeHistoryResponseDto, CubeResultOptionDto, InspectionInfoDto, MapleStoryApi, MapleStoryApiError, PotentialOptionGrade, potentialOptionGradeFromString };
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "maplestory-openapi",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "This JavaScript library enables the use of the MapleStory OpenAPI provided by Nexon.",
|
|
4
5
|
"keywords": [
|
|
5
6
|
"maplestory",
|
|
6
7
|
"maplestory openapi",
|
|
@@ -44,11 +45,13 @@
|
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|
|
46
47
|
"axios": "^1.6.0",
|
|
47
|
-
"dayjs": "^1.11.10"
|
|
48
|
+
"dayjs": "^1.11.10",
|
|
49
|
+
"xml2js": "^0.6.2"
|
|
48
50
|
},
|
|
49
51
|
"devDependencies": {
|
|
50
52
|
"@rollup/plugin-commonjs": "^21.1.0",
|
|
51
53
|
"@rollup/plugin-node-resolve": "13.1.3",
|
|
54
|
+
"@types/xml2js": "^0.4.14",
|
|
52
55
|
"rollup": "2.66.1",
|
|
53
56
|
"rollup-plugin-terser": "7.0.2",
|
|
54
57
|
"rollup-plugin-typescript2": "0.27.1",
|
package/types/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export * from './maplestory/api/mapleStoryApiError';
|
|
|
3
3
|
export * from './maplestory/api/dto/cubeHistoryDto';
|
|
4
4
|
export * from './maplestory/api/dto/cubeHistoryResponseDto';
|
|
5
5
|
export * from './maplestory/api/dto/cubeResultOptionDto';
|
|
6
|
+
export * from './maplestory/api/dto/inspectionInfoDto';
|
|
6
7
|
export * from './maplestory/api/dto/potentialOptionGrade';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { InspectionInfoSoapBody } from "../response/inspectionInfoSoapBody";
|
|
2
|
+
/**
|
|
3
|
+
* 서버 점검 정보
|
|
4
|
+
*/
|
|
5
|
+
declare class InspectionInfoDto {
|
|
6
|
+
/**
|
|
7
|
+
* 서비스 코드
|
|
8
|
+
*/
|
|
9
|
+
serviceCode: number;
|
|
10
|
+
/**
|
|
11
|
+
* 점검 시작 시각
|
|
12
|
+
*/
|
|
13
|
+
startDateTime: Date;
|
|
14
|
+
/**
|
|
15
|
+
* 점검 종료 시각
|
|
16
|
+
*/
|
|
17
|
+
endDateTime: Date;
|
|
18
|
+
/**
|
|
19
|
+
* 점검 안내 제목
|
|
20
|
+
*/
|
|
21
|
+
strObstacleContents: string;
|
|
22
|
+
constructor(obj: InspectionInfoSoapBody);
|
|
23
|
+
}
|
|
24
|
+
export { InspectionInfoDto };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CubeHistoryResponseDto } from "./dto/cubeHistoryResponseDto";
|
|
2
|
+
import { InspectionInfoDto } from "./dto/inspectionInfoDto";
|
|
2
3
|
declare class MapleStoryApi {
|
|
3
4
|
private readonly apiKey;
|
|
4
5
|
private static baseUrl;
|
|
@@ -7,14 +8,16 @@ declare class MapleStoryApi {
|
|
|
7
8
|
constructor(apiKey: string);
|
|
8
9
|
/**
|
|
9
10
|
* 오늘 날짜의 확률형 아이템 큐브의 사용 결과를 조회합니다.<br>
|
|
10
|
-
* 데이터는 일단위로 갱신되며, 오전 4시 조회 시 전일 데이터를 조회할 수
|
|
11
|
+
* 데이터는 일단위로 갱신되며, 오전 4시 조회 시 전일 데이터를 조회할 수 있습니다.<br>
|
|
12
|
+
* 데이터는 2022년 11월 25일부터 조회할 수 있습니다.<br>
|
|
11
13
|
*
|
|
12
14
|
* @param count 한번에 가져오려는 결과의 갯수(최소 10, 최대 1000) Default value : 10
|
|
13
15
|
*/
|
|
14
16
|
getCubeResult(count: number): Promise<CubeHistoryResponseDto>;
|
|
15
17
|
/**
|
|
16
18
|
* 지목한 날짜의 확률형 아이템 큐브의 사용 결과를 조회합니다.<br>
|
|
17
|
-
* 데이터는 일단위로 갱신되며, 오전 4시 조회 시 전일 데이터를 조회할 수
|
|
19
|
+
* 데이터는 일단위로 갱신되며, 오전 4시 조회 시 전일 데이터를 조회할 수 있습니다.<br>
|
|
20
|
+
* 데이터는 2022년 11월 25일부터 조회할 수 있습니다.<br>
|
|
18
21
|
*
|
|
19
22
|
* @param count 한번에 가져오려는 결과의 갯수(최소 10, 최대 1000) Default value : 10
|
|
20
23
|
* @param dateOptions 조회할 연월일 날짜 정보
|
|
@@ -22,12 +25,17 @@ declare class MapleStoryApi {
|
|
|
22
25
|
getCubeResult(count: number, dateOptions: DateOptions): Promise<CubeHistoryResponseDto>;
|
|
23
26
|
/**
|
|
24
27
|
* 확률형 아이템 큐브의 사용 결과를 조회합니다.<br>
|
|
25
|
-
* 데이터는 일단위로 갱신되며, 오전 4시 조회 시 전일 데이터를 조회할 수
|
|
28
|
+
* 데이터는 일단위로 갱신되며, 오전 4시 조회 시 전일 데이터를 조회할 수 있습니다.<br>
|
|
29
|
+
* 데이터는 2022년 11월 25일부터 조회할 수 있습니다.<br>
|
|
26
30
|
*
|
|
27
31
|
* @param count 한번에 가져오려는 결과의 갯수(최소 10, 최대 1000) Default value : 10
|
|
28
32
|
* @param cursor
|
|
29
33
|
*/
|
|
30
34
|
getCubeResult(count: number, cursor: string): Promise<CubeHistoryResponseDto>;
|
|
35
|
+
/**
|
|
36
|
+
* 서버 점검 정보를 조회합니다.
|
|
37
|
+
*/
|
|
38
|
+
getInspectionInfo(): Promise<InspectionInfoDto>;
|
|
31
39
|
private buildHeaders;
|
|
32
40
|
}
|
|
33
41
|
type DateOptions = {
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
type InspectionInfoSoapBody = {
|
|
2
|
+
'soap:Envelope': {
|
|
3
|
+
"$": {
|
|
4
|
+
"xmlns:soap": "http://schemas.xmlsoap.org/soap/envelope/";
|
|
5
|
+
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance";
|
|
6
|
+
"xmlns:xsd": "http://www.w3.org/2001/XMLSchema";
|
|
7
|
+
};
|
|
8
|
+
"soap:Body": [
|
|
9
|
+
{
|
|
10
|
+
"GetInspectionInfoResponse": [
|
|
11
|
+
{
|
|
12
|
+
"$": {
|
|
13
|
+
"xmlns": "https://api.maplestory.nexon.com/soap/";
|
|
14
|
+
};
|
|
15
|
+
"GetInspectionInfoResult": [
|
|
16
|
+
{
|
|
17
|
+
"xs:schema": [
|
|
18
|
+
{
|
|
19
|
+
"$": {
|
|
20
|
+
"id": "NewDataSet";
|
|
21
|
+
"xmlns": "";
|
|
22
|
+
"xmlns:xs": "http://www.w3.org/2001/XMLSchema";
|
|
23
|
+
"xmlns:msdata": "urn:schemas-microsoft-com:xml-msdata";
|
|
24
|
+
};
|
|
25
|
+
"xs:element": [
|
|
26
|
+
{
|
|
27
|
+
"$": {
|
|
28
|
+
"name": "NewDataSet";
|
|
29
|
+
"msdata:IsDataSet": "true";
|
|
30
|
+
"msdata:UseCurrentLocale": "true";
|
|
31
|
+
};
|
|
32
|
+
"xs:complexType": [
|
|
33
|
+
{
|
|
34
|
+
"xs:choice": [
|
|
35
|
+
{
|
|
36
|
+
"$": {
|
|
37
|
+
"minOccurs": "0";
|
|
38
|
+
"maxOccurs": "unbounded";
|
|
39
|
+
};
|
|
40
|
+
"xs:element": [
|
|
41
|
+
{
|
|
42
|
+
"$": {
|
|
43
|
+
"name": "InspectionInfo";
|
|
44
|
+
};
|
|
45
|
+
"xs:complexType": [
|
|
46
|
+
{
|
|
47
|
+
"xs:sequence": [
|
|
48
|
+
{
|
|
49
|
+
"xs:element": [
|
|
50
|
+
{
|
|
51
|
+
"$": {
|
|
52
|
+
"name": "serviceCode";
|
|
53
|
+
"type": "xs:unsignedByte";
|
|
54
|
+
"minOccurs": "0";
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"$": {
|
|
59
|
+
"name": "startDateTime";
|
|
60
|
+
"type": "xs:dateTime";
|
|
61
|
+
"minOccurs": "0";
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"$": {
|
|
66
|
+
"name": "endDateTime";
|
|
67
|
+
"type": "xs:dateTime";
|
|
68
|
+
"minOccurs": "0";
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"$": {
|
|
73
|
+
"name": "strObstacleContents";
|
|
74
|
+
"type": "xs:string";
|
|
75
|
+
"minOccurs": "0";
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
];
|
|
93
|
+
"diffgr:diffgram": [
|
|
94
|
+
{
|
|
95
|
+
"$": {
|
|
96
|
+
"xmlns:msdata": "urn:schemas-microsoft-com:xml-msdata";
|
|
97
|
+
"xmlns:diffgr": "urn:schemas-microsoft-com:xml-diffgram-v1";
|
|
98
|
+
};
|
|
99
|
+
"NewDataSet": [
|
|
100
|
+
{
|
|
101
|
+
"$": {
|
|
102
|
+
"xmlns": "";
|
|
103
|
+
};
|
|
104
|
+
"InspectionInfo": [
|
|
105
|
+
{
|
|
106
|
+
"$": {
|
|
107
|
+
"diffgr:id": "InspectionInfo1";
|
|
108
|
+
"msdata:rowOrder": "0";
|
|
109
|
+
"diffgr:hasChanges": "inserted";
|
|
110
|
+
};
|
|
111
|
+
"serviceCode": [
|
|
112
|
+
string
|
|
113
|
+
];
|
|
114
|
+
"startDateTime": [
|
|
115
|
+
string
|
|
116
|
+
];
|
|
117
|
+
"endDateTime": [
|
|
118
|
+
string
|
|
119
|
+
];
|
|
120
|
+
"strObstacleContents": [
|
|
121
|
+
string
|
|
122
|
+
];
|
|
123
|
+
}
|
|
124
|
+
];
|
|
125
|
+
}
|
|
126
|
+
];
|
|
127
|
+
}
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
];
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
export type { InspectionInfoSoapBody };
|