@cinerino/sdk 3.104.0-alpha.1 → 3.104.0-alpha.4

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.
@@ -203,7 +203,7 @@ async function main() {
203
203
  value: '12345'
204
204
  }],
205
205
  // email: '',
206
- familyName: 'Motion',
206
+ familyName: 'SDK',
207
207
  gender: 'Female',
208
208
  givenName: 'Taro',
209
209
  telephone: '+819012345678'
@@ -0,0 +1,154 @@
1
+ // tslint:disable:no-console no-implicit-dependencies no-magic-numbers
2
+ import * as moment from 'moment';
3
+ import * as client from '../../../../lib/index';
4
+ import * as auth from '../../auth/authAsAdmin';
5
+
6
+ const project = { id: process.env.PROJECT_ID };
7
+
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
+
16
+ export type IAuthorizeReservationAction
17
+ = client.factory.action.authorize.offer.seatReservation.IAction<client.factory.service.webAPI.Identifier.Chevre>;
18
+
19
+ // tslint:disable-next-line:max-func-body-length
20
+ async function main() {
21
+ const authClient = await auth.login();
22
+ await authClient.refreshAccessToken();
23
+ const loginTicket = authClient.verifyIdToken({});
24
+ console.log('username is', loginTicket.getUsername());
25
+
26
+ const sellerService = new client.chevre.service.Seller({
27
+ endpoint: <string>process.env.CHEVRE_ENDPOINT,
28
+ auth: authClient,
29
+ project
30
+ });
31
+ const placeOrderService = new client.chevre.service.transaction.PlaceOrder({
32
+ endpoint: <string>process.env.CHEVRE_ENDPOINT,
33
+ auth: authClient,
34
+ project
35
+ });
36
+
37
+ console.log('finding profile...');
38
+ // const profile = await personService.getProfile({ personId: 'me' });
39
+ console.log('profile found');
40
+
41
+ // 販売劇場検索
42
+ const searchSellersResult = await sellerService.search({});
43
+ // tslint:disable-next-line:insecure-random
44
+ const seller = searchSellersResult.data[Math.floor(searchSellersResult.data.length * Math.random())];
45
+ if (seller === undefined) {
46
+ throw new Error('No seller');
47
+ }
48
+ console.log('ordering from seller...', (<client.factory.multilingualString>seller.name).ja);
49
+
50
+ console.log('starting transaction...');
51
+ const transaction = await placeOrderService.start({
52
+ expires: moment()
53
+ .add(10, 'minutes')
54
+ .toDate(),
55
+ agent: {
56
+ identifier: [
57
+ {
58
+ name: 'SampleName',
59
+ value: 'SampleValue'
60
+ },
61
+ ...(typeof process.env.LINE_NOTIFY_URL === 'string' && process.env.LINE_NOTIFY_URL.length > 0)
62
+ ? [
63
+ {
64
+ name: 'onOrderPlaced.recipient.url',
65
+ value: process.env.LINE_NOTIFY_URL
66
+ },
67
+ {
68
+ name: 'onOrderPlaced.object.customer.identifier',
69
+ value: 'onOrderPlaced.object.customer.identifier.value1'
70
+ },
71
+ {
72
+ name: 'onOrderPlaced.object.customer.identifier',
73
+ value: 'onOrderPlaced.object.customer.identifier.value2'
74
+ }
75
+
76
+ ]
77
+ : []
78
+ ]
79
+ },
80
+ seller: {
81
+ typeOf: seller.typeOf,
82
+ id: String(seller.id)
83
+ },
84
+ object: {
85
+ // passport: { token: passportToken }
86
+ }
87
+ });
88
+ console.log('transaction started', transaction.id);
89
+
90
+ // 購入者情報入力時間
91
+ // tslint:disable-next-line:no-magic-numbers
92
+ await wait(5000);
93
+
94
+ const settingProfile: client.factory.person.IProfile = {
95
+ givenName: 'Taro',
96
+ familyName: 'SDK',
97
+ telephone: '+819012345678',
98
+ email: profile.email
99
+ };
100
+ console.log('setting customer profile...');
101
+ await placeOrderService.setProfile({ id: transaction.id, agent: settingProfile });
102
+ console.log('customer profile set');
103
+
104
+ // let i = 0;
105
+ // setInterval(
106
+ // async () => {
107
+ // i += 1;
108
+ // try {
109
+ // console.log('setting customer profile...');
110
+ // await placeOrderService.setProfile({ id: transaction.id, agent: settingProfile });
111
+ // console.log('customer profile set');
112
+
113
+ // } catch (error) {
114
+ // console.error('setting profile failed.', error.message);
115
+ // }
116
+ // },
117
+ // // tslint:disable-next-line:no-magic-numbers
118
+ // 500
119
+ // );
120
+
121
+ // return;
122
+
123
+ // 購入情報確認時間
124
+ // tslint:disable-next-line:no-magic-numbers
125
+ await wait(5000);
126
+
127
+ const publishOrderNumberReulst = await placeOrderService.publishOrderNumberIfNotExist({ id: transaction.id });
128
+ console.log(publishOrderNumberReulst.orderNumber);
129
+
130
+ // 取引を中止する場合はコチラ↓
131
+ // console.log('取引を中止します...');
132
+ // await placeOrderService.cancel({ id: transaction.id });
133
+ // console.log('取引を中止しました。');
134
+
135
+ console.log('confirming transaction...');
136
+ const confirmResult = await placeOrderService.confirm({
137
+ id: transaction.id,
138
+ sendEmailMessage: true
139
+ // expectsReservationIds: true
140
+ });
141
+ const order = confirmResult.order;
142
+ console.log('transaction confirmed', confirmResult);
143
+ console.log('transaction confirmed', order.orderNumber);
144
+ }
145
+
146
+ async function wait(waitInMilliseconds: number) {
147
+ return new Promise((resolve) => setTimeout(resolve, waitInMilliseconds));
148
+ }
149
+
150
+ main()
151
+ .then(() => {
152
+ console.log('success!');
153
+ })
154
+ .catch(console.error);
@@ -9,8 +9,8 @@ const project = { id: 'cinerino' };
9
9
  const profile = {
10
10
  email: <string>process.env.TEST_PROFILE_EMAIL,
11
11
  givenName: 'Taro',
12
- familyName: 'Motion',
13
- name: 'Taro ☆ Motion',
12
+ familyName: 'SDK',
13
+ name: 'Taro ☆ SDK',
14
14
  telephone: '+819012345678'
15
15
  };
