@cinerino/sdk 12.3.0-alpha.4 → 12.3.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.
@@ -0,0 +1,150 @@
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
+ await eventService.createIfNotExistByIdentifier(
34
+ [
35
+ {
36
+ identifier,
37
+ doorTime: moment(`${today}T13:00:00Z`)
38
+ .toDate(),
39
+ startDate: moment(`${today}T13:00:00Z`)
40
+ .toDate(),
41
+ endDate: moment(`${today}T14:00:00Z`)
42
+ .toDate(),
43
+ eventStatus: client.factory.eventStatusType.EventScheduled,
44
+ additionalProperty: [
45
+ { name: ADDITIONAL_PROPERTY_NAME, value: identifier }
46
+ ],
47
+ maximumPhysicalAttendeeCapacity: 3,
48
+ offers: {
49
+ unacceptedPaymentMethod: [],
50
+ eligibleQuantity: {
51
+ maxValue: 6
52
+ },
53
+ itemOffered: {
54
+ id: EVENT_SERVICE_ID
55
+ },
56
+ seller: {
57
+ makesOffer: [
58
+ {
59
+ typeOf: client.factory.offerType.Offer,
60
+ availableAtOrFrom: { id: AVAILABLE_AT_OR_FROM_ID }, // <-販売アプリケーションIDを指定する
61
+ availabilityStarts: moment(`${today}T00:00:00+09:00`)
62
+ .toDate(),
63
+ availabilityEnds: moment(`${today}T14:00:00Z`)
64
+ .toDate(),
65
+ validFrom: moment(`${today}T00:00:00+09:00`)
66
+ .toDate(),
67
+ validThrough: moment(`${today}T14:00:00Z`)
68
+ .toDate()
69
+ }
70
+ ]
71
+ // makesOfferDefaultを指定するとmakesOfferよりも優先される
72
+ // makesOfferDefault: {
73
+ // typeOf: client.factory.offerType.Offer,
74
+ // availabilityStarts: moment('2024-05-11T00:00:00.000Z')
75
+ // .toDate(),
76
+ // availabilityEnds: moment('2024-05-12T00:00:00.000Z')
77
+ // .toDate(),
78
+ // validFrom: moment('2024-05-11T00:00:00.000Z')
79
+ // .toDate(),
80
+ // validThrough: moment('2024-05-12T00:00:00.000Z')
81
+ // .toDate()
82
+ // }
83
+ }
84
+ }
85
+ }
86
+ ],
87
+ {
88
+ locationBranchCode: '10',
89
+ superEventId: '7k9ayl8hc',
90
+ hasTicketedSeat: true,
91
+ typeOf: client.factory.eventType.ScreeningEvent
92
+ }
93
+ );
94
+ console.log('created.');
95
+
96
+ await eventService.updateEventsByIdentifier(
97
+ [
98
+ {
99
+ identifier,
100
+ doorTime: moment(`${today}T13:00:00Z`)
101
+ .toDate(),
102
+ startDate: moment(`${today}T13:00:00Z`)
103
+ .toDate(),
104
+ endDate: moment(`${today}T14:00:00Z`)
105
+ .toDate(),
106
+ eventStatus: client.factory.eventStatusType.EventScheduled,
107
+ additionalProperty: [
108
+ { name: ADDITIONAL_PROPERTY_NAME, value: identifier }
109
+ ],
110
+ maximumPhysicalAttendeeCapacity: 3,
111
+ offers: {
112
+ unacceptedPaymentMethod: [],
113
+ eligibleQuantity: {
114
+ maxValue: 6
115
+ },
116
+ itemOffered: {
117
+ id: EVENT_SERVICE_ID
118
+ },
119
+ seller: {
120
+ makesOffer: [
121
+ {
122
+ typeOf: client.factory.offerType.Offer,
123
+ availableAtOrFrom: { id: AVAILABLE_AT_OR_FROM_ID }, // <-販売アプリケーションIDを指定する
124
+ availabilityStarts: moment(`${today}T00:00:00+09:00`)
125
+ .toDate(),
126
+ availabilityEnds: moment(`${today}T14:00:00Z`)
127
+ .toDate(),
128
+ validFrom: moment(`${today}T00:00:00+09:00`)
129
+ .toDate(),
130
+ validThrough: moment(`${today}T14:00:00Z`)
131
+ .toDate()
132
+ }
133
+ ]
134
+ }
135
+ }
136
+ }
137
+ ],
138
+ {
139
+ typeOf: client.factory.eventType.ScreeningEvent
140
+ }
141
+ );
142
+ console.log('updated.');
143
+
144
+ }
145
+
146
+ main()
147
+ .then(() => {
148
+ console.log('success!');
149
+ })
150
+ .catch(console.error);
@@ -6,6 +6,7 @@ import { auth } from './auth/clientCredentials';
6
6
  const PROJECT_ID = String(process.env.PROJECT_ID);
