@cinerino/sdk 12.8.0-alpha.2 → 12.8.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.
@@ -1,12 +1,13 @@
1
1
  // tslint:disable:no-console
2
2
  // tslint:disable-next-line:no-implicit-dependencies
3
+ import * as moment from 'moment';
3
4
  import * as client from '../../../../lib/index';
4
5
  import * as auth from '../../auth/authAsAdmin';
5
6
 
6
7
  const PROJECT_ID = String(process.env.PROJECT_ID);
7
8
  const SELLER_ID = '59d20831e53ebc2b4e774466';
8
- const OFFER_IDENTIFIER = '20251115eventOffer01';
9
- const itemOfferedId = '69151228ad580da66c8b5068';
9
+ const OFFER_IDENTIFIER = '20251119eventOffer01';
10
+ const itemOfferedId = '691d48de08422fdedd8b864a';
10
11
 
11
12
  // tslint:disable-next-line:max-func-body-length
12
13
  async function main() {
@@ -24,13 +25,18 @@ async function main() {
24
25
  });
25
26
 
26
27
  const now = new Date();
28
+ const validFrom = moment(now)
29
+ .toDate();
30
+ const validThrough = moment(validFrom)
31
+ .add(1, 'minutes')
32
+ .toDate();
27
33
  await eventOfferService.createEventOfferByIdentifier(
28
34
  [
29
35
  {
30
36
  identifier: OFFER_IDENTIFIER,
31
37
  availableAtOrFrom: { identifier: 'SmartTheaterTXN' },
32
- validFrom: now,
33
- validThrough: now
38
+ validFrom,
39
+ validThrough
34
40
  }
35
41
  ],
36
42
  {
@@ -44,8 +50,8 @@ async function main() {
44
50
  {
45
51
  identifier: OFFER_IDENTIFIER,
46
52
  availableAtOrFrom: { identifier: 'SmartTheaterTXN' },
47
- validFrom: now,
48
- validThrough: now
53
+ validFrom,
54
+ validThrough
49
55
  }
50
56
  ],
51
57
  {
@@ -364,15 +364,24 @@ async function authorizeSeatReservationByEvent(params: {
364
364
  const selectedSeatOffers = availableSeatOffers.slice(0, 1);
365
365
  console.log(selectedSeatOffers.length, 'seats selected');
366
366
 
367
+ // tslint:disable-next-line:no-suspicious-comment
368
+ // TODO 拡張イベントオファー検索
369
+
370
+ await wait(3000);
371
+ // 拡張オファー使用の場合、オファーコードを指定してオファーチケットを発行
372
+ const { ticketToken } = await offerService.issueEventServiceOfferTicket({
373
+ audience: { id: transaction.id },
374
+ eventId: screeningEvent.id,
375
+ eventOfferId: '691d492f929e69df1e32b89d' // 拡張オファー使用の場合、オファーコードを指定する
376
+ });
377
+ console.log('offer ticket issued.', ticketToken);
378
+
367
379
  await wait(3000);
368
380
  console.log('authorizing seat reservation...');
369
381
  const seatReservationAuth = <IAuthorizeReservationAction>await offerService.authorizeEventService({
370
382
  object: {
371
383
  reservationFor: {
372
- id: screeningEvent.id,
373
- offers: {
374
- identifier: '20251113eventOffer' // 拡張オファー使用の場合、オファーコードを指定する
375
- }
384
+ id: screeningEvent.id
376
385
  },
377
386
  acceptedOffer: selectedSeatOffers.map((o) => {
378
387
  return {
@@ -396,7 +405,10 @@ async function authorizeSeatReservationByEvent(params: {
396
405
  };
397
406
  })
398
407
  },
399
- purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder }
408
+ purpose: { id: transaction.id, typeOf: client.factory.transactionType.PlaceOrder },
409
+ instrument: [
410
+ { ticketToken, typeOf: 'Ticket' } // オファーチケットを指定する
411
+ ]
400
412
  });
401
413
  console.log('seat reservation authorized', seatReservationAuth.id);
402
414
 
@@ -323,17 +323,21 @@ async function authorizeSeatReservationByEvent(params: {
323
323
  if (typeof MEMBER_PROGRAM_TIER_TOKEN !== 'string') {
324
324
  throw new Error('process.env.MEMBER_PROGRAM_TIER_TOKEN required');
325
325
  }
326
+
327
+ // tslint:disable-next-line:no-suspicious-comment
328
+ // TODO オファーチケット発行
329
+ // offers: {
330
+ // validForMemberTier: {
331
+ // token: MEMBER_PROGRAM_TIER_TOKEN,
332
+ // isTierOf: { identifier: 'DefaultMemberProgram' }
333
+ // }
334
+ // }
335
+
326
336
  console.log('authorizing seat reservation...');
327
337
  const seatReservationAuth = <IAuthorizeReservationAction>await offerService.authorizeEventService({
328
338
  object: {
329
339
  reservationFor: {
330
- id: screeningEvent.id,
331
- offers: {
332
- validForMemberTier: {
333
- token: MEMBER_PROGRAM_TIER_TOKEN,
334
- isTierOf: { identifier: 'DefaultMemberProgram' }
335
- }
336
- }
340
+ id: screeningEvent.id
337
341
  },
338
342
  acceptedOffer: selectedSeatOffers.map((o) => {
339
343
  return {
@@ -3,15 +3,26 @@ import { Service } from '../service';
3
3
  declare type ISendEmailMessageOnEventUpdated = Pick<factory.action.transfer.send.message.email.IAttributes, 'purpose' | 'recipient'> & {
4
4
  object: factory.action.transfer.send.message.email.IObjectAsEmailMessage;
5
5
  };
6
+ /**
7
+ * 識別子によるイベント追加パラメータ
8
+ */
6
9
  export declare type ICreateParamsByIdentifier = Pick<factory.event.screeningEvent.ICreateParams, 'additionalProperty' | 'doorTime' | 'endDate' | 'eventStatus' | 'maximumPhysicalAttendeeCapacity' | 'offers' | 'startDate'> & {
7
10
  identifier: string;
8
11
  offers: Pick<factory.event.screeningEvent.IOffers4create, 'eligibleQuantity' | 'seller' | 'unacceptedPaymentMethod'> & {
9
12
  itemOffered: Pick<factory.event.screeningEvent.IItemOffered, 'id'>;
10
13
  };
11
14
  };
15
+ /**
16
+ * 識別子によるイベント編集パラメータ
17
+ */
12
18
  export declare type IUpdateParamsByIdentifier = Pick<factory.event.screeningEvent.IUpdateByIdParams, 'additionalProperty' | 'doorTime' | 'endDate' | 'eventStatus' | 'maximumPhysicalAttendeeCapacity' | 'startDate'> & {
13
19
  identifier: string;
14
- offers: Pick<factory.event.screeningEvent.IOffer4update, 'eligibleQuantity' | 'unacceptedPaymentMethod' | 'itemOffered' | 'seller'>;
20
+ offers: Pick<factory.event.screeningEvent.IOffer4update, 'eligibleQuantity' | 'unacceptedPaymentMethod' | 'itemOffered'> & {
21
+ /**
22
+ * アプリケーション設定
23
+ */
24
+ seller: Pick<factory.event.screeningEvent.ISeller4create, 'makesOffer'>;
25
+ };
15
26
  location?: never;
16
27
  superEvent?: never;
17
28
  };
@@ -1,6 +1,6 @@
1
1
  import * as factory from '../factory';
2
2
  import { Service } from '../service';
3
- import { IAuthorizeEventServiceResult, IAuthorizeProductOfferResult, IMinimalAuthorizeEventServiceResult } from './transaction/placeOrder/factory';
3
+ import { IAuthorizeEventServiceResult, IAuthorizeProductOfferResult, IMinimalAuthorizeEventServiceResult, IOfferTicket } from './transaction/placeOrder/factory';
4
4
  export interface IPurpose {
5
5
  typeOf: factory.transactionType;
6
6
  id: string;
@@ -16,12 +16,22 @@ export declare class OfferService extends Service {
16
16
  object: factory.action.authorize.offer.product.IObjectWithoutDetail;
17
17
  purpose: factory.action.authorize.offer.product.IPurpose;
18
18
  }): Promise<IAuthorizeProductOfferResult>;
19
+ /**
20
+ * 興行オファーチケット発行
21
+ */
22
+ issueEventServiceOfferTicket(params: {
23
+ audience: Pick<factory.action.authorize.offer.eventService.IPurpose, 'id'>;
24
+ eventId: string;
25
+ eventOfferId?: string;
26
+ ticketedOffer?: Pick<factory.authorization.IOfferAsObject, 'token' | 'validForMemberTier'>;
27
+ }): Promise<IOfferTicket>;
19
28
  /**
20
29
  * 興行オファー承認
21
30
  */
22
31
  authorizeEventService(params: {
23
- object: factory.action.authorize.offer.eventService.IObjectWithoutDetail;
32
+ object: Pick<factory.action.authorize.offer.eventService.IObjectWithoutDetail, 'acceptedOffer' | 'reservationFor'>;
24
33
  purpose: factory.action.authorize.offer.eventService.IPurpose;
34
+ instrument?: factory.action.reserve.ITicketAsInstrument[];
25
35
  }, options?: {
26
36
  expectsMinimalResponse?: boolean;
27
37
  /**
@@ -107,6 +107,28 @@ var OfferService = /** @class */ (function (_super) {
107
107
  });
108
108
  });
109
109
  };
110
+ /**
111
+ * 興行オファーチケット発行
112
+ */
113
+ OfferService.prototype.issueEventServiceOfferTicket = function (params) {
114
+ return __awaiter(this, void 0, void 0, function () {
115
+ var ticketedOffer, audience, eventId, eventOfferId;
116
+ var _this = this;
117
+ return __generator(this, function (_a) {
118
+ ticketedOffer = params.ticketedOffer, audience = params.audience, eventId = params.eventId, eventOfferId = params.eventOfferId;
119
+ return [2 /*return*/, this.fetch({
120
+ uri: "/offers/" + factory.product.ProductType.EventService + "/tickets",
121
+ method: 'POST',
122
+ expectedStatusCodes: [http_status_1.CREATED],
123
+ body: { ticketedOffer: ticketedOffer },
124
+ qs: __assign({ audience: { id: audience.id }, eventId: eventId }, (typeof eventOfferId === 'string') ? { eventOfferId: eventOfferId } : undefined)
125
+ })
126
+ .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
127
+ return [2 /*return*/, response.json()];
128
+ }); }); })];
129
+ });
130
+ });
131
+ };
110
132
  /**
111
133
  * 興行オファー承認
112
134
  */
@@ -69,4 +69,13 @@ export declare type IMinimalOrderAsConfirmResult = Pick<factory.order.IOrder, 'c
69
69
  export interface IMinimalConfirmResult {
70
70
  order: IMinimalOrderAsConfirmResult;
71
71
  }
72
+ /**
73
+ * 興行オファーチケット
74
+ */
75
+ export interface IOfferTicket {
76
+ /**
77
+ * チケットトークン
78
+ */
79
+ ticketToken: string;
80
+ }
72
81
  export {};
@@ -1,6 +1,6 @@
1
1
  import * as factory from '../../factory';
2
2
  import { Service } from '../../service';
3
- import { ICreateParamsByIdentifier, IUpdateEventSellerMakesOfferParamsByIdentifier, IUpdateParamsByIdentifier } from '../../chevreAdmin/event';
3
+ import { ICreateParamsByIdentifier, IUpdateParamsByIdentifier } from '../../chevreAdmin/event';
4
4
  declare type ISendEmailMessageOnEventUpdated = Pick<factory.action.transfer.send.message.email.IAttributes, 'purpose' | 'recipient'> & {
5
5
  object: factory.action.transfer.send.message.email.IObjectAsEmailMessage;
6
6
  };
@@ -39,15 +39,6 @@ export declare class EventService extends Service {
39
39
  updateEventsByIdentifier(params: IUpdateParamsByIdentifier[], options: {
40
40
  typeOf: factory.eventType.ScreeningEvent;
41
41
  }): Promise<void>;
42
- /**
43
- * イベントのアプリケーションオファー編集(識別子によるイベント複数編集)
44
- * 識別子のイベントが存在しなければNotFound
45
- */
46
- updateEventsSellerMakesOfferByIdentifier(
47
- /**
48
- * max: 10
49
- */
50
- params: IUpdateEventSellerMakesOfferParamsByIdentifier[]): Promise<void>;
51
42
  /**
52
43
  * イベントステータス更新
53
44
  */
@@ -136,38 +136,6 @@ var EventService = /** @class */ (function (_super) {
136
136
  });
137
137
  });
138
138
  };
139
- /**
140
- * イベントのアプリケーションオファー編集(識別子によるイベント複数編集)
141
- * 識別子のイベントが存在しなければNotFound
142
- */
143
- EventService.prototype.updateEventsSellerMakesOfferByIdentifier = function (
144
- /**
145
- * max: 10
146
- */
147
- params) {
148
- return __awaiter(this, void 0, void 0, function () {
149
- var _a, auth, endpoint, project, seller, disableAutoRetry, chevreAdmin, eventService;
150
- return __generator(this, function (_b) {
151
- switch (_b.label) {
152
- case 0:
153
- _a = this.options, auth = _a.auth, endpoint = _a.endpoint, project = _a.project, seller = _a.seller, disableAutoRetry = _a.disableAutoRetry;
154
- return [4 /*yield*/, index_1.loadChevreAdmin({ auth: auth, endpoint: endpoint, disableAutoRetry: disableAutoRetry })];
155
- case 1:
156
- chevreAdmin = _b.sent();
157
- return [4 /*yield*/, chevreAdmin.createEventInstance({
158
- project: project,
159
- seller: { id: (typeof (seller === null || seller === void 0 ? void 0 : seller.id) === 'string') ? seller.id : '' }
160
- })];
161
- case 2:
162
- eventService = _b.sent();
163
- return [4 /*yield*/, eventService.updateEventsSellerMakesOfferByIdentifier(params)];
164
- case 3:
165
- _b.sent();
166
- return [2 /*return*/];
167
- }
168
- });
169
- });
170
- };
171
139
  /**
172
140
  * イベントステータス更新
173
141
  */
@@ -1,16 +1,26 @@
1
- import type { IAuthorizeEventServiceResult, IMinimalAuthorizeEventServiceResult } from '../../chevreTxn/transaction/placeOrder/factory';
1
+ import type { IAuthorizeEventServiceResult, IMinimalAuthorizeEventServiceResult, IOfferTicket } from '../../chevreTxn/transaction/placeOrder/factory';
2
2
  import * as factory from '../../factory';
3
3
  import { Service } from '../../service';
4
4
  /**
5
5
  * オファーサービス
6
6
  */
7
7
  export declare class OfferService extends Service {
8
+ /**
9
+ * 興行オファーチケット発行
10
+ */
11
+ issueEventServiceOfferTicket(params: {
12
+ audience: Pick<factory.action.authorize.offer.eventService.IPurpose, 'id'>;
13
+ eventId: string;
14
+ eventOfferId?: string;
15
+ ticketedOffer?: Pick<factory.authorization.IOfferAsObject, 'token' | 'validForMemberTier'>;
16
+ }): Promise<IOfferTicket>;
8
17
  /**
9
18
  * 興行オファー承認
10
19
  */
11
20
  authorizeEventService(params: {
12
21
  object: factory.action.authorize.offer.eventService.IObjectWithoutDetail;
13
22
  purpose: factory.action.authorize.offer.eventService.IPurpose;
23
+ instrument?: factory.action.reserve.ITicketAsInstrument[];
14
24
  }, options?: {
15
25
  /**
16
26
  * レスポンスを最小化する
@@ -75,6 +75,32 @@ var OfferService = /** @class */ (function (_super) {
75
75
  // > & IAdditionalOptions) {
76
76
  // super(options);
77
77
  // }
78
+ /**
79
+ * 興行オファーチケット発行
80
+ */
81
+ OfferService.prototype.issueEventServiceOfferTicket = function (params) {
82
+ return __awaiter(this, void 0, void 0, function () {
83
+ var _a, auth, endpoint, project, seller, disableAutoRetry, retryableStatusCodes, chevreTxn, offerService, ticketedOffer, audience, eventId, eventOfferId;
84
+ return __generator(this, function (_b) {
85
+ switch (_b.label) {
86
+ case 0:
87
+ _a = this.options, auth = _a.auth, endpoint = _a.endpoint, project = _a.project, seller = _a.seller, disableAutoRetry = _a.disableAutoRetry, retryableStatusCodes = _a.retryableStatusCodes;
88
+ return [4 /*yield*/, index_1.loadChevreTxn({ auth: auth, endpoint: endpoint, disableAutoRetry: disableAutoRetry })];
89
+ case 1:
90
+ chevreTxn = _b.sent();
91
+ return [4 /*yield*/, chevreTxn.createOfferInstance({
92
+ project: project,
93
+ seller: { id: (typeof (seller === null || seller === void 0 ? void 0 : seller.id) === 'string') ? seller.id : '' },
94
+ retryableStatusCodes: __spreadArray([], (Array.isArray(retryableStatusCodes)) ? retryableStatusCodes : [])
95
+ })];
96
+ case 2:
97
+ offerService = _b.sent();
98
+ ticketedOffer = params.ticketedOffer, audience = params.audience, eventId = params.eventId, eventOfferId = params.eventOfferId;
99
+ return [2 /*return*/, offerService.issueEventServiceOfferTicket({ ticketedOffer: ticketedOffer, audience: audience, eventId: eventId, eventOfferId: eventOfferId })];
100
+ }
101
+ });
102
+ });
103
+ };
78
104
  /**
79
105
  * 興行オファー承認
80
106
  */
@@ -100,7 +126,8 @@ var OfferService = /** @class */ (function (_super) {
100
126
  acceptedOffer: params.object.acceptedOffer,
101
127
  reservationFor: params.object.reservationFor
102
128
  },
103
- purpose: { id: params.purpose.id, typeOf: factory.transactionType.PlaceOrder }
129
+ purpose: { id: params.purpose.id, typeOf: factory.transactionType.PlaceOrder },
130
+ instrument: (Array.isArray(params.instrument)) ? params.instrument : []
104
131
  }, options)];
105
132
  }
106
133
  });
package/lib/bundle.js CHANGED
@@ -19295,6 +19295,28 @@ var OfferService = /** @class */ (function (_super) {
19295
19295
  });
19296
19296
  });
19297
19297
  };
19298
+ /**
19299
+ * 興行オファーチケット発行
19300
+ */
19301
+ OfferService.prototype.issueEventServiceOfferTicket = function (params) {
19302
+ return __awaiter(this, void 0, void 0, function () {
19303
+ var ticketedOffer, audience, eventId, eventOfferId;
19304
+ var _this = this;
19305
+ return __generator(this, function (_a) {
19306
+ ticketedOffer = params.ticketedOffer, audience = params.audience, eventId = params.eventId, eventOfferId = params.eventOfferId;
19307
+ return [2 /*return*/, this.fetch({
19308
+ uri: "/offers/" + factory.product.ProductType.EventService + "/tickets",
19309
+ method: 'POST',
19310
+ expectedStatusCodes: [http_status_1.CREATED],
19311
+ body: { ticketedOffer: ticketedOffer },
19312
+ qs: __assign({ audience: { id: audience.id }, eventId: eventId }, (typeof eventOfferId === 'string') ? { eventOfferId: eventOfferId } : undefined)
19313
+ })
19314
+ .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
19315
+ return [2 /*return*/, response.json()];
19316
+ }); }); })];
19317
+ });
19318
+ });
19319
+ };
19298
19320
  /**
19299
19321
  * 興行オファー承認
19300
19322
  */
