@cinerino/sdk 3.70.0 → 3.73.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.
@@ -3381,7 +3381,7 @@ var TaskName;
3381
3381
  */
3382
3382
  TaskName["DeleteMember"] = "deleteMember";
3383
3383
  /**
3384
- * ポイントインセンティブ付与
3384
+ * ポイント特典付与
3385
3385
  */
3386
3386
  TaskName["GivePointAward"] = "givePointAward";
3387
3387
  /**
@@ -3401,7 +3401,7 @@ var TaskName;
3401
3401
  */
3402
3402
  TaskName["ReturnMoneyTransfer"] = "returnMoneyTransfer";
3403
3403
  /**
3404
- * ポイントインセンティブ返却
3404
+ * ポイント特典返却
3405
3405
  */
3406
3406
  TaskName["ReturnPointAward"] = "returnPointAward";
3407
3407
  /**
@@ -25,7 +25,7 @@ async function main() {
25
25
  typeOf: client.factory.assetTransactionType.MoneyTransfer,
26
26
  transactionNumber: transactionNumber,
27
27
  project: { typeOf: client.factory.organizationType.Project, id: project.id },
28
- agent: { typeOf: 'Person', name: 'Agent' },
28
+ agent: { typeOf: client.factory.personType.Person, name: 'Agent', id: 'id' },
29
29
  recipient: { typeOf: client.factory.personType.Person, name: 'Recipient', id: 'id' },
30
30
  object: {
31
31
  amount: {
@@ -38,7 +38,12 @@ async function main() {
38
38
  project: { typeOf: client.factory.organizationType.Project, id: project.id },
39
39
  typeOf: client.factory.assetTransactionType.Refund,
40
40
  transactionNumber: transactionNumber,
41
- agent: { typeOf: seller.typeOf, name: seller.name, id: seller.id },
41
+ agent: {
42
+ typeOf: seller.typeOf,
43
+ name: (<client.factory.multilingualString>seller.name)?.ja,
44
+ id: seller.id,
45
+ project: { typeOf: client.factory.organizationType.Project, id: project.id }
46
+ },
42
47
  recipient: { typeOf: client.factory.personType.Person, name: 'サンプル決済者名称', id: 'id' },
43
48
  object: {
44
49
  typeOf: client.factory.service.paymentService.PaymentServiceType.CreditCard,
package/lib/bundle.js CHANGED
@@ -3421,7 +3421,7 @@ var TaskName;
3421
3421
  */
3422
3422
  TaskName["DeleteMember"] = "deleteMember";
3423
3423
  /**
3424
- * ポイントインセンティブ付与
3424
+ * ポイント特典付与
3425
3425
  */
3426
3426
  TaskName["GivePointAward"] = "givePointAward";
3427
3427
  /**
@@ -3441,7 +3441,7 @@ var TaskName;
3441
3441
  */
3442
3442
  TaskName["ReturnMoneyTransfer"] = "returnMoneyTransfer";
3443
3443
  /**
3444
- * ポイントインセンティブ返却
3444
+ * ポイント特典返却
3445
3445
  */
3446
3446
  TaskName["ReturnPointAward"] = "returnPointAward";
3447
3447
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cinerino/sdk",
3
- "version": "3.70.0",
3
+ "version": "3.73.0",
4
4
  "description": "Cinerino SDK",
5
5
  "main": "./lib/index.js",
6
6
  "browser": {
@@ -97,7 +97,7 @@
97
97
  "watchify": "^3.11.1"
98
98
  },