16
16
 
@@ -9,8 +9,8 @@ const project = { id: 'cinerino' };
9
9
  const profile = {
10
10
  email: <string>process.env.TEST_PROFILE_EMAIL,
11
11
  givenName: 'Taro',
12
- familyName: 'Motion',
13
- name: 'Taro ☆ Motion',
12
+ familyName: 'SDK',
13
+ name: 'Taro ☆ SDK',
14
14
  telephone: '+819012345678'
15
15
  };
16
16
 
@@ -9,8 +9,8 @@ const project = { id: 'cinerino' };
9
9
  const profile = {
10
10
  email: <string>process.env.TEST_PROFILE_EMAIL,
11
11
  givenName: 'Taro',
12
- familyName: 'Motion',
13
- name: 'Taro ☆ Motion',
12
+ familyName: 'SDK',
13
+ name: 'Taro ☆ SDK',
14
14
  telephone: '+819012345678'
15
15
  };
16
16
 
@@ -124,8 +124,8 @@ async function main() {
124
124
  const profile = {
125
125
  email: '',
126
126
  givenName: 'Taro',
127
- familyName: 'Motion',
128
- name: 'Taro ☆ Motion',
127
+ familyName: 'SDK',
128
+ name: 'Taro ☆ SDK',
129
129
  telephone: '+819012345678'
130
130
  };
131
131
  await placeOrderService.setProfile({
@@ -132,8 +132,8 @@ async function main() {
132
132
  const profile = {
133
133
  email: '',
134
134
  givenName: 'Taro',
135
- familyName: 'Motion',
136
- name: 'Taro ☆ Motion',
135
+ familyName: 'SDK',
136
+ name: 'Taro ☆ SDK',
137
137
  telephone: '+819012345678'
138
138
  };
139
139
  await placeOrderService.setProfile({
@@ -9,8 +9,8 @@ const projectId = 'cinerino';
9
9
  const profile = {
10
10
  email: <string>process.env.TEST_PROFILE_EMAIL,
11
11
  givenName: 'Taro',
12
- familyName: 'Motion',
13
- name: 'Taro ☆ Motion',
12
+ familyName: 'SDK',
13
+ name: 'Taro ☆ SDK',
14
14
  telephone: '+819012345678'
15
15
  };
16
16
 
@@ -9,8 +9,8 @@ const project = { id: 'cinerino' };
9
9
  const profile = {
10
10
  email: <string>process.env.TEST_PROFILE_EMAIL,
11
11
  givenName: 'Taro',
12
- familyName: 'Motion',
13
- name: 'Taro ☆ Motion',
12
+ familyName: 'SDK',
13
+ name: 'Taro ☆ SDK',
14
14
  telephone: '+819012345678'
15
15
  };
16
16
 
@@ -9,8 +9,8 @@ const project = { id: 'cinerino' };
9
9
  const profile = {
10
10
  email: <string>process.env.TEST_PROFILE_EMAIL,
11
11
  givenName: 'Taro',
12
- familyName: 'Motion',
13
- name: 'Taro ☆ Motion',
12
+ familyName: 'SDK',
13
+ name: 'Taro ☆ SDK',
14
14
  telephone: '+819012345678'
15
15
  };
16
16
 
@@ -9,8 +9,8 @@ const project = { id: 'cinerino' };
9
9
  const profile = {
10
10
  email: <string>process.env.TEST_PROFILE_EMAIL,
11
11
  givenName: 'Taro',
12
- familyName: 'Motion',
13
- name: 'Taro ☆ Motion',
12
+ familyName: 'SDK',
13
+ name: 'Taro ☆ SDK',
14
14
  telephone: '+819012345678'
15
15
  };
16
16
 
@@ -9,8 +9,8 @@ const project = { id: 'cinerino' };
9
9
  const profile = {
10
10
  email: <string>process.env.TEST_PROFILE_EMAIL,
11
11
  givenName: 'Taro',
12
- familyName: 'Motion',
13
- name: 'Taro ☆ Motion',
12
+ familyName: 'SDK',
13
+ name: 'Taro ☆ SDK',
14
14
  telephone: '+819012345678'
15
15
  };
16
16
 
@@ -301,7 +301,7 @@ async function main() {
301
301
  id: transaction.id,
302
302
  agent: {
303
303
  givenName: 'Taro',
304
- familyName: 'Motion',
304
+ familyName: 'SDK',
305
305
  telephone: '+819012345678',
306
306
  email: profile.email
307
307
  }
@@ -15,8 +15,8 @@ const creditCard = {
15
15
  const profile = {
16
16
  email: <string>process.env.TEST_PROFILE_EMAIL,
17
17
  givenName: 'Taro',
18
- familyName: 'Motion',
19
- name: 'Taro ☆ Motion',
18
+ familyName: 'SDK',
19
+ name: 'Taro ☆ SDK',
20
20
  telephone: '+819012345678'
21
21
  };
22
22
 
@@ -432,7 +432,7 @@ async function main() {
432
432
  id: transaction.id,
433
433
  agent: {
434
434
  givenName: 'Taro',
435
- familyName: 'Motion',
435
+ familyName: 'SDK',
436
436
  telephone: '+819012345678',
437
437
  email: profile.email
438
438
  }
@@ -10,8 +10,8 @@ const project = { id: 'sskts-development' };
10
10
  const profile = {
11
11
  email: <string>process.env.TEST_PROFILE_EMAIL,
12
12
  givenName: 'Taro',
13
- familyName: 'Motion',
14
- name: 'Taro ☆ Motion',
13
+ familyName: 'SDK',
14
+ name: 'Taro ☆ SDK',
15
15
  telephone: '+819012345678'
16
16
  };
17
17
 
@@ -9,8 +9,8 @@ const projectId = 'cinerino';
9
9
  const profile = {
10
10
  email: <string>process.env.TEST_PROFILE_EMAIL,
11
11
  givenName: 'Taro',
12
- familyName: 'Motion',
13
- name: 'Taro ☆ Motion',
12
+ familyName: 'SDK',
13
+ name: 'Taro ☆ SDK',
14
14
  telephone: '+819012345678'
15
15
  };
16
16