@cinerino/sdk 12.3.0-alpha.5 → 12.3.0-alpha.6

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,103 @@
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
+
6
+ const PROJECT_ID = String(process.env.PROJECT_ID);
7
+ const SELLER_ID = '5a392dfdfca1c8737fb6da42';
8
+ const EVENT_SERVICE_ID = '630b139e4dd0621c0496a30c';
9
+ const AVAILABLE_AT_OR_FROM_ID = '51qbjcfr72h62m06vtv5kkhgje';
10
+ const ADDITIONAL_PROPERTY_NAME = 'oldEventId';
11
+ const SUPER_EVENT_ID = '7kaf1djmz';
12
+ const LOCATION_BRANCH_CODE = '01';
13
+
14
+ // tslint:disable-next-line:max-func-body-length
15
+ async function main() {
16
+ const authClient = await client.auth.ClientCredentials.createInstance({
17
+ domain: <string>process.env.CHEVRE_AUTHORIZE_SERVER_DOMAIN,
18
+ clientId: <string>process.env.CHEVRE_CLIENT_ID,
19
+ clientSecret: <string>process.env.CHEVRE_CLIENT_SECRET,
20
+ scopes: [],
21
+ state: ''
22
+ });
23
+
24
+ const eventService = await (await client.loadChevreAdmin({
25
+ endpoint: <string>process.env.CHEVRE_ENDPOINT,
26
+ auth: authClient
27
+ })).createEventInstance({
28
+ project: { id: PROJECT_ID },
29
+ seller: { id: SELLER_ID }
30
+ });
31
+
32
+ const today = moment()
33
+ .tz('Asia/Tokyo')
34
+ .format('YYYY-MM-DD');
35
+ const identifier = '250909001001010900';
36
+ await eventService.createIfNotExistByIdentifier(
37
+ [
38
+ {
39
+ identifier,
40
+ doorTime: moment(`${today}T13:00:00Z`)
41
+ .toDate(),
42
+ startDate: moment(`${today}T13:00:00Z`)
43
+ .toDate(),
44
+ endDate: moment(`${today}T14:00:00Z`)
45
+ .toDate(),
46
+ eventStatus: client.factory.eventStatusType.EventScheduled,
47
+ additionalProperty: [
48
+ { name: ADDITIONAL_PROPERTY_NAME, value: identifier }
49
+ ],
50
+ offers: {
51
+ unacceptedPaymentMethod: [],
52
+ eligibleQuantity: {
53
+ maxValue: 6
54
+ },
55
+ itemOffered: {
56
+ id: EVENT_SERVICE_ID
57
+ },
58
+ seller: {
59
+ makesOffer: [
60
+ {
61
+ typeOf: client.factory.offerType.Offer,
62
+ availableAtOrFrom: { id: AVAILABLE_AT_OR_FROM_ID }, // <-販売アプリケーションIDを指定する
63
+ availabilityStarts: moment(`${today}T00:00:00+09:00`)
64
+ .toDate(),
65
+ availabilityEnds: moment(`${today}T14:00:00Z`)
66
+ .toDate(),
67
+ validFrom: moment(`${today}T00:00:00+09:00`)
68
+ .toDate(),
69
+ validThrough: moment(`${today}T14:00:00Z`)
70
+ .toDate()
71
+ }
72
+ ]
73
+ // makesOfferDefaultを指定するとmakesOfferよりも優先される
74
+ // makesOfferDefault: {
75
+ // typeOf: client.factory.offerType.Offer,
76
+ // availabilityStarts: moment('2024-05-11T00:00:00.000Z')
77
+ // .toDate(),
78
+ // availabilityEnds: moment('2024-05-12T00:00:00.000Z')
79
+ // .toDate(),
80
+ // validFrom: moment('2024-05-11T00:00:00.000Z')
81
+ // .toDate(),
82
+ // validThrough: moment('2024-05-12T00:00:00.000Z')
83
+ // .toDate()
84
+ // }
85
+ }
86
+ }
87
+ }
88
+ ],
89
+ {
90
+ locationBranchCode: LOCATION_BRANCH_CODE,
91
+ superEventId: SUPER_EVENT_ID,
92
+ hasTicketedSeat: true,
93
+ typeOf: client.factory.eventType.ScreeningEvent
94
+ }
95
+ );
96
+ console.log('created.');
97
+ }
98
+
99
+ main()
100
+ .then(() => {
101
+ console.log('success!');
102
+ })
103
+ .catch(console.error);
@@ -0,0 +1,102 @@
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
+ import { auth } from '../../auth/clientCredentials';
7
+
8
+ const PROJECT_ID = String(process.env.PROJECT_ID);
9
+ const SELLER_ID = '5a392dfdfca1c8737fb6da42';
10
+ const EVENT_SERVICE_ID = '630b139e4dd0621c0496a30c';
11
+ const AVAILABLE_AT_OR_FROM_ID = '51qbjcfr72h62m06vtv5kkhgje';
12
+ const ADDITIONAL_PROPERTY_NAME = 'oldEventId';
13
+ const SUPER_EVENT_ID = '7kaf1djmz';
14
+ const LOCATION_BRANCH_CODE = '01';
15
+
16
+ // tslint:disable-next-line:max-func-body-length
17
+ async function main() {
18
+ // const authClient = await auth.login();
19
+ // await authClient.refreshAccessToken();
20
+ // const loginTicket = authClient.verifyIdToken({});
21
+ // console.log('username is', loginTicket.getUsername());
22
+
23
+ const eventService = await (await client.loadCloudAdmin({
24
+ endpoint: <string>process.env.API_ADMIN_ENDPOINT,
25
+ auth: await auth()
26
+ })).createEventInstance({
27
+ project: { id: PROJECT_ID },
28
+ seller: { id: SELLER_ID }
29
+ });
30
+
31
+ const today = moment()
32
+ .tz('Asia/Tokyo')
33
+ .format('YYYY-MM-DD');
34
+ const identifier = '250909001001010900';
35
+ await eventService.createIfNotExistByIdentifier(
36
+ [
37
+ {
38
+ identifier,
39
+ doorTime: moment(`${today}T13:00:00Z`)
40
+ .toDate(),
41
+ startDate: moment(`${today}T13:00:00Z`)
42
+ .toDate(),
43
+ endDate: moment(`${today}T14:00:00Z`)
44
+ .toDate(),
45
+ eventStatus: client.factory.eventStatusType.EventScheduled,
46
+ additionalProperty: [
47
+ { name: ADDITIONAL_PROPERTY_NAME, value: identifier }
48
+ ],
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: LOCATION_BRANCH_CODE,
90
+ superEventId: SUPER_EVENT_ID,
91
+ hasTicketedSeat: true,
92
+ typeOf: client.factory.eventType.ScreeningEvent
93
+ }
94
+ );
95
+ console.log('created.');
96
+ }
97
+
98
+ main()
99
+ .then(() => {
100
+ console.log('success!');
101
+ })
102
+ .catch(console.error);
@@ -14,9 +14,9 @@ async function main() {
14
14
  seller: { id: '' }
15
15
  });
