@cinerino/sdk 8.0.0-alpha.3 → 8.0.0-alpha.5

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 (31) hide show
  1. package/example/src/{transaction → cloud/transaction}/paymentAsyncForce.ts +2 -2
  2. package/example/src/cloud/transaction/processPlaceOrderByCreditCard3DS.ts +9 -4
  3. package/example/src/{transaction → cloud/transaction}/processPlaceOrderCOAEventByCreditCard.ts +6 -5
  4. package/example/src/{transaction → cloud/transaction}/processPlaceOrderCOAEventByMovieTicket.ts +6 -5
  5. package/example/src/{transaction → cloud/transaction}/processReturnOrder.ts +6 -5
  6. package/example/src/{transaction → cloud/transaction}/test/lockTransactionTest.ts +6 -5
  7. package/example/src/{transaction → cloud/transaction}/test/rateLimitTest.ts +6 -5
  8. package/lib/abstract/chevreTxn.d.ts +3 -3
  9. package/lib/abstract/chevreTxn.js +9 -4
  10. package/lib/abstract/cinerino/default.d.ts +0 -18
  11. package/lib/abstract/cinerino/default.js +0 -36
  12. package/lib/abstract/cinerino/service/transaction/placeOrder4sskts.d.ts +3 -3
  13. package/lib/abstract/cinerino/service/transaction/placeOrder4sskts.js +6 -3
  14. package/lib/abstract/cloud/admin.js +14 -14
  15. package/lib/abstract/cloud/pay.js +2 -2
  16. package/lib/abstract/cloud/txn/offer.d.ts +1 -2
  17. package/lib/abstract/cloud/txn/offer.js +15 -8
  18. package/lib/abstract/cloud/txn/transaction/placeOrder.d.ts +1 -2
  19. package/lib/abstract/cloud/txn/transaction/placeOrder.js +33 -23
  20. package/lib/abstract/cloud/txn/transaction/returnOrder.d.ts +1 -2
  21. package/lib/abstract/cloud/txn/transaction/returnOrder.js +9 -2
  22. package/lib/abstract/cloud/txn.js +4 -4
  23. package/lib/bundle.js +464 -960
  24. package/package.json +4 -4
  25. package/example/src/transaction/processPlaceOrderByCreditCard3DS.ts +0 -460
  26. package/lib/abstract/cinerino/service/offer.d.ts +0 -41
  27. package/lib/abstract/cinerino/service/offer.js +0 -136
  28. package/lib/abstract/cinerino/service/transaction/placeOrder.d.ts +0 -61
  29. package/lib/abstract/cinerino/service/transaction/placeOrder.js +0 -209
  30. package/lib/abstract/cinerino/service/transaction/returnOrder.d.ts +0 -22
  31. package/lib/abstract/cinerino/service/transaction/returnOrder.js +0 -141
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cinerino/sdk",
3
- "version": "8.0.0-alpha.3",
3
+ "version": "8.0.0-alpha.5",
4
4
  "description": "Cinerino SDK",
5
5
  "main": "./lib/index.js",
6
6
  "browser": {
@@ -60,7 +60,7 @@
60
60
  "@types/debug": "0.0.30",
61
61
  "@types/fetch-mock": "^6.0.6",
62
62
  "@types/form-data": "^2.5.0",
63
- "@types/http-status": "^0.2.30",
63
+ "@types/http-status": "1.1.2",
64
64
  "@types/isomorphic-fetch": "0.0.34",
65
65
  "@types/jwt-decode": "^2.2.1",
66
66
  "@types/mocha": "^5.2.7",
@@ -92,9 +92,9 @@
92
92
  "watchify": "^3.11.1"
93
93
  },