@@ -21745,38 +21767,6 @@ var EventService = /** @class */ (function (_super) {
21745
21767
  });
21746
21768
  });
21747
21769
  };
21748
- /**
21749
- * イベントのアプリケーションオファー編集(識別子によるイベント複数編集)
21750
- * 識別子のイベントが存在しなければNotFound
21751
- */
21752
- EventService.prototype.updateEventsSellerMakesOfferByIdentifier = function (
21753
- /**
21754
- * max: 10
21755
- */
21756
- params) {
21757
- return __awaiter(this, void 0, void 0, function () {
21758
- var _a, auth, endpoint, project, seller, disableAutoRetry, chevreAdmin, eventService;
21759
- return __generator(this, function (_b) {
21760
- switch (_b.label) {
21761
- case 0:
21762
- _a = this.options, auth = _a.auth, endpoint = _a.endpoint, project = _a.project, seller = _a.seller, disableAutoRetry = _a.disableAutoRetry;
21763
- return [4 /*yield*/, index_1.loadChevreAdmin({ auth: auth, endpoint: endpoint, disableAutoRetry: disableAutoRetry })];
21764
- case 1:
21765
- chevreAdmin = _b.sent();
21766
- return [4 /*yield*/, chevreAdmin.createEventInstance({
21767
- project: project,
21768
- seller: { id: (typeof (seller === null || seller === void 0 ? void 0 : seller.id) === 'string') ? seller.id : '' }
21769
- })];
21770
- case 2:
21771
- eventService = _b.sent();
21772
- return [4 /*yield*/, eventService.updateEventsSellerMakesOfferByIdentifier(params)];
21773
- case 3:
21774
- _b.sent();
21775
- return [2 /*return*/];
21776
- }
21777
- });
21778
- });
21779
- };
21780
21770
  /**
21781
21771
  * イベントステータス更新
21782
21772
  */