16
16
  const orders = await orderService.findByConfirmationNumber({
17
- confirmationNumber: '96678',
17
+ confirmationNumber: '74441',
18
18
  customer: {
19
- telephone: '+819012345678'
19
+ telephone: '+819011111111'
20
20
  }
21
21
  });
22
22
  // tslint:disable-next-line:no-null-keyword
@@ -3,13 +3,13 @@ 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'> & {
6
+ export declare type ICreateParamsByIdentifier = Pick<factory.event.ICreateParams<factory.eventType.ScreeningEvent>, 'additionalProperty' | 'doorTime' | 'endDate' | 'eventStatus' | 'maximumPhysicalAttendeeCapacity' | 'offers' | 'startDate'> & {
7
7
  identifier: string;
8
8
  offers: Pick<factory.event.screeningEvent.IOffers4create, 'eligibleQuantity' | 'seller' | 'unacceptedPaymentMethod'> & {
9
9
  itemOffered: Pick<factory.event.screeningEvent.IItemOffered, 'id'>;
10
10
  };
11
11
  };
12
- declare type IUpdateParamsByIdentifier = Pick<factory.event.IUpdateParams<factory.eventType.ScreeningEvent>, 'additionalProperty' | 'doorTime' | 'endDate' | 'eventStatus' | 'maximumPhysicalAttendeeCapacity' | 'offers' | 'startDate'> & {
12
+ export declare type IUpdateParamsByIdentifier = Pick<factory.event.IUpdateParams<factory.eventType.ScreeningEvent>, 'additionalProperty' | 'doorTime' | 'endDate' | 'eventStatus' | 'maximumPhysicalAttendeeCapacity' | 'offers' | 'startDate'> & {
13
13
  identifier: string;
14
14
  offers: Pick<factory.event.screeningEvent.IOffers4create, 'eligibleQuantity' | 'seller' | 'unacceptedPaymentMethod'> & {
15
15
  itemOffered: Pick<factory.event.screeningEvent.IItemOffered, 'id'>;
@@ -136,8 +136,8 @@ export declare namespace service {
136
136
  * 管理サービス
137
137
  */
138
138
  export declare class ChevreAdmin {
139
- options: Pick<IOptions, 'auth' | 'endpoint'>;
140
- constructor(options: Pick<IOptions, 'auth' | 'endpoint'>);
139
+ options: Pick<IOptions, 'auth' | 'endpoint' | 'disableAutoRetry'>;
140
+ constructor(options: Pick<IOptions, 'auth' | 'endpoint' | 'disableAutoRetry'>);
141
141
  createAuthorizationInstance(params: Pick<IOptions, 'project'> & Pick<IAdditionalOptions, 'seller'>): Promise<AuthorizationService>;
142
142
  createCreativeWorkInstance(params: Pick<IOptions, 'project'> & Pick<IAdditionalOptions, 'seller'>): Promise<CreativeWorkService>;
143
143
  createCustomerInstance(params: Pick<IOptions, 'project'> & Pick<IAdditionalOptions, 'seller'>): Promise<CustomerService>;
@@ -1,5 +1,6 @@
1
1
  import * as factory from '../../factory';
2
2
  import { Service } from '../../service';
3
+ import { ICreateParamsByIdentifier, IUpdateParamsByIdentifier } from '../../chevreAdmin/event';
3
4
  declare type ISendEmailMessageOnEventUpdated = Pick<factory.action.transfer.send.message.email.IAttributes, 'purpose' | 'recipient'> & {
4
5
  object: factory.action.transfer.send.message.email.IObjectAsEmailMessage;
5
6
  };
@@ -23,6 +24,33 @@ declare type ICreateScreeningEventParams = Omit<factory.event.ICreateParams<fact
23
24
  * イベントサービス
24
25
  */
25
26
  export declare class EventService extends Service {
27
+ /**
28
+ * イベント冪等複数作成
29
+ * イベントコードをキーにして、存在しなければ作成する
30
+ */
31
+ createIfNotExistByIdentifier(params: ICreateParamsByIdentifier[], options: {
32
+ /**
33
+ * 施設コンテンツID
34
+ */
35
+ superEventId: string;
36
+ /**
37
+ * ルームコード
38
+ */
39
+ locationBranchCode: string;
40
+ /**
41
+ * 座席有無
42
+ */
43
+ hasTicketedSeat: boolean;
44
+ typeOf: factory.eventType.ScreeningEvent;
45
+ }): Promise<void>;
46
+ /**
47
+ * 識別子によるイベント複数更新
48
+ * 識別子のイベントが存在しなければNotFound
49
+ * 座席有無は変更できない
50
+ */
51
+ updateEventsByIdentifier(params: IUpdateParamsByIdentifier[], options: {
52
+ typeOf: factory.eventType.ScreeningEvent;
53
+ }): Promise<void>;
26
54
  /**
27
55
  * イベント冪等複数作成
28
56
  * 特定の追加特性をキーにして、存在しなければ作成する
@@ -93,6 +93,63 @@ var EventService = /** @class */ (function (_super) {
93
93
  function EventService() {
94
94
  return _super !== null && _super.apply(this, arguments) || this;
95
95
  }
96
+ /**
97
+ * イベント冪等複数作成
98
+ * イベントコードをキーにして、存在しなければ作成する
99
+ */
100
+ EventService.prototype.createIfNotExistByIdentifier = function (params, options) {
101
+ return __awaiter(this, void 0, void 0, function () {
102
+ var _a, auth, endpoint, project, seller, chevreAdmin, eventService;
103
+ return __generator(this, function (_b) {
104
+ switch (_b.label) {
105
+ case 0:
106
+ _a = this.options, auth = _a.auth, endpoint = _a.endpoint, project = _a.project, seller = _a.seller;
107
+ return [4 /*yield*/, index_1.loadChevreAdmin({ auth: auth, endpoint: endpoint })];
108
+ case 1:
109
+ chevreAdmin = _b.sent();
110
+ return [4 /*yield*/, chevreAdmin.createEventInstance({
111
+ project: project,
112
+ seller: { id: (typeof (seller === null || seller === void 0 ? void 0 : seller.id) === 'string') ? seller.id : '' }
113
+ })];
114
+ case 2:
115
+ eventService = _b.sent();
116
+ return [4 /*yield*/, eventService.createIfNotExistByIdentifier(params, options)];
117
+ case 3:
118
+ _b.sent();
119
+ return [2 /*return*/];
120
+ }
121
+ });
122
+ });
123
+ };
124
+ /**
125
+ * 識別子によるイベント複数更新
126
+ * 識別子のイベントが存在しなければNotFound
127
+ * 座席有無は変更できない
128
+ */
129
+ EventService.prototype.updateEventsByIdentifier = function (params, options) {
130
+ return __awaiter(this, void 0, void 0, function () {
131
+ var _a, auth, endpoint, project, seller, disableAutoRetry, chevreAdmin, eventService;
132
+ return __generator(this, function (_b) {
133
+ switch (_b.label) {
134
+ case 0:
135
+ _a = this.options, auth = _a.auth, endpoint = _a.endpoint, project = _a.project, seller = _a.seller, disableAutoRetry = _a.disableAutoRetry;
136
+ return [4 /*yield*/, index_1.loadChevreAdmin({ auth: auth, endpoint: endpoint, disableAutoRetry: disableAutoRetry })];
137
+ case 1:
138
+ chevreAdmin = _b.sent();
139
+ return [4 /*yield*/, chevreAdmin.createEventInstance({
140
+ project: project,
141
+ seller: { id: (typeof (seller === null || seller === void 0 ? void 0 : seller.id) === 'string') ? seller.id : '' }
142
+ })];
143
+ case 2:
144
+ eventService = _b.sent();
145
+ return [4 /*yield*/, eventService.updateEventsByIdentifier(params, options)];
146
+ case 3:
147
+ _b.sent();
148
+ return [2 /*return*/];
149
+ }
150
+ });
151
+ });
152
+ };
96
153
  /**
97
154
  * イベント冪等複数作成
98
155
  * 特定の追加特性をキーにして、存在しなければ作成する
@@ -102,8 +102,8 @@ export declare namespace service {
102
102
  * 管理サービス
103
103
  */
104
104
  export declare class CloudAdmin {
105
- options: Pick<IOptions, 'auth' | 'endpoint'>;
106
- constructor(options: Pick<IOptions, 'auth' | 'endpoint'>);
105
+ options: Pick<IOptions, 'auth' | 'endpoint' | 'disableAutoRetry'>;
106
+ constructor(options: Pick<IOptions, 'auth' | 'endpoint' | 'disableAutoRetry'>);
107
107
  createCreativeWorkInstance(params: Pick<IOptions, 'project'> & Pick<IAdditionalOptions, 'seller'>): Promise<CreativeWorkService>;
108
108
  createCustomerInstance(params: Pick<IOptions, 'project'> & Pick<IAdditionalOptions, 'seller'>): Promise<CustomerService>;
109
109
  createEventInstance(params: Pick<IOptions, 'project'> & Pick<IAdditionalOptions, 'seller'>): Promise<EventService>;
package/lib/bundle.js CHANGED
@@ -20827,6 +20827,63 @@ var EventService = /** @class */ (function (_super) {
20827
20827
  function EventService() {
20828
20828
  return _super !== null && _super.apply(this, arguments) || this;
20829
20829
  }
20830
+ /**
20831
+ * イベント冪等複数作成
20832
+ * イベントコードをキーにして、存在しなければ作成する
20833
+ */
20834
+ EventService.prototype.createIfNotExistByIdentifier = function (params, options) {
20835
+ return __awaiter(this, void 0, void 0, function () {
20836
+ var _a, auth, endpoint, project, seller, chevreAdmin, eventService;
20837
+ return __generator(this, function (_b) {
20838
+ switch (_b.label) {
20839
+ case 0:
20840
+ _a = this.options, auth = _a.auth, endpoint = _a.endpoint, project = _a.project, seller = _a.seller;
20841
+ return [4 /*yield*/, index_1.loadChevreAdmin({ auth: auth, endpoint: endpoint })];
20842
+ case 1:
20843
+ chevreAdmin = _b.sent();
20844
+ return [4 /*yield*/, chevreAdmin.createEventInstance({
20845
+ project: project,
20846
+ seller: { id: (typeof (seller === null || seller === void 0 ? void 0 : seller.id) === 'string') ? seller.id : '' }
20847
+ })];
20848
+ case 2:
20849
+ eventService = _b.sent();
20850
+ return [4 /*yield*/, eventService.createIfNotExistByIdentifier(params, options)];
20851
+ case 3:
20852
+ _b.sent();
20853
+ return [2 /*return*/];
20854
+ }
20855
+ });
20856
+ });
20857
+ };
20858
+ /**
20859
+ * 識別子によるイベント複数更新
20860
+ * 識別子のイベントが存在しなければNotFound
20861
+ * 座席有無は変更できない
20862
+ */
20863
+ EventService.prototype.updateEventsByIdentifier = function (params, options) {
20864
+ return __awaiter(this, void 0, void 0, function () {
20865
+ var _a, auth, endpoint, project, seller, disableAutoRetry, chevreAdmin, eventService;
20866
+ return __generator(this, function (_b) {
20867
+ switch (_b.label) {
20868
+ case 0:
20869
+ _a = this.options, auth = _a.auth, endpoint = _a.endpoint, project = _a.project, seller = _a.seller, disableAutoRetry = _a.disableAutoRetry;
20870
+ return [4 /*yield*/, index_1.loadChevreAdmin({ auth: auth, endpoint: endpoint, disableAutoRetry: disableAutoRetry })];
20871
+ case 1:
20872
+ chevreAdmin = _b.sent();
20873
+ return [4 /*yield*/, chevreAdmin.createEventInstance({
20874
+ project: project,
20875
+ seller: { id: (typeof (seller === null || seller === void 0 ? void 0 : seller.id) === 'string') ? seller.id : '' }
20876
+ })];
20877
+ case 2:
20878
+ eventService = _b.sent();
20879
+ return [4 /*yield*/, eventService.updateEventsByIdentifier(params, options)];
20880
+ case 3:
20881
+ _b.sent();
20882
+ return [2 /*return*/];
20883
+ }
20884
+ });
20885
+ });
20886
+ };
20830
20887
  /**
20831
20888
  * イベント冪等複数作成
20832
20889
  * 特定の追加特性をキーにして、存在しなければ作成する
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cinerino/sdk",
3
- "version": "12.3.0-alpha.5",
3
+ "version": "12.3.0-alpha.6",
4
4
  "description": "Cinerino SDK",
5
5
  "main": "./lib/index.js",
6
6
  "browser": {