99
99
  "dependencies": {
100
- "@cinerino/api-abstract-client": "3.70.0",
100
+ "@cinerino/api-abstract-client": "3.73.0",
101
101
  "debug": "^3.2.6",
102
102
  "http-status": "^1.4.2",
103
103
  "idtoken-verifier": "^2.0.3",
@@ -1,170 +0,0 @@
1
- // tslint:disable:no-console no-implicit-dependencies
2
- /**
3
- * イベントステータス更新
4
- */
5
- import * as moment from 'moment';
6
- import * as pug from 'pug';
7
- import * as client from '../../lib/index';
8
- import * as auth from './auth/authAsAdmin';
9
-
10
- const project = { id: 'cinerino' };
11
-
12
- async function main() {
13
- const authClient = await auth.login();
14
- await authClient.refreshAccessToken();
15
- const loginTicket = authClient.verifyIdToken({});
16
- console.log('username is', loginTicket.getUsername());
17
-
18
- const eventService = new client.service.Event({
19
- endpoint: <string>process.env.API_ENDPOINT,
20
- auth: authClient,
21
- project
22
- });
23
- const emailMessageService = new client.service.EmailMessage({
24
- endpoint: <string>process.env.API_ENDPOINT,
25
- auth: authClient,
26
- project
27
- });
28
- const orderService = new client.service.Order({
29
- endpoint: <string>process.env.API_ENDPOINT,
30
- auth: authClient,
31
- project
32
- });
33
-
34
- const searchEmailMessagesResult = await emailMessageService.search({
35
- limit: 1,
36
- page: 1,
37
- about: { identifier: { $eq: client.factory.creativeWork.message.email.AboutIdentifier.OnEventStatusChanged } }
38
- });
39
- const emailMessageOnCanceled = searchEmailMessagesResult.data.shift();
40
- if (emailMessageOnCanceled === undefined) {
41
- throw new Error('Eメールメッセージテンプレートが見つかりません');
42
- }
43
-
44
- const eventId = 'akrdohgg7';
45
- const eventStatus = client.factory.eventStatusType.EventCancelled;
46
- // const eventStatus = client.factory.eventStatusType.EventScheduled;
47
- // Eメールカスタムテキスト
48
- const notice = 'カスタムテキスト';
49
-
50
- let sendEmailMessageParams: client.factory.action.transfer.send.message.email.IAttributes[] = [];
51
-
52
- if (eventStatus === client.factory.eventStatusType.EventCancelled) {
53
- // イベントに対する注文検索
54
- const searchOrdersResult = await orderService.search({
55
- // project: { id: { $eq: req.project?.id } },
56
- acceptedOffers: {
57
- itemOffered: {
58
- // アイテムが予約
59
- typeOf: { $in: [client.factory.reservationType.EventReservation] },
60
- // 予約対象イベント
61
- reservationFor: { ids: [eventId] }
62
- }
63
- },
64
- // 返品済は除く
65
- orderStatuses: [client.factory.orderStatus.OrderDelivered, client.factory.orderStatus.OrderProcessing]
66
- });
67
- const orders = searchOrdersResult.data;
68
- sendEmailMessageParams = await Promise.all(orders.map(async (order) => {
69
- return createEmail(order, notice, emailMessageOnCanceled);
70
- }));
71
- }
72
-
73
- await eventService.updateEventStatus({
74
- id: eventId,
75
- eventStatus: eventStatus,
76
- onUpdated: {
77
- sendEmailMessage: sendEmailMessageParams
78
- }
79
- });
80
-
81
- }
82
-
83
- async function createEmail(
84
- order: client.factory.order.IOrder,
85
- notice: string,
86
- emailMessageOnCanceled: client.factory.creativeWork.message.email.ICreativeWork
87
- ): Promise<client.factory.action.transfer.send.message.email.IAttributes> {
88
- const content = await new Promise<string>((resolve, reject) => {
89
- pug.render(
90
- emailMessageOnCanceled.text,
91
- {
92
- // moment使う場合
93
- moment,
94
- // order変数使える
95
- order,
96
- // カスタムテキスト変数使える
97
- notice
98
- },
99
- (err, message) => {
100
- if (err instanceof Error) {
101
- reject(new client.factory.errors.Argument('emailTemplate', err.message));
102
-
103
- return;
104
- }
105
-
106
- resolve(message);
107
- }
108
- );
109
- });
110
-
111
- // メール作成
112
- const emailMessage: client.factory.creativeWork.message.email.ICreativeWork = {
113
- typeOf: client.factory.creativeWorkType.EmailMessage,
114
- identifier: `updateEventStatus-${order.orderNumber}`,
115
- name: `updateEventStatus-${order.orderNumber}`,
116
- sender: {
117
- typeOf: order.seller.typeOf,
118
- name: emailMessageOnCanceled.sender.name,
119
- email: emailMessageOnCanceled.sender.email
120
- },
121
- toRecipient: {
122
- typeOf: order.customer.typeOf,
123
- name: String(order.customer.name),
124
- email: String(order.customer.email)
125
- },
126
- about: {
127
- typeOf: 'Thing',
128
- identifier: emailMessageOnCanceled.about.identifier,
129
- name: emailMessageOnCanceled.about.name
130
- },
131
- text: content
132
- };
133
-
134
- const purpose = {
135
- project: { typeOf: order.project.typeOf, id: order.project.id },
136
- typeOf: order.typeOf,
137
- seller: order.seller,
138
- customer: order.customer,
139
- confirmationNumber: order.confirmationNumber,
140
- orderNumber: order.orderNumber,
141
- price: order.price,
142
- priceCurrency: order.priceCurrency,
143
- orderDate: moment(order.orderDate)
144
- .toDate()
145
- };
146
-
147
- const recipient: any = {
148
- id: order.customer.id,
149
- name: emailMessage.toRecipient.name,
150
- typeOf: order.customer.typeOf
151
- };
152
-
153
- return {
154
- typeOf: client.factory.actionType.SendAction,
155
- agent: {
156
- typeOf: client.factory.personType.Person,
157
- id: ''
158
- },
159
- object: emailMessage,
160
- project: { typeOf: order.project.typeOf, id: order.project.id },
161
- purpose: purpose,
162
- recipient
163
- };
164
- }
165
-
166
- main()
167
- .then(() => {
168
- console.log('success!');
169
- })
170
- .catch(console.error);