@motionpicture/coa-service 9.3.0-alpha.3 → 9.3.0-alpha.4
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 +0 -5
- package/example/delReserve.js +10 -9
- package/example/findFilms.js +2 -1
- package/lib/auth/refreshTokenClient.d.ts +2 -2
- package/lib/auth/refreshTokenClient.js +3 -6
- package/lib/index.d.ts +3 -5
- package/lib/index.js +5 -6
- package/lib/service.d.ts +1 -1
- package/lib/transporter/coaServiceError.d.ts +10 -0
- package/lib/transporter/coaServiceError.js +16 -0
- package/lib/transporter/requestOption.d.ts +16 -0
- package/lib/transporter/requestOption.js +2 -0
- package/lib/transporters.d.ts +18 -14
- package/lib/transporters.js +42 -58
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,7 +17,6 @@ COA SDK for Node.js
|
|
|
17
17
|
- [Environment variables](#environment-variables)
|
|
18
18
|
- [劇場情報を取得する](#劇場情報を取得する)
|
|
19
19
|
- [Code Samples](#code-samples)
|
|
20
|
-
- [Documentation](#documentation)
|
|
21
20
|
|
|
22
21
|
## Specification
|
|
23
22
|
|
|
@@ -73,7 +72,3 @@ masterService.theater({
|
|
|
73
72
|
## Code Samples
|
|
74
73
|
|
|
75
74
|
Code sample are [here](https://github.com/motionpicture/coa-service/tree/master/example).
|
|
76
|
-
|
|
77
|
-
## Documentation
|
|
78
|
-
|
|
79
|
-
`npm run doc` emits typedoc to ./docs.
|
package/example/delReserve.js
CHANGED
|
@@ -14,25 +14,26 @@ const service = new COA.service.Reserve(
|
|
|
14
14
|
);
|
|
15
15
|
|
|
16
16
|
service.delReserve({
|
|
17
|
-
reserveNum: '
|
|
18
|
-
theaterCode: '
|
|
19
|
-
dateJouei:
|
|
20
|
-
titleCode:
|
|
21
|
-
titleBranchNum:
|
|
22
|
-
timeBegin:
|
|
23
|
-
telNum: '
|
|
17
|
+
reserveNum: '45701',
|
|
18
|
+
theaterCode: '120',
|
|
19
|
+
"dateJouei": "20240125",
|
|
20
|
+
"titleCode": "99100",
|
|
21
|
+
"titleBranchNum": "0",
|
|
22
|
+
"timeBegin": "1720",
|
|
23
|
+
telNum: '09096793896',
|
|
24
24
|
listSeat: [
|
|
25
25
|
{
|
|
26
26
|
seatSection: '0',
|
|
27
|
-
seatNum:
|
|
27
|
+
"seatNum": "b-18",
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
seatSection: '0',
|
|
31
|
-
seatNum:
|
|
31
|
+
"seatNum": "b-19",
|
|
32
32
|
}
|
|
33
33
|
]
|
|
34
34
|
}).then((result) => {
|
|
35
35
|
console.log(result);
|
|
36
36
|
}).catch((err) => {
|
|
37
37
|
console.error(err);
|
|
38
|
+
console.log('err instanceof COA.COAServiceError?:', err instanceof COA.COAServiceError);
|
|
38
39
|
});
|
package/example/findFilms.js
CHANGED
|
@@ -10,7 +10,8 @@ const service = new COA.service.Master(
|
|
|
10
10
|
endpoint: process.env.COA_ENDPOINT,
|
|
11
11
|
auth: new COA.auth.RefreshToken({
|
|
12
12
|
endpoint: process.env.COA_ENDPOINT,
|
|
13
|
-
refreshToken: process.env.COA_REFRESH_TOKEN
|
|
13
|
+
refreshToken: process.env.COA_REFRESH_TOKEN,
|
|
14
|
+
useFetch: true
|
|
14
15
|
})
|
|
15
16
|
},
|
|
16
17
|
{ timeout: 1000 }
|
|
@@ -42,11 +42,11 @@ export declare class RefreshTokenClient {
|
|
|
42
42
|
* APIリクエストを投げる
|
|
43
43
|
* 認証エラー(401,403)であれば自動的に一度だけアクセストークンをリフレッシュします。
|
|
44
44
|
*/
|
|
45
|
-
request(options: IRequestOptions, expectedStatusCodes: number[]): Promise<
|
|
45
|
+
request(options: IRequestOptions, expectedStatusCodes: number[]): Promise<import("../transporters").IResponseBodyAsJson>;
|
|
46
46
|
/**
|
|
47
47
|
* 認証情報が適切である前提でAPIリクエストを投げる
|
|
48
48
|
*/
|
|
49
|
-
protected makeRequest(options: IRequestOptions, expectedStatusCodes: number[]): Promise<
|
|
49
|
+
protected makeRequest(options: IRequestOptions, expectedStatusCodes: number[]): Promise<import("../transporters").IResponseBodyAsJson>;
|
|
50
50
|
/**
|
|
51
51
|
* 認証情報を更新する
|
|
52
52
|
*/
|
|
@@ -17,6 +17,7 @@ const request = require("request");
|
|
|
17
17
|
const transporters_1 = require("../transporters");
|
|
18
18
|
const debug = createDebug('coa-service:auth:refreshTokenClient');
|
|
19
19
|
const TIMEOUT = 10000;
|
|
20
|
+
const MAX_NUM_TRY_REQUEST = 1;
|
|
20
21
|
/**
|
|
21
22
|
* リフレッシュトークン認証クライアント
|
|
22
23
|
*/
|
|
@@ -193,11 +194,10 @@ class RefreshTokenClient {
|
|
|
193
194
|
let retry = true;
|
|
194
195
|
let result;
|
|
195
196
|
let numberOfTry = 0;
|
|
196
|
-
|
|
197
|
-
while (numberOfTry >= 0) {
|
|
197
|
+
while (result === undefined) {
|
|
198
198
|
try {
|
|
199
199
|
numberOfTry += 1;
|
|
200
|
-
if (numberOfTry >
|
|
200
|
+
if (numberOfTry > MAX_NUM_TRY_REQUEST) {
|
|
201
201
|
retry = false;
|
|
202
202
|
}
|
|
203
203
|
options.auth = { bearer: yield this.getAccessToken() };
|
|
@@ -225,9 +225,6 @@ class RefreshTokenClient {
|
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
-
else {
|
|
229
|
-
// no operation
|
|
230
|
-
}
|
|
231
228
|
throw error;
|
|
232
229
|
}
|
|
233
230
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
* coa-service
|
|
3
3
|
*/
|
|
4
4
|
import * as factory from './factory';
|
|
5
|
+
import { RefreshTokenClient } from './auth/refreshTokenClient';
|
|
5
6
|
import { MasterService } from './service/master';
|
|
6
7
|
import { ReserveService } from './service/reserve';
|
|
7
|
-
import {
|
|
8
|
-
export
|
|
8
|
+
import { COAServiceError } from './transporter/coaServiceError';
|
|
9
|
+
export { COAServiceError, factory };
|
|
9
10
|
export declare namespace auth {
|
|
10
11
|
/**
|
|
11
12
|
* リフレッシュトークン認証クライアント
|
|
@@ -13,9 +14,6 @@ export declare namespace auth {
|
|
|
13
14
|
class RefreshToken extends RefreshTokenClient {
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
|
-
/**
|
|
17
|
-
* recommended
|
|
18
|
-
*/
|
|
19
17
|
export declare namespace service {
|
|
20
18
|
/**
|
|
21
19
|
* マスターサービス
|
package/lib/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.service = exports.auth = exports.factory = void 0;
|
|
3
|
+
exports.service = exports.auth = exports.factory = exports.COAServiceError = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* coa-service
|
|
6
6
|
*/
|
|
7
7
|
const factory = require("./factory");
|
|
8
|
+
exports.factory = factory;
|
|
9
|
+
const refreshTokenClient_1 = require("./auth/refreshTokenClient");
|
|
8
10
|
const master_1 = require("./service/master");
|
|
9
11
|
const reserve_1 = require("./service/reserve");
|
|
10
|
-
const
|
|
11
|
-
exports.
|
|
12
|
+
const coaServiceError_1 = require("./transporter/coaServiceError");
|
|
13
|
+
Object.defineProperty(exports, "COAServiceError", { enumerable: true, get: function () { return coaServiceError_1.COAServiceError; } });
|
|
12
14
|
var auth;
|
|
13
15
|
(function (auth) {
|
|
14
16
|
/**
|
|
@@ -18,9 +20,6 @@ var auth;
|
|
|
18
20
|
}
|
|
19
21
|
auth.RefreshToken = RefreshToken;
|
|
20
22
|
})(auth = exports.auth || (exports.auth = {}));
|
|
21
|
-
/**
|
|
22
|
-
* recommended
|
|
23
|
-
*/
|
|
24
23
|
var service;
|
|
25
24
|
(function (service) {
|
|
26
25
|
/**
|
package/lib/service.d.ts
CHANGED
|
@@ -18,5 +18,5 @@ export declare class Service {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create and send request to API
|
|
20
20
|
*/
|
|
21
|
-
request(options: IRequestOptions, expectedStatusCodes: number[]): Promise<
|
|
21
|
+
request(options: IRequestOptions, expectedStatusCodes: number[]): Promise<import("./transporters").IResponseBodyAsJson>;
|
|
22
22
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IRequestOptions } from './requestOption';
|
|
2
|
+
/**
|
|
3
|
+
* COAServiceError
|
|
4
|
+
*/
|
|
5
|
+
export declare class COAServiceError extends Error {
|
|
6
|
+
code: number;
|
|
7
|
+
status: string;
|
|
8
|
+
requestOptions: IRequestOptions | undefined;
|
|
9
|
+
constructor(code: number, status: string, message?: string, requestOptions?: IRequestOptions);
|
|
10
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.COAServiceError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* COAServiceError
|
|
6
|
+
*/
|
|
7
|
+
class COAServiceError extends Error {
|
|
8
|
+
constructor(code, status, message, requestOptions) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = 'COAServiceError';
|
|
11
|
+
this.code = code;
|
|
12
|
+
this.status = status;
|
|
13
|
+
this.requestOptions = requestOptions;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.COAServiceError = COAServiceError;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface IHeaders {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
}
|
|
4
|
+
type IQS = Record<string, string | number | any[]>;
|
|
5
|
+
export interface IRequestOptions {
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
auth?: {
|
|
8
|
+
bearer?: string;
|
|
9
|
+
};
|
|
10
|
+
qs?: IQS;
|
|
11
|
+
method?: string;
|
|
12
|
+
headers?: IHeaders;
|
|
13
|
+
timeout?: number;
|
|
14
|
+
uri: string;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
package/lib/transporters.d.ts
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
import * as request from 'request';
|
|
2
|
+
import { COAServiceError } from './transporter/coaServiceError';
|
|
3
|
+
import { IRequestOptions } from './transporter/requestOption';
|
|
2
4
|
/**
|
|
3
5
|
* リクエスト成功の場合のレスポンス本文のstatus属性の値
|
|
4
6
|
* 失敗の場合はstring型だが、成功の場合のみnumber型が返却されるので注意すること。
|
|
5
7
|
*/
|
|
6
8
|
export declare const RESPONSE_BODY_STAUS_SUCCESS = 0;
|
|
7
|
-
export
|
|
9
|
+
export { COAServiceError, IRequestOptions };
|
|
10
|
+
export type IResponseBodyAsJson = {
|
|
11
|
+
/**
|
|
12
|
+
* COAの提示するステータス
|
|
13
|
+
* 0でなければBadRequest
|
|
14
|
+
*/
|
|
15
|
+
status?: string | number;
|
|
16
|
+
/**
|
|
17
|
+
* COAの提示するメッセージ
|
|
18
|
+
*/
|
|
19
|
+
message?: string;
|
|
20
|
+
} & Record<string, any>;
|
|
21
|
+
export type IResponseBody = IResponseBodyAsJson;
|
|
8
22
|
/**
|
|
9
23
|
* transporter abstract class
|
|
10
24
|
* トランスポーター抽象クラス
|
|
11
25
|
*/
|
|
12
26
|
export declare abstract class Transporter {
|
|
13
|
-
abstract request(options: IRequestOptions): Promise<
|
|
14
|
-
}
|
|
15
|
-
export type IBodyResponseCallback = Promise<any>;
|
|
16
|
-
/**
|
|
17
|
-
* COAServiceError
|
|
18
|
-
*/
|
|
19
|
-
export declare class COAServiceError extends Error {
|
|
20
|
-
code: number;
|
|
21
|
-
status: string;
|
|
22
|
-
requestOptions: IRequestOptions | undefined;
|
|
23
|
-
constructor(code: number, status: string, message?: string, requestOptions?: IRequestOptions);
|
|
27
|
+
abstract request(options: IRequestOptions): Promise<IResponseBody>;
|
|
24
28
|
}
|
|
25
29
|
/**
|
|
26
30
|
* DefaultTransporter
|
|
@@ -39,7 +43,7 @@ export declare class DefaultTransporter implements Transporter {
|
|
|
39
43
|
/**
|
|
40
44
|
* Makes a request with given options and invokes callback.
|
|
41
45
|
*/
|
|
42
|
-
request(options: IRequestOptions): Promise<
|
|
46
|
+
request(options: IRequestOptions): Promise<IResponseBody>;
|
|
43
47
|
/**
|
|
44
48
|
* Wraps the response callback.
|
|
45
49
|
*/
|
|
@@ -62,7 +66,7 @@ export declare class FetchTransporter implements Transporter {
|
|
|
62
66
|
/**
|
|
63
67
|
* Makes a request with given options and invokes callback.
|
|
64
68
|
*/
|
|
65
|
-
request(options: IRequestOptions): Promise<
|
|
69
|
+
request(options: IRequestOptions): Promise<IResponseBody>;
|
|
66
70
|
/**
|
|
67
71
|
* Wraps the response callback.
|
|
68
72
|
*/
|
package/lib/transporters.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.FetchTransporter = exports.DefaultTransporter = exports.
|
|
12
|
+
exports.FetchTransporter = exports.DefaultTransporter = exports.Transporter = exports.COAServiceError = exports.RESPONSE_BODY_STAUS_SUCCESS = void 0;
|
|
13
13
|
// tslint:disable:max-classes-per-file
|
|
14
14
|
/**
|
|
15
15
|
* transporters
|
|
@@ -19,6 +19,8 @@ const http_status_1 = require("http-status");
|
|
|
19
19
|
const node_fetch_1 = require("node-fetch");
|
|
20
20
|
const querystring = require("querystring");
|
|
21
21
|
const request = require("request");
|
|
22
|
+
const coaServiceError_1 = require("./transporter/coaServiceError");
|
|
23
|
+
Object.defineProperty(exports, "COAServiceError", { enumerable: true, get: function () { return coaServiceError_1.COAServiceError; } });
|
|
22
24
|
const debug = createDebug('coa-service:transporters');
|
|
23
25
|
// tslint:disable-next-line
|
|
24
26
|
const pkg = require('../package.json');
|
|
@@ -34,19 +36,7 @@ exports.RESPONSE_BODY_STAUS_SUCCESS = 0;
|
|
|
34
36
|
class Transporter {
|
|
35
37
|
}
|
|
36
38
|
exports.Transporter = Transporter;
|
|
37
|
-
|
|
38
|
-
* COAServiceError
|
|
39
|
-
*/
|
|
40
|
-
class COAServiceError extends Error {
|
|
41
|
-
constructor(code, status, message, requestOptions) {
|
|
42
|
-
super(message);
|
|
43
|
-
this.name = 'COAServiceError';
|
|
44
|
-
this.code = code;
|
|
45
|
-
this.status = status;
|
|
46
|
-
this.requestOptions = requestOptions;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.COAServiceError = COAServiceError;
|
|
39
|
+
// export type IBodyResponseCallback = Promise<any>;
|
|
50
40
|
/**
|
|
51
41
|
* DefaultTransporter
|
|
52
42
|
*/
|
|
@@ -97,9 +87,9 @@ class DefaultTransporter {
|
|
|
97
87
|
*/
|
|
98
88
|
wrapCallback(error, response, body, options) {
|
|
99
89
|
const requestOptions = { uri: options.uri };
|
|
100
|
-
let err = new COAServiceError(http_status_1.INTERNAL_SERVER_ERROR, '', 'An unexpected error occurred.', requestOptions);
|
|
90
|
+
let err = new coaServiceError_1.COAServiceError(http_status_1.INTERNAL_SERVER_ERROR, '', 'An unexpected error occurred.', requestOptions);
|
|
101
91
|
if (error instanceof Error) {
|
|
102
|
-
throw new COAServiceError(http_status_1.INTERNAL_SERVER_ERROR, '', error.message, requestOptions);
|
|
92
|
+
throw new coaServiceError_1.COAServiceError(http_status_1.INTERNAL_SERVER_ERROR, '', error.message, requestOptions);
|
|
103
93
|
}
|
|
104
94
|
debug('request processed', error, body, response.statusCode);
|
|
105
95
|
const statusFromBody = body === null || body === void 0 ? void 0 : body.status;
|
|
@@ -109,14 +99,14 @@ class DefaultTransporter {
|
|
|
109
99
|
if (this.expectedStatusCodes.indexOf(response.statusCode) < 0) {
|
|
110
100
|
if (typeof body === 'string') {
|
|
111
101
|
// Consider all 4xx and 5xx responses errors.
|
|
112
|
-
err = new COAServiceError(response.statusCode, '', body, requestOptions);
|
|
102
|
+
err = new coaServiceError_1.COAServiceError(response.statusCode, '', body, requestOptions);
|
|
113
103
|
}
|
|
114
104
|
else {
|
|
115
105
|
// エラーレスポンスにステータスがあった場合
|
|
116
106
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
117
107
|
/* istanbul ignore else */
|
|
118
108
|
if (statusFromBody !== undefined) {
|
|
119
|
-
err = new COAServiceError(response.statusCode, statusFromBody, body.message, requestOptions);
|
|
109
|
+
err = new coaServiceError_1.COAServiceError(response.statusCode, statusFromBody, body.message, requestOptions);
|
|
120
110
|
}
|
|
121
111
|
else {
|
|
122
112
|
// no operation
|
|
@@ -126,17 +116,17 @@ class DefaultTransporter {
|
|
|
126
116
|
else {
|
|
127
117
|
// HTTPステータスコード2xxでも、レスポンス本文のステータスが0でなければBadRequest
|
|
128
118
|
if (statusFromBody !== undefined && statusFromBody !== exports.RESPONSE_BODY_STAUS_SUCCESS) {
|
|
129
|
-
err = new COAServiceError(response.statusCode, statusFromBody, body.message, requestOptions);
|
|
119
|
+
err = new coaServiceError_1.COAServiceError(response.statusCode, statusFromBody, body.message, requestOptions);
|
|
130
120
|
}
|
|
131
121
|
else {
|
|
132
|
-
if (response.statusCode ===
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
122
|
+
// if (response.statusCode === NO_CONTENT) {
|
|
123
|
+
// // consider 204
|
|
124
|
+
// return;
|
|
125
|
+
// } else {
|
|
126
|
+
// // consider 200,201
|
|
127
|
+
// return body;
|
|
128
|
+
// }
|
|
129
|
+
return body;
|
|
140
130
|
}
|
|
141
131
|
}
|
|
142
132
|
}
|
|
@@ -167,10 +157,10 @@ class FetchTransporter {
|
|
|
167
157
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
168
158
|
/* istanbul ignore else */
|
|
169
159
|
if (!options.headers['User-Agent']) {
|
|
170
|
-
options.headers['User-Agent'] =
|
|
160
|
+
options.headers['User-Agent'] = FetchTransporter.USER_AGENT;
|
|
171
161
|
}
|
|
172
|
-
else if (options.headers['User-Agent'].indexOf(
|
|
173
|
-
options.headers['User-Agent'] = `${options.headers['User-Agent']} ${
|
|
162
|
+
else if (options.headers['User-Agent'].indexOf(FetchTransporter.USER_AGENT) === -1) {
|
|
163
|
+
options.headers['User-Agent'] = `${options.headers['User-Agent']} ${FetchTransporter.USER_AGENT}`;
|
|
174
164
|
}
|
|
175
165
|
else {
|
|
176
166
|
// no operation
|
|
@@ -197,7 +187,7 @@ class FetchTransporter {
|
|
|
197
187
|
wrapCallback(res, options) {
|
|
198
188
|
return __awaiter(this, void 0, void 0, function* () {
|
|
199
189
|
const requestOptions = { uri: options.uri };
|
|
200
|
-
let err = new COAServiceError(http_status_1.INTERNAL_SERVER_ERROR, '', 'An unexpected error occurred.', requestOptions);
|
|
190
|
+
let err = new coaServiceError_1.COAServiceError(http_status_1.INTERNAL_SERVER_ERROR, '', 'An unexpected error occurred.', requestOptions);
|
|
201
191
|
debug('fetch processed. res.status:', res.status, 'content-type:', res.headers.get('content-type'));
|
|
202
192
|
let body = {};
|
|
203
193
|
try {
|
|
@@ -207,50 +197,44 @@ class FetchTransporter {
|
|
|
207
197
|
else {
|
|
208
198
|
body = yield res.json();
|
|
209
199
|
}
|
|
200
|
+
debug('fetch processed. body:', body);
|
|
210
201
|
}
|
|
211
202
|
catch (error) {
|
|
212
203
|
// no op
|
|
213
204
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
205
|
+
if (typeof body === 'string') {
|
|
206
|
+
// Consider all 4xx and 5xx responses errors.
|
|
207
|
+
err = new coaServiceError_1.COAServiceError(res.status, '', body, requestOptions);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
217
210
|
if (this.expectedStatusCodes.indexOf(res.status) < 0) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
211
|
+
// エラーレスポンスにステータスがあった場合
|
|
212
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
213
|
+
/* istanbul ignore else */
|
|
214
|
+
if (body.status !== undefined) {
|
|
215
|
+
err = new coaServiceError_1.COAServiceError(res.status, String(body.status), body.message, requestOptions);
|
|
221
216
|
}
|
|
222
217
|
else {
|
|
223
|
-
//
|
|
224
|
-
// tslint:disable-next-line:no-single-line-block-comment
|
|
225
|
-
/* istanbul ignore else */
|
|
226
|
-
if (body.status !== undefined) {
|
|
227
|
-
err = new COAServiceError(res.status, body.status, body.message, requestOptions);
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
// no operation
|
|
231
|
-
}
|
|
218
|
+
// no operation
|
|
232
219
|
}
|
|
233
220
|
}
|
|
234
221
|
else {
|
|
235
222
|
// HTTPステータスコード2xxでも、レスポンス本文のステータスが0でなければBadRequest
|
|
236
223
|
if (body.status !== undefined && body.status !== exports.RESPONSE_BODY_STAUS_SUCCESS) {
|
|
237
|
-
err = new COAServiceError(res.status, body.status, body.message, requestOptions);
|
|
224
|
+
err = new coaServiceError_1.COAServiceError(res.status, String(body.status), body.message, requestOptions);
|
|
238
225
|
}
|
|
239
226
|
else {
|
|
240
|
-
if (res.status ===
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
227
|
+
// if (res.status === NO_CONTENT) {
|
|
228
|
+
// // consider 204
|
|
229
|
+
// return;
|
|
230
|
+
// } else {
|
|
231
|
+
// // consider 200,201
|
|
232
|
+
// return body;
|
|
233
|
+
// }
|
|
234
|
+
return body;
|
|
248
235
|
}
|
|
249
236
|
}
|
|
250
237
|
}
|
|
251
|
-
else {
|
|
252
|
-
// no operation
|
|
253
|
-
}
|
|
254
238
|
throw err;
|
|
255
239
|
});
|
|
256
240
|
}
|
package/package.json
CHANGED