@@ -26320,6 +26310,32 @@ var OfferService = /** @class */ (function (_super) {
26320
26310
  // > & IAdditionalOptions) {
26321
26311
  // super(options);
26322
26312
  // }
26313
+ /**
26314
+ * 興行オファーチケット発行
26315
+ */
26316
+ OfferService.prototype.issueEventServiceOfferTicket = function (params) {
26317
+ return __awaiter(this, void 0, void 0, function () {
26318
+ var _a, auth, endpoint, project, seller, disableAutoRetry, retryableStatusCodes, chevreTxn, offerService, ticketedOffer, audience, eventId, eventOfferId;
26319
+ return __generator(this, function (_b) {
26320
+ switch (_b.label) {
26321
+ case 0:
26322
+ _a = this.options, auth = _a.auth, endpoint = _a.endpoint, project = _a.project, seller = _a.seller, disableAutoRetry = _a.disableAutoRetry, retryableStatusCodes = _a.retryableStatusCodes;
26323
+ return [4 /*yield*/, index_1.loadChevreTxn({ auth: auth, endpoint: endpoint, disableAutoRetry: disableAutoRetry })];
26324
+ case 1:
26325
+ chevreTxn = _b.sent();
26326
+ return [4 /*yield*/, chevreTxn.createOfferInstance({
26327
+ project: project,
26328
+ seller: { id: (typeof (seller === null || seller === void 0 ? void 0 : seller.id) === 'string') ? seller.id : '' },
26329
+ retryableStatusCodes: __spreadArray([], (Array.isArray(retryableStatusCodes)) ? retryableStatusCodes : [])
26330
+ })];
26331
+ case 2:
26332
+ offerService = _b.sent();
26333
+ ticketedOffer = params.ticketedOffer, audience = params.audience, eventId = params.eventId, eventOfferId = params.eventOfferId;
26334
+ return [2 /*return*/, offerService.issueEventServiceOfferTicket({ ticketedOffer: ticketedOffer, audience: audience, eventId: eventId, eventOfferId: eventOfferId })];
26335
+ }
26336
+ });
26337
+ });
26338
+ };
26323
26339
  /**
26324
26340
  * 興行オファー承認
26325
26341
  */
@@ -26345,7 +26361,8 @@ var OfferService = /** @class */ (function (_super) {
26345
26361
  acceptedOffer: params.object.acceptedOffer,
26346
26362
  reservationFor: params.object.reservationFor
26347
26363
  },
26348
- purpose: { id: params.purpose.id, typeOf: factory.transactionType.PlaceOrder }
26364
+ purpose: { id: params.purpose.id, typeOf: factory.transactionType.PlaceOrder },
26365
+ instrument: (Array.isArray(params.instrument)) ? params.instrument : []
26349
26366
  }, options)];