94
94
  "dependencies": {
95
- "@chevre/factory": "4.376.0-alpha.1",
95
+ "@chevre/factory": "4.376.0-alpha.2",
96
96
  "debug": "^3.2.6",
97
- "http-status": "^1.4.2",
97
+ "http-status": "1.7.4",
98
98
  "idtoken-verifier": "^2.0.3",
99
99
  "isomorphic-fetch": "^2.2.1",
100
100
  "qs": "6.11.0"
@@ -1,460 +0,0 @@
1
- // tslint:disable:no-console no-implicit-dependencies no-magic-numbers
2
- import * as moment from 'moment';
3
- import * as readline from 'readline';
4
- import * as client from '../../../lib/index';
5
- import { auth } from '../auth/clientCredentials';
6
-
7
- const project = { id: String(process.env.PROJECT_ID) };
8
- const profile = {
9
- email: <string>process.env.TEST_PROFILE_EMAIL,
10
- givenName: 'Taro',
11
- familyName: 'SDK',
12
- name: 'Taro ☆ SDK',
13
- telephone: '+819012345678'
14
- };
15
- const paymentMethodType = 'CreditCard3DS';
16
- const paymentServiceId = '664d98376fb87922bd6a4e52';
17
- // 取引に使用するクレジットカード
18
- const creditCard: client.factory.paymentMethod.paymentCard.creditCard.IUncheckedCardRaw = {
19
- cardNo: '4100000000000100',
20
- expire: '2812',
21
- cardPass: '123',
22
- holderName: 'AA AA'
23
- };
24
-
25
- // tslint:disable-next-line:max-func-body-length
26
- async function main() {
27
- const eventService = new (await client.loadService()).Event({
28
- endpoint: <string>process.env.API_ENDPOINT,
29
- auth: await auth(),
30
- project,
31
- seller: { id: '' }
32
- });
33
-
34
- const sellerService = new (await client.loadService()).Seller({
35
- endpoint: <string>process.env.API_ENDPOINT,
36
- auth: await auth(),
37
- project
38
- });
39
-
40
- const placeOrderService = new (await client.loadService()).txn.PlaceOrder({
41
- endpoint: <string>process.env.API_ENDPOINT,
42
- auth: await auth(),
43
- project,
44
- seller: { id: '' }
45
- });
46
-
47
- // 新しい決済サービス
48
- const paymentService = await (await client.loadCloudPay({
49
- endpoint: <string>process.env.API_PAY_ENDPOINT,
50
- auth: await auth()
51
- })).createPaymentInstance({
52
- project,
53
- seller: { id: '' }
54
- });
55
-
56
- // 販売劇場検索
57
- const searchSellersResult = await sellerService.search({ branchCode: { $eq: '001' } });
58
- // tslint:disable-next-line:insecure-random
59
- const seller = searchSellersResult.data[Math.floor(searchSellersResult.data.length * Math.random())];
60
- if (seller === undefined) {
61
- throw new Error('No seller');
62
- }
63
- console.log('ordering from seller...', (<client.factory.multilingualString>seller.name).ja);
64
-
65
- // イベント検索
66
- const searchScreeningEventsResult = await eventService.search<client.factory.eventType.ScreeningEvent>({
67
- typeOf: client.factory.eventType.ScreeningEvent,
68
- inSessionFrom: moment()
69
- .toDate(),
70
- inSessionThrough: moment()
71
- .add(1, 'week')
72
- .toDate()
73
- });
74
- console.log(searchScreeningEventsResult.data.length, 'events found');
75
-
76
- const availableEvents = searchScreeningEventsResult.data;
77
- if (availableEvents.length === 0) {
78
- throw new Error('No available events');
79
- }
80
-
81
- console.log('starting transaction...');
82
- const transaction = await placeOrderService.start({
83
- agent: {},
84
- seller: { id: String(seller.id) },
85
- object: {
86
- // passport: { token: passportToken }
87
- }
88
- });
89
- console.log('transaction started', transaction.id);
90
-
91
- try {
92
- const numEvents = 1;
93
- let amount = 0;
94
- // tslint:disable-next-line:max-line-length
95
- const authorizeSeatReservationResults: { price: number }[] = [];
96
-
97
- // tslint:disable-next-line:no-increment-decrement
98
- for (let i = 0; i < numEvents; i++) {
99
- // イベント決定
100
- // tslint:disable-next-line:insecure-random
101
- const screeningEvent = availableEvents[Math.floor(availableEvents.length * Math.random())];
102
- const authorizeSeatReservationResult = await authorizeSeatReservationByEvent({
103
- event: screeningEvent,
104
- transaction: transaction
105
- });
106
- amount += Number(authorizeSeatReservationResult.price);
107
- authorizeSeatReservationResults.push(authorizeSeatReservationResult);
108
- }
109
-
110
- // 決済URL発行
111
- const { paymentMethodId, paymentUrl } = await publishPaymentUrlAsyncForcibly({
112
- object: {
113
- amount,
114
- paymentMethod: paymentMethodType,
115
- method: '1',
116
- creditCard: {
117
- ...creditCard,
118
- retUrl: String(process.env.SECURE_TRAN_RET_URL) // callbackを指定すると3DSとして処理される
119
- },
120
- issuedThrough: { id: paymentServiceId }
121
- },
122
- purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
123
- })({ paymentService });
124
- console.log('paymentUrl published.', paymentMethodId, paymentUrl);
125
-
126
- // wait callback...
127
- await new Promise<void>((resolve, reject) => {
128
- const rl = readline.createInterface({
129
- input: process.stdin,
130
- output: process.stdout
131
- });
132
-
133
- rl.question('callback received?:\n', async () => {
134
- try {
135
- console.log('authorizing credit card payment...');
136
- const creditCardPaymentAuth = await authorizeCreditCardAsyncForcibly({
137
- object: {
138
- amount,
139
- // amount: 1, // 間違えてみる
140
- paymentMethod: paymentMethodType,
141
- paymentMethodId, // URL発行時のpaymentMethodIdを指定
142
- method: '1',
143
- creditCard,
144
- issuedThrough: { id: paymentServiceId }
145
- },
146
- purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
147
- })({ paymentService });
148
- console.log('credit card payment authorized', creditCardPaymentAuth.id);
149
-
150
- // tslint:disable-next-line:no-magic-numbers
151
- await wait(3000);
152
-
153
- console.log('setting customer profile...');
154
- await placeOrderService.setProfile({
155
- id: transaction.id,
156
- agent: profile
157
- });
158
- console.log('customer profile set');
159
-
160
- await wait(3000);
161
-
162
- // console.log('voiding credit card auth...');
163
- // await paymentService.voidTransaction({
164
- // id: creditCardPaymentAuth.id,
165
- // object: { typeOf: client.factory.service.paymentService.PaymentServiceType.CreditCard },
166
- // purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
167
- // });
168
- // console.log('credit card auth voided');
169
- // await wait(3000);
170
- // return;
171
-
172
- console.log('confirming transaction...');
173
-
174
- let confirmResult = await placeOrderService.confirmWithMiminalResponse({ id: transaction.id });
175
- console.log('transaction confirmed', confirmResult);
176
-
177
- // 何度確定をコールしても冪等
178
- console.log('reconfirming transaction...');
179
- confirmResult = await placeOrderService.confirmWithMiminalResponse({ id: transaction.id });
180
- console.log('transaction reconfirmed', confirmResult);
181
- resolve();
182
- } catch (error) {
183
- reject(error);
184
- }
185
- });
186
- });
187
- } catch (error) {
188
- console.error(error);
189
-
190
- await wait(3000);
191
-
192
- console.log('canceling transaction...');
193
- await placeOrderService.cancel({ id: transaction.id });
194
- console.log('transaction canceled.');
195
- }
196
- }
197
-
198
- type IAuthorizeReservationAction = Pick<
199
- client.factory.action.authorize.offer.eventService.IAction<client.factory.service.webAPI.Identifier.Chevre>,
200
- 'id'
201
- > & {
202
- result?: {
203
- price?: number;
204
- };
205
- };
206
-
207
- // tslint:disable-next-line:max-func-body-length
208
- async function authorizeSeatReservationByEvent(params: {
209
- event: client.factory.event.screeningEvent.IEvent;
210
- transaction: Pick<client.factory.transaction.placeOrder.ITransaction, 'id'>;
211
- }): Promise<{
212
- price: number;
213
- }> {
214
- const eventService = new (await client.loadService()).Event({
215
- endpoint: <string>process.env.API_ENDPOINT,
216
- auth: await auth(),
217
- project,
218
- seller: { id: '' }
219
- });
220
-
221
- const offerService = new (await client.loadService()).Offer({
222
- endpoint: <string>process.env.API_ENDPOINT,
223
- auth: await auth(),
224
- project,
225
- seller: { id: '' }
226
- });
227
-
228
- const screeningEvent = params.event;
229
- const transaction = params.transaction;
230
-
231
- // 券種検索
232
- let ticketOffers = await eventService.searchTicketOffers({
233
- event: { id: screeningEvent.id }
234
- });
235
- console.log('チケットオファーは以下の通りです');
236
- console.log(ticketOffers.map((o) => {
237
- const unitPriceSpecification = o.priceSpecification.priceComponent
238
- .filter((s) => s.typeOf === client.factory.priceSpecificationType.UnitPriceSpecification)
239
- .map((s) => `単価:${s.price}/${(<client.factory.priceSpecification.IPriceSpecification<client.factory.priceSpecificationType.UnitPriceSpecification>>s).referenceQuantity.value}`)
240
- .join(' ');
241
- const categoryCodeCharge = o.priceSpecification.priceComponent
242
- .filter((s) => s.typeOf === client.factory.priceSpecificationType.CategoryCodeChargeSpecification)
243
- .map((s) => `+${(<client.factory.priceSpecification.IPriceSpecification<client.factory.priceSpecificationType.CategoryCodeChargeSpecification>>s).appliesToCategoryCode[0].codeValue}チャージ:${s.price} ${s.priceCurrency}`)
244
- .join(' ');
245
-
246
- return `${o.id} ${(<client.factory.multilingualString>o.name).ja} ${unitPriceSpecification} ${o.priceCurrency} ${categoryCodeCharge}`;
247
- })
248
- .join('\n'));
249
-
250
- // 空席検索
251
- const searchSeatOffersResult = await eventService.searchSeats({ event: { id: screeningEvent.id } });
252
- const seatOffers = searchSeatOffersResult.data;
253
- // console.log(seatOffers.length, 'seatOffers found');
254
- // const seatOffers = offers[0].containsPlace;
255
- console.log(seatOffers.length, 'seatOffers found');
256
- const availableSeatOffers
257
- = seatOffers.filter((o) => o.offers?.shift()?.availability === client.factory.itemAvailability.InStock);
258
- console.log(availableSeatOffers.length, 'availableSeatOffers found');
259
- if (availableSeatOffers.length <= 0) {
260
- throw new Error('No available seats');
261
- }
262
-
263
- // ムビチケ以外のメンバーシップオファーを選択
264
- ticketOffers = ticketOffers
265
- .filter((offer) => {
266
- const movieTicketTypeChargeSpecification = offer.priceSpecification.priceComponent.find(
267
- (component) => component.typeOf === client.factory.priceSpecificationType.MovieTicketTypeChargeSpecification
268
- );
269
-
270
- return movieTicketTypeChargeSpecification === undefined;
271
- });
272
-
273
- const selectedTicketOffer = ticketOffers.shift();
274
- if (selectedTicketOffer === undefined) {
275
- throw new Error('selectedTicketOffer undefined');
276
- }
277
- console.log('ticket offer selected', selectedTicketOffer.id, selectedTicketOffer.identifier, selectedTicketOffer.name.ja);
278
-
279
- // 座席をランダムに選択
280
- const selectedScreeningRoomSection = String(availableSeatOffers[0].containedInPlace?.branchCode);
281
- console.log('screening room section selected', selectedScreeningRoomSection);
282
- console.log(selectedScreeningRoomSection);
283
- const selectedSeatOffers = availableSeatOffers.slice(0, 1);
284
- console.log(selectedSeatOffers.length, 'seats selected');
285
-
286
- await wait(3000);
287
- console.log('authorizing seat reservation...');
288
- const seatReservationAuth = <IAuthorizeReservationAction>await offerService.authorizeEventService({
289
- object: {
290
- reservationFor: {
291
- id: screeningEvent.id
292
- },
293
- acceptedOffer: selectedSeatOffers.map((o) => {
294
- return {
295
- typeOf: selectedTicketOffer.typeOf,
296
- id: String(selectedTicketOffer.id),
297
- itemOffered: {
298
- serviceOutput: {
299
- typeOf: client.factory.reservationType.EventReservation,
300
- reservedTicket: {
301
- typeOf: 'Ticket',
302
- ticketedSeat: {
303
- typeOf: client.factory.placeType.Seat,
304
- seatNumber: o.branchCode,
305
- seatSection: selectedScreeningRoomSection,
306
- seatRow: ''
307
- }
308
- }
309
- }
310
- },
311
- additionalProperty: [{ name: 'sampleName', value: 'sampleValue' }]
312
- };
313
- })
314
- },
315
- purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
316
- });
317
- console.log('seat reservation authorized', seatReservationAuth.id);
318
-
319
- const price = seatReservationAuth.result?.price;
320
- // 金額計算
321
- if (typeof price !== 'number') {
322
- throw new Error('result.price undefined');
323
- }
324
- console.log('price:', price);
325
-
326
- return { price };
327
- }
328
-
329
- async function wait(waitInMilliseconds: number) {
330
- return new Promise((resolve) => setTimeout(resolve, waitInMilliseconds));
331
- }
332
-
333
- const USE_FORCE_AUTHORIZE_PAYMENT_ASYNC_GIVE_UP_SECONDS = 10;
334
- const USE_FORCE_AUTHORIZE_PAYMENT_ASYNC_CHECK_INTERVAL_MS = 1000;
335
- function publishPaymentUrlAsyncForcibly(params: {
336
- object: Pick<client.factory.action.authorize.paymentMethod.any.IObjectWithoutDetail, 'amount' | 'creditCard' | 'issuedThrough' | 'paymentMethod' | 'method'>;
337
- purpose: {
338
- typeOf: client.factory.transactionType.PlaceOrder;
339
- id: string;
340
- };
341
- }) {
342
- return async (repos: {
343
- paymentService: client.cloudPay.service.Payment;
344
- }): Promise<client.factory.action.accept.pay.IResult> => {
345
- const acceptTask = await repos.paymentService.publishCreditCardPaymentUrlAsync(params);
346
- const giveUpPayment = moment()
347
- .add(USE_FORCE_AUTHORIZE_PAYMENT_ASYNC_GIVE_UP_SECONDS, 'seconds');
348
- let result: client.factory.action.accept.pay.IResult | undefined;
349
- let error: { name?: string; message?: string } | undefined;
350
-
351
- // n秒おきに状態確認
352
- while (result === undefined && error === undefined) {
353
- await wait(USE_FORCE_AUTHORIZE_PAYMENT_ASYNC_CHECK_INTERVAL_MS); // n秒待機
354
-
355
- // タスク作成から一定時間経過すればあきらめる
356
- if (moment()
357
- .isAfter(giveUpPayment)) {
358
- error = new client.factory.errors.GatewayTimeout('action given up');
359
- break;
360
- }
361
-
362
- const acceptAction = await repos.paymentService.findAcceptPayAction({
363
- sameAs: { id: acceptTask.id },
364
- purpose: params.purpose
365
- });
366
-
367
- // CompletedActionStatusであればタスク完了とみなす
368
- if (acceptAction.actionStatus === client.factory.actionStatusType.CompletedActionStatus
369
- && acceptAction.result !== undefined) {
370
- result = acceptAction.result;
371
- break;
372
- } else {
373
- // 待機続行
374
- }
375
-
376
- // エラーが存在すれば、これ以上待機する価値はなし
377
- if (acceptAction.error !== undefined) {
378
- error = acceptAction.error;
379
- break;
380
- }
381
- }
382
-
383
- if (typeof result?.paymentMethodId === 'string') {
384
- return result;
385
- }
386
-
387
- throw error;
388
- };
389
- }
390
-
391
- function authorizeCreditCardAsyncForcibly(params: {
392
- object: Pick<
393
- client.factory.action.authorize.paymentMethod.any.IObjectWithoutDetail,
394
- 'amount' | 'issuedThrough' | 'paymentMethod' | 'creditCard' | 'method' | 'paymentMethodId' | 'name' | 'additionalProperty'
395
- >;
396
- purpose: {
397
- typeOf: client.factory.transactionType.PlaceOrder;
398
- id: string;
399
- };
400
- }) {
401
- return async (repos: {
402
- paymentService: client.cloudPay.service.Payment;
403
- }): Promise<{ id: string }> => {
404
- // 決済承認タスク作成
405
- const authorizeTask = await repos.paymentService.authorizeCreditCardAsync(params);
406
- const giveUpPayment = moment()
407
- .add(USE_FORCE_AUTHORIZE_PAYMENT_ASYNC_GIVE_UP_SECONDS, 'seconds');
408
- let result: { id: string } | undefined;
409
- let error: { name?: string; message?: string } | undefined;
410
-
411
- // n秒おきに状態確認
412
- while (result === undefined && error === undefined) {
413
- await wait(USE_FORCE_AUTHORIZE_PAYMENT_ASYNC_CHECK_INTERVAL_MS); // n秒待機
414
-
415
- // タスク作成から一定時間経過すればあきらめる
416
- if (moment()
417
- .isAfter(giveUpPayment)) {
418
- error = new client.factory.errors.GatewayTimeout('action given up');
419
- break;
420
- }
421
-
422
- const authorizeAction = await repos.paymentService.findAuthorizeAction({
423
- sameAs: { id: authorizeTask.id },
424
- object: {
425
- typeOf: client.factory.service.paymentService.PaymentServiceType.CreditCard
426
- },
427
- purpose: params.purpose
428
- });
429
-
430
- // アクションIDが存在し、CompletedActionStatusであればタスク完了とみなす
431
- if (typeof authorizeAction.id === 'string') {
432
- if (authorizeAction.actionStatus === client.factory.actionStatusType.CompletedActionStatus) {
433
- // ステータス完了であれば決済承認アクションIDを保管
434
- result = { id: authorizeAction.id };
435
- break;
436
- } else {
437
- // 待機続行
438
- }
439
- }
440
-
441
- // エラーが存在すれば、これ以上待機する価値はなし
442
- if (authorizeAction.error !== undefined) {
443
- error = authorizeAction.error;
444
- break;
445
- }
446
- }
447
-
448
- if (typeof result?.id === 'string') {
449
- return result;
450
- }
451
-
452
- throw error;
453
- };
454
- }
455
-
456
- main()
457
- .then(() => {
458
- console.log('success!');
459
- })
460
- .catch(console.error);
@@ -1,41 +0,0 @@
1
- import { IAuthorizeEventServiceResult, IMinimalAuthorizeEventServiceResult } from '../../chevreTxn/transaction/placeOrder/factory';
2
- import * as factory from '../../factory';
3
- import { IAdditionalOptions, IOptions, Service } from '../../service';
4
- /**
5
- * オファーサービス
6
- */
7
- export declare class OfferService extends Service {
8
- constructor(options: Pick<IOptions, 'auth' | 'endpoint' | 'transporter' | 'project' | 'defaultPath'> & IAdditionalOptions);
9
- /**
10
- * 興行オファー承認
11
- */
12
- authorizeEventService(params: {
13
- object: factory.action.authorize.offer.eventService.IObjectWithoutDetail<factory.service.webAPI.Identifier.Chevre>;
14
- purpose: factory.action.authorize.offer.eventService.IPurpose;
15
- }, options?: {
16
- /**
17
- * レスポンスを最小化する
18
- * Promise<IMinimalAuthorizeEventServiceResult>が返ります
19
- */
20
- expectsMinimalResponse?: boolean;
21
- /**
22
- * オファー未指定(座席をホールドするのみ)
23
- */
24
- noOfferSpecified?: boolean;
25
- }): Promise<IAuthorizeEventServiceResult | IMinimalAuthorizeEventServiceResult>;
26
- /**
27
- * 興行オファー承認取消
28
- */
29
- voidAuthorization(params: {
30
- /**
31
- * アクションID
32
- */
33
- id: string;
34
- object: {
35
- itemOffered: {
36
- typeOf: factory.product.ProductType.EventService;
37
- };
38
- };
39
- purpose: factory.action.authorize.offer.eventService.IPurpose;
40
- }): Promise<void>;
41
- }
@@ -1,136 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
- return new (P || (P = Promise))(function (resolve, reject) {
31
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
- step((generator = generator.apply(thisArg, _arguments || [])).next());
35
- });
36
- };
37
- var __generator = (this && this.__generator) || function (thisArg, body) {
38
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
39
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
40
- function verb(n) { return function (v) { return step([n, v]); }; }
41
- function step(op) {
42
- if (f) throw new TypeError("Generator is already executing.");
43
- while (_) try {
44
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
45
- if (y = 0, t) op = [op[0] & 2, t.value];
46
- switch (op[0]) {
47
- case 0: case 1: t = op; break;
48
- case 4: _.label++; return { value: op[1], done: false };
49
- case 5: _.label++; y = op[1]; op = [0]; continue;
50
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
51
- default:
52
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
53
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
54
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
55
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
56
- if (t[2]) _.ops.pop();
57
- _.trys.pop(); continue;
58
- }
59
- op = body.call(thisArg, _);
60
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
61
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
- }
63
- };
64
- var __rest = (this && this.__rest) || function (s, e) {
65
- var t = {};
66
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
67
- t[p] = s[p];
68
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
69
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
70
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
71
- t[p[i]] = s[p[i]];
72
- }
73
- return t;
74
- };
75
- Object.defineProperty(exports, "__esModule", { value: true });
76
- exports.OfferService = void 0;
77
- var http_status_1 = require("http-status");
78
- var factory = require("../../factory");
79
- var service_1 = require("../../service");
80
- /**
81
- * オファーサービス
82
- */
83
- var OfferService = /** @class */ (function (_super) {
84
- __extends(OfferService, _super);
85
- function OfferService(options) {
86
- return _super.call(this, __assign(__assign({}, options), { defaultPath: '/txn', retryableStatusCodes: [http_status_1.BAD_GATEWAY, http_status_1.FORBIDDEN, http_status_1.UNAUTHORIZED] })) || this;
87
- }
88
- /**
89
- * 興行オファー承認
90
- */
91
- OfferService.prototype.authorizeEventService = function (params, options) {
92
- return __awaiter(this, void 0, void 0, function () {
93
- var _this = this;
94
- return __generator(this, function (_a) {
95
- return [2 /*return*/, this.fetch({
96
- uri: "/offers/" + factory.product.ProductType.EventService + "/authorize",
97
- method: 'POST',
98
- expectedStatusCodes: [http_status_1.CREATED],
99
- body: params,
100
- qs: __assign(__assign({ purpose: { id: params.purpose.id } }, ((options === null || options === void 0 ? void 0 : options.expectsMinimalResponse) === true) ? { expectsMinimalResponse: '1' } : undefined), ((options === null || options === void 0 ? void 0 : options.noOfferSpecified) === true) ? { noOfferSpecified: '1' } : undefined)
101
- })
102
- .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
103
- return [2 /*return*/, response.json()];
104
- }); }); })];
105
- });
106
- });
107
- };
108
- /**
109
- * 興行オファー承認取消
110
- */
111
- OfferService.prototype.voidAuthorization = function (params) {
112
- return __awaiter(this, void 0, void 0, function () {
113
- var id, object, body;
114
- return __generator(this, function (_a) {
115
- switch (_a.label) {
116
- case 0:
117
- id = params.id, object = params.object, body = __rest(params, ["id", "object"]);
118
- return [4 /*yield*/, this.fetch({
119
- uri: "/offers/" + object.itemOffered.typeOf + "/authorize/" + id + "/void",
120
- method: 'PUT',
121
- expectedStatusCodes: [http_status_1.NO_CONTENT],
122
- body: body,
123
- qs: {
124
- purpose: { id: params.purpose.id } // 追加(2024-04-03~)
125
- }
126
- })];
127
- case 1:
128
- _a.sent();
129
- return [2 /*return*/];
130
- }
131
- });
132
- });
133
- };
134
- return OfferService;
135
- }(service_1.Service));
136
- exports.OfferService = OfferService;