7
7
 
8
8
  async function main() {
9
+ const now = new Date();
9
10
  const eventService = new (await client.loadService()).Event({
10
11
  endpoint: <string>process.env.API_ENDPOINT,
11
12
  auth: await auth(),
@@ -17,17 +18,18 @@ async function main() {
17
18
  page: 1,
18
19
  limit: 1,
19
20
  typeOf: client.factory.eventType.ScreeningEvent,
20
- startFrom: new Date(),
21
- startThrough: moment()
21
+ startFrom: now,
22
+ startThrough: moment(now)
22
23
  .add(1, 'days')
23
24
  .toDate(),
24
25
  sort: {
25
26
  startDate: client.factory.sortType.Ascending
26
27
  },
27
- sellerMakesOfferAvailableAtIn: ['xx', 'xxx']
28
+ sellerMakesOfferAvailableAtIn: ['xx', 'xxx'],
29
+ identifiers: ['x', 'x']
28
30
  });
29
31
  // tslint:disable-next-line:no-null-keyword
30
- // console.dir(data.at(0), { depth: null });
32
+ console.dir(data.at(0), { depth: null });
31
33
  // tslint:disable-next-line:no-null-keyword
32
34
  // console.dir(data.at(0)?.offers?.seller.makesOffer, { depth: null });
33
35
  console.log(data.length, 'events');
@@ -3,10 +3,51 @@ 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
+ declare type ICreateParamsByIdentifier = Pick<factory.event.ICreateParams<factory.eventType.ScreeningEvent>, 'additionalProperty' | 'doorTime' | 'endDate' | 'eventStatus' | 'maximumPhysicalAttendeeCapacity' | 'offers' | 'startDate'> & {
7
+ identifier: string;
8
+ offers: Pick<factory.event.screeningEvent.IOffers4create, 'eligibleQuantity' | 'seller' | 'unacceptedPaymentMethod'> & {
9
+ itemOffered: Pick<factory.event.screeningEvent.IItemOffered, 'id'>;
10
+ };
11
+ };
12
+ declare type IUpdateParamsByIdentifier = Pick<factory.event.IUpdateParams<factory.eventType.ScreeningEvent>, 'additionalProperty' | 'doorTime' | 'endDate' | 'eventStatus' | 'maximumPhysicalAttendeeCapacity' | 'offers' | 'startDate'> & {
13
+ identifier: string;
14
+ offers: Pick<factory.event.screeningEvent.IOffers4create, 'eligibleQuantity' | 'seller' | 'unacceptedPaymentMethod'> & {
15
+ itemOffered: Pick<factory.event.screeningEvent.IItemOffered, 'id'>;
16
+ };
17
+ location?: never;
18
+ superEvent?: never;
19
+ };
6
20
  /**
7
21
  * イベントサービス
8
22
  */
9
23
  export declare class EventService extends Service {
24
+ /**
25
+ * イベント冪等複数作成
26
+ * イベントコードをキーにして、存在しなければ作成する
27
+ */
28
+ createIfNotExistByIdentifier(params: ICreateParamsByIdentifier[], options: {
29
+ /**
30
+ * 施設コンテンツID
31
+ */
32
+ superEventId: string;
33
+ /**
34
+ * ルームコード
35
+ */
36
+ locationBranchCode: string;
37
+ /**
38
+ * 座席有無
39
+ */
40
+ hasTicketedSeat: boolean;
41
+ typeOf: factory.eventType.ScreeningEvent;
42
+ }): Promise<void>;
43
+ /**
44
+ * 識別子によるイベント複数更新
45
+ * 識別子のイベントが存在しなければNotFound
46
+ * 座席有無は変更できない
47
+ */
48
+ updateEventsByIdentifier(params: IUpdateParamsByIdentifier[], options: {
49
+ typeOf: factory.eventType.ScreeningEvent;
50
+ }): Promise<void>;
10
51
  /**
11
52
  * イベント冪等複数作成
12
53
  * 特定の追加特性をキーにして、存在しなければ作成する
@@ -63,6 +63,60 @@ var EventService = /** @class */ (function (_super) {
63
63
  function EventService() {
64
64
  return _super !== null && _super.apply(this, arguments) || this;
65
65
  }
66
+ /**
67
+ * イベント冪等複数作成
68
+ * イベントコードをキーにして、存在しなければ作成する
69
+ */
70
+ EventService.prototype.createIfNotExistByIdentifier = function (params, options) {
71
+ return __awaiter(this, void 0, void 0, function () {
72
+ var superEventId, locationBranchCode, hasTicketedSeat, typeOf;
73
+ return __generator(this, function (_a) {
74
+ switch (_a.label) {
75
+ case 0:
76
+ superEventId = options.superEventId, locationBranchCode = options.locationBranchCode, hasTicketedSeat = options.hasTicketedSeat, typeOf = options.typeOf;
77
+ return [4 /*yield*/, this.fetch({
78
+ uri: '/events',
79
+ method: 'POST',
80
+ body: params,
81
+ qs: { superEventId: superEventId, locationBranchCode: locationBranchCode, hasTicketedSeat: hasTicketedSeat, typeOf: typeOf },
82
+ expectedStatusCodes: [http_status_1.NO_CONTENT]
83
+ })];
84
+ case 1:
85
+ _a.sent();
86
+ return [2 /*return*/];
87
+ }
88
+ });
89
+ });
90
+ };
91
+ /**
92
+ * 識別子によるイベント複数更新
93
+ * 識別子のイベントが存在しなければNotFound
94
+ * 座席有無は変更できない
95
+ */
96
+ EventService.prototype.updateEventsByIdentifier = function (params, options) {
97
+ return __awaiter(this, void 0, void 0, function () {
98
+ var typeOf;
99
+ return __generator(this, function (_a) {
100
+ switch (_a.label) {
101
+ case 0:
102
+ typeOf = options.typeOf;
103
+ return [4 /*yield*/, this.fetch({
104
+ uri: '/events',
105
+ method: 'PUT',
106
+ body: params,
107
+ qs: {
108
+ typeOf: typeOf,
109
+ updateBy: 'identifier'
110
+ },
111
+ expectedStatusCodes: [http_status_1.NO_CONTENT]
112
+ })];
113
+ case 1:
114
+ _a.sent();
115
+ return [2 /*return*/];
116
+ }
117
+ });
118
+ });
119
+ };
66
120
  /**
67
121
  * イベント冪等複数作成
68
122
  * 特定の追加特性をキーにして、存在しなければ作成する
package/lib/bundle.js CHANGED
@@ -2569,6 +2569,60 @@ var EventService = /** @class */ (function (_super) {
2569
2569
  function EventService() {
2570
2570
  return _super !== null && _super.apply(this, arguments) || this;
2571
2571
  }
2572
+ /**
2573
+ * イベント冪等複数作成
2574
+ * イベントコードをキーにして、存在しなければ作成する
2575
+ */
2576
+ EventService.prototype.createIfNotExistByIdentifier = function (params, options) {
2577
+ return __awaiter(this, void 0, void 0, function () {
2578
+ var superEventId, locationBranchCode, hasTicketedSeat, typeOf;
2579
+ return __generator(this, function (_a) {
2580
+ switch (_a.label) {
2581
+ case 0:
2582
+ superEventId = options.superEventId, locationBranchCode = options.locationBranchCode, hasTicketedSeat = options.hasTicketedSeat, typeOf = options.typeOf;
2583
+ return [4 /*yield*/, this.fetch({
2584
+ uri: '/events',
2585
+ method: 'POST',
2586
+ body: params,
2587
+ qs: { superEventId: superEventId, locationBranchCode: locationBranchCode, hasTicketedSeat: hasTicketedSeat, typeOf: typeOf },
2588
+ expectedStatusCodes: [http_status_1.NO_CONTENT]
2589
+ })];
2590
+ case 1:
2591
+ _a.sent();
2592
+ return [2 /*return*/];
2593
+ }
2594
+ });
2595
+ });
2596
+ };
2597
+ /**
2598
+ * 識別子によるイベント複数更新
2599
+ * 識別子のイベントが存在しなければNotFound
2600
+ * 座席有無は変更できない
2601
+ */
2602
+ EventService.prototype.updateEventsByIdentifier = function (params, options) {
2603
+ return __awaiter(this, void 0, void 0, function () {
2604
+ var typeOf;
2605
+ return __generator(this, function (_a) {
2606
+ switch (_a.label) {
2607
+ case 0:
2608
+ typeOf = options.typeOf;
2609
+ return [4 /*yield*/, this.fetch({
2610
+ uri: '/events',
2611
+ method: 'PUT',
2612
+ body: params,
2613
+ qs: {
2614
+ typeOf: typeOf,
2615
+ updateBy: 'identifier'
2616
+ },
2617
+ expectedStatusCodes: [http_status_1.NO_CONTENT]
2618
+ })];
2619
+ case 1:
2620
+ _a.sent();
2621
+ return [2 /*return*/];
2622
+ }
2623
+ });
2624
+ });
2625
+ };
2572
2626
  /**
2573
2627
  * イベント冪等複数作成
2574
2628
  * 特定の追加特性をキーにして、存在しなければ作成する
@@ -30730,35 +30784,8 @@ var RoleName;
30730
30784
  })(RoleName = exports.RoleName || (exports.RoleName = {}));
30731
30785
 
30732
30786
  },{}],335:[function(require,module,exports){
30733
- "use strict";
30734
- Object.defineProperty(exports, "__esModule", { value: true });
30735
- // export interface ISchedule4ttts extends Pick<IEventWithSchedule, 'id' | 'offers' | 'project' | 'superEvent'> {
30736
- // eventSchedule?: never;
30737
- // duration: number;
30738
- // noPerformanceTimes: string[];
30739
- // /**
30740
- // * 作成対象時間: 9,10,11など
30741
- // */
30742
- // hours: string[];
30743
- // /**
30744
- // * ['00', '15', '30', '45']
30745
- // */
30746
- // minutes: string[];
30747
- // /**
30748
- // * ['1', '2', '3', '4']
30749
- // */
30750
- // tours: string[];
30751
- // /**
30752
- // * 作成開始が今日から何日後か
30753
- // */
30754
- // // start: number;
30755
- // /**
30756
- // * 何日分作成するか
30757
- // */
30758
- // days: number;
30759
- // }
30760
-
30761
- },{}],336:[function(require,module,exports){
30787
+ arguments[4][34][0].apply(exports,arguments)
30788
+ },{"dup":34}],336:[function(require,module,exports){
30762
30789
  arguments[4][34][0].apply(exports,arguments)
30763
30790
  },{"dup":34}],337:[function(require,module,exports){
30764
30791
  arguments[4][34][0].apply(exports,arguments)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cinerino/sdk",
3
- "version": "12.3.0-alpha.4",
3
+ "version": "12.3.0-alpha.5",
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": "4.398.0-alpha.3",
96
+ "@chevre/factory": "4.398.0-alpha.6",
97
97
  "debug": "3.2.7",
98
98
  "http-status": "1.7.4",
99
99
  "idtoken-verifier": "2.0.3",