26350
26367
  }
26351
26368
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cinerino/sdk",
3
- "version": "12.8.0-alpha.2",
3
+ "version": "12.8.0",
4
4
  "description": "Cinerino SDK",
5
5
  "main": "./lib/index.js",
6
6
  "browser": {
@@ -93,7 +93,7 @@
93
93
  "watchify": "^3.11.1"
94
94
  },
95
95
  "dependencies": {
96
- "@chevre/factory": "5.2.0-alpha.11",
96
+ "@chevre/factory": "5.2.0-alpha.15",
97
97
  "debug": "3.2.7",
98
98
  "http-status": "1.7.4",
99
99
  "idtoken-verifier": "2.0.3",
@@ -1,138 +0,0 @@
1
- // tslint:disable:no-console
2
- // tslint:disable-next-line:no-implicit-dependencies
3
- import * as moment from 'moment-timezone';
4
- import * as client from '../../../../lib/index';
5
- import * as auth from '../../auth/authAsAdmin';
6
-
7
- const PROJECT_ID = String(process.env.PROJECT_ID);
8
- const SELLER_ID = '59d20831e53ebc2b4e774466';
9
- const EVENT_SERVICE_ID = '681aa7c1b53b6dbbe5efbec7';
10
- const AVAILABLE_AT_OR_FROM_ID = '51qbjcfr72h62m06vtv5kkhgje';
11
- const ADDITIONAL_PROPERTY_NAME = 'sampleCreateId';
12
-
13
- // tslint:disable-next-line:max-func-body-length
14
- async function main() {
15
- const authClient = await auth.login();
16
- await authClient.refreshAccessToken();
17
- const loginTicket = authClient.verifyIdToken({});
18
- console.log('username is', loginTicket.getUsername());
19
-
20
- const eventService = await (await client.loadChevreAdmin({
21
- endpoint: <string>process.env.CHEVRE_ENDPOINT,
22
- auth: authClient
23
- })).createEventInstance({
24
- project: { id: PROJECT_ID },
25
- seller: { id: SELLER_ID }
26
- });
27
-
28
- const today = moment()
29
- .tz('Asia/Tokyo')
30
- .format('YYYY-MM-DD');
31
- // const identifier = `fromSamples${moment()
32
- // .format('YYYYMMDDTHHmm')}`;
33
- const identifier = 'fromSamples20251028T1337';
34
- await eventService.createIfNotExistByIdentifier(
35
- [
36
- {
37
- identifier,
38
- doorTime: moment(`${today}T13:00:00Z`)
39
- .toDate(),
40
- startDate: moment(`${today}T13:00:00Z`)
41
- .toDate(),
42
- endDate: moment(`${today}T14:00:00Z`)
43
- .toDate(),
44
- eventStatus: client.factory.eventStatusType.EventScheduled,
45
- additionalProperty: [
46
- { name: ADDITIONAL_PROPERTY_NAME, value: identifier }
47
- ],
48
- maximumPhysicalAttendeeCapacity: 3,
49
- offers: {
50
- unacceptedPaymentMethod: [],
51
- eligibleQuantity: {
52
- maxValue: 6
53
- },
54
- itemOffered: {
55
- id: EVENT_SERVICE_ID
56
- },
57
- seller: {
58
- makesOffer: [
59
- {
60
- typeOf: client.factory.offerType.Offer,
61
- availableAtOrFrom: { id: AVAILABLE_AT_OR_FROM_ID }, // <-販売アプリケーションIDを指定する
62
- availabilityStarts: moment(`${today}T00:00:00+09:00`)
63
- .toDate(),
64
- availabilityEnds: moment(`${today}T14:00:00Z`)
65
- .toDate(),
66
- validFrom: moment(`${today}T00:00:00+09:00`)
67
- .toDate(),
68
- validThrough: moment(`${today}T14:00:00Z`)
69
- .toDate()
70
- }
71
- ]
72
- // makesOfferDefaultを指定するとmakesOfferよりも優先される
73
- // makesOfferDefault: {
74
- // typeOf: client.factory.offerType.Offer,
75
- // availabilityStarts: moment('2024-05-11T00:00:00.000Z')
76
- // .toDate(),
77
- // availabilityEnds: moment('2024-05-12T00:00:00.000Z')
78
- // .toDate(),
79
- // validFrom: moment('2024-05-11T00:00:00.000Z')
80
- // .toDate(),
81
- // validThrough: moment('2024-05-12T00:00:00.000Z')
82
- // .toDate()
83
- // }
84
- }
85
- }
86
- }
87
- ],
88
- {
89
- locationBranchCode: '10',
90
- superEventId: '7k9ayl8hc',
91
- hasTicketedSeat: true,
92
- typeOf: client.factory.eventType.ScreeningEvent,
93
- disableOverwriteMakesOffer: true,
94
- useExtensibleOffer: false
95
- }
96
- );
97
- console.log('created.');
98
-
99
- await eventService.updateEventsByIdentifier(
100
- [
101
- {
102
- identifier,
103
- doorTime: moment(`${today}T13:00:00Z`)
104
- .toDate(),
105
- startDate: moment(`${today}T13:00:00Z`)
106
- .toDate(),
107
- endDate: moment(`${today}T14:00:00Z`)
108
- .toDate(),
109
- eventStatus: client.factory.eventStatusType.EventScheduled,
110
- additionalProperty: [
111
- { name: ADDITIONAL_PROPERTY_NAME, value: identifier }
112
- ],
113
- maximumPhysicalAttendeeCapacity: 3,
114
- offers: {
115
- unacceptedPaymentMethod: [],
116
- eligibleQuantity: {
117
- maxValue: 6
118
- },
119
- itemOffered: {
120
- id: EVENT_SERVICE_ID
121
- }
122
- }
123
- }
124
- ],
125
- {
126
- typeOf: client.factory.eventType.ScreeningEvent,
127
- disableOverwriteMakesOffer: false
128
- }
129
- );
130
- console.log('updated.');
131
-
132
- }
133
-
134
- main()
135
- .then(() => {
136
- console.log('success!');
137
- })
138
- .catch(console.error);