@tripian/core 1.0.0 → 4.0.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,21 +1,21 @@
1
- import { AxiosError } from 'axios';
2
- import Model from '@tripian/model';
3
- /**
4
- * All successfully (axios response status code) resolved promises firstly handles by this function. easy.log calling.
5
- * If dataKey exist and httpResponse.data.success is true, httpResponse.data.data is saving to tripian.data[dataKey]
6
- * @param {AxiosResponse} httpResponse axios response object
7
- * @param {string} dataKey
8
- * @returns {any} httpResponse.data axios httpResponse.data
9
- */
10
- declare const handleHttpResponseSuccess: <T>(httpResponse: Model.SuccessResponse<T>, dataKey: string, params?: any) => Model.DataPayload<T>;
11
- /**
12
- * All failed (axios response status code) promises firstly handles by this function.
13
- * setting tripian.data.hasError to true
14
- * easy.log calling.
15
- * If dataKey exist (and dataKey !== 'trip') and httpResponse.data.success is true, httpResponse.data.data is saving to tripian.data[dataKey]
16
- * @param {AxiosError} errorResponse is axios error response object
17
- * @param {string} dataKey
18
- * @returns {AxiosError} errorResponse is axios error response object
19
- */
20
- declare const handleHttpResponseError: (errorResponse: AxiosError<Model.ErrorResponse>, dataKey: string, params?: any) => never;
21
- export { handleHttpResponseSuccess, handleHttpResponseError };
1
+ import { AxiosError } from 'axios';
2
+ import Model from '@tripian/model';
3
+ /**
4
+ * All successfully (axios response status code) resolved promises firstly handles by this function. easy.log calling.
5
+ * If dataKey exist and httpResponse.data.success is true, httpResponse.data.data is saving to tripian.data[dataKey]
6
+ * @param {AxiosResponse} httpResponse axios response object
7
+ * @param {string} dataKey
8
+ * @returns {any} httpResponse.data axios httpResponse.data
9
+ */
10
+ declare const handleHttpResponseSuccess: <T>(httpResponse: Model.SuccessResponse<T>, dataKey: string, params?: any) => Model.DataPayload<T>;
11
+ /**
12
+ * All failed (axios response status code) promises firstly handles by this function.
13
+ * setting tripian.data.hasError to true
14
+ * easy.log calling.
15
+ * If dataKey exist (and dataKey !== 'trip') and httpResponse.data.success is true, httpResponse.data.data is saving to tripian.data[dataKey]
16
+ * @param {AxiosError} errorResponse is axios error response object
17
+ * @param {string} dataKey
18
+ * @returns {AxiosError} errorResponse is axios error response object
19
+ */
20
+ declare const handleHttpResponseError: (errorResponse: AxiosError<Model.ErrorResponse>, dataKey: string, params?: any) => never;
21
+ export { handleHttpResponseSuccess, handleHttpResponseError };
package/index.d.ts CHANGED
@@ -1,40 +1,43 @@
1
- import Model, { Providers } from '@tripian/model';
2
- import random from './Random';
3
- import data from './data/data';
4
- import API from './api/API';
5
- import ProvidersYelpAPI from './providers/yelp/API';
6
- import ProvidersGlxAPI from './providers/glx/API';
7
- import ProvidersGygAPI from './providers/gyg/API';
8
- /**
9
- * Env
10
- */
11
- declare const ENV: {
12
- DEV: {
13
- url: string;
14
- xApiKey: string;
15
- };
16
- TEST: {
17
- url: string;
18
- xApiKey: string;
19
- };
20
- PROD: {
21
- url: string;
22
- xApiKey: string;
23
- };
24
- };
25
- declare let api: API;
26
- /**
27
- * This function initilize for web sdk.
28
- */
29
- declare const init: (url: string, xApiKey: string, token?: Model.Token | undefined, useCahce?: boolean) => void;
30
- interface IProviders {
31
- yelp?: ProvidersYelpAPI;
32
- glx?: ProvidersGlxAPI;
33
- gyg?: ProvidersGygAPI;
34
- yelpInit: (sandbox?: boolean) => void;
35
- glxInit: () => Promise<Providers.Glx.Token>;
36
- gygInit: () => void;
37
- }
38
- declare const providers: IProviders;
39
- declare const ver: string;
40
- export { ver, random, data, api, init, ENV, providers };
1
+ import Model, { Providers } from '@tripian/model';
2
+ import random from './Random';
3
+ import data from './data/data';
4
+ import API from './api/API';
5
+ import ProvidersYelpAPI from './providers/yelp/API';
6
+ import ProvidersGlxAPI from './providers/glx/API';
7
+ import ProvidersGygAPI from './providers/gyg/API';
8
+ import ProvidersBbAPI from './providers/bb/API';
9
+ /**
10
+ * Env
11
+ */
12
+ declare const ENV: {
13
+ DEV: {
14
+ url: string;
15
+ xApiKey: string;
16
+ };
17
+ TEST: {
18
+ url: string;
19
+ xApiKey: string;
20
+ };
21
+ PROD: {
22
+ url: string;
23
+ xApiKey: string;
24
+ };
25
+ };
26
+ declare let api: API;
27
+ /**
28
+ * This function initilize for web sdk.
29
+ */
30
+ declare const init: (url: string, xApiKey: string, token?: Model.Token | undefined, useCahce?: boolean) => void;
31
+ declare type Providers = {
32
+ yelp?: ProvidersYelpAPI;
33
+ glx?: ProvidersGlxAPI;
34
+ gyg?: ProvidersGygAPI;
35
+ bb?: ProvidersBbAPI;
36
+ yelpInit: (sandbox?: boolean) => void;
37
+ glxInit: () => Promise<Providers.Glx.Token>;
38
+ gygInit: (sandbox?: boolean) => void;
39
+ bbInit: (sandbox?: boolean) => Promise<void>;
40
+ };
41
+ declare const providers: Providers;
42
+ declare const ver: string;
43
+ export { ver, random, data, api, init, ENV, providers };
package/index.html CHANGED
@@ -1,115 +1,115 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Tripian Web Core Test</title>
7
- <!-- <script src="https://unpkg.com/@tripian/core@latest/tcore.umd.js"></script> -->
8
- <script src="tcore.umd.js"></script>
9
- </head>
10
- <body></body>
11
- <script>
12
- const url = tcore.ENV.DEV.url; // 'https://fgzpwfdoy1.execute-api.eu-west-1.amazonaws.com/api'
13
- const xApiKey = tcore.ENV.DEV.xApiKey; // 'oPkgR28N5W1xmZs705Lhf72HnZjj4q2p6KySXuyb'
14
-
15
- // const url = tcore.ENV.PROD.url; // 'https://0gke6jmyse.execute-api.eu-west-1.amazonaws.com/api'
16
- // const xApiKey = tcore.ENV.PROD.xApiKey; // '7cq5PBc7Qd2dKkbkTP7Gj3uecDODPtof8CZ3pLNZ'
17
-
18
- // (url: string, xApiKey: string, token?: Model.Token, useCahce: boolean = true)
19
- tcore.init(url, xApiKey, undefined, true);
20
-
21
- // Cities
22
- // tcore.api.citiesAll().then((cities) => console.log('cities', cities));
23
-
24
- // Register
25
- // tcore.api
26
- // .register({
27
- // email: '35@35.com',
28
- // first_name: 'Otuz',
29
- // last_name: 'Beş',
30
- // password: 'Tripian*123',
31
- // profile: {
32
- // age: 18,
33
- // answers: [],
34
- // },
35
- // })
36
- // .then(() => {
37
- // Login
38
- tcore.api.login({ email: '35@35.com', password: 'Tripian*123' }).then(() => {
39
- // User Trips
40
- tcore.api.tripRefs().then((tripRefs) => {
41
- console.log('tripRefs', tripRefs);
42
- // User Trips is not empty
43
- if (tripRefs.length > 0) {
44
- // First Trip Data
45
- tcore.api.trip(tripRefs[0].trip_hash).then((trip) => {
46
- console.log('trip', trip);
47
- // Trip City Top 10 Pois
48
- tcore.api.topTen(tripRefs[0].city.id).then((topTenArray) => {
49
- if (topTenArray.length > 0) console.log('topTen', topTenArray[0].top_ten_poi);
50
- });
51
- });
52
- }
53
- });
54
- });
55
- // });
56
-
57
- /* Yelp Test
58
- tcore.providers.yelpInit(undefined, false);
59
- tcore.providers.yelp.bussiness('gR9DTbKCvezQlqvD7_FzPw').then((bussiness) => {
60
- console.log('html yelp bussiness', bussiness);
61
- tcore.providers.yelp.openings('rC5mIHMNF5C1Jtpb2obSkA', '2020-06-15', '12:00', 2).then((openings) => {
62
- console.log('html yelp openings', openings);
63
- tcore.providers.yelp.hold('rC5mIHMNF5C1Jtpb2obSkA', '2020-06-15', '12:00', 2, 'unique_mi_unique').then((hold) => {
64
- console.log('html yelp hold', hold);
65
- tcore.providers.yelp
66
- .reservation(
67
- 'rC5mIHMNF5C1Jtpb2obSkA',
68
- '2020-06-15',
69
- '12:00',
70
- 2,
71
- 'unique_mi_unique',
72
- hold.hold_id,
73
- 'Cenan',
74
- 'Yunusoglu',
75
- 'cenan@tripian.com',
76
- '+1-555-66-777',
77
- )
78
- .then((reservation) => {
79
- console.log('html yelp reservation', reservation);
80
- });
81
- });
82
- });
83
- });
84
- */
85
-
86
- // tcore.init(tcore.ENV.PROD.url, tcore.ENV.PROD.xApiKey);
87
- // tcore.api.login({ email: 'umut@tripian.com', password: 'tripiaN123' }).then(() => {
88
- // tcore.api.trip('f106b4e6dd8148778dd70f552965f686').then(() => {
89
- // tcore.api.trip('f106b4e6dd8148778dd70f552965f686').then(() => {
90
- // console.log('trip');
91
- // console.log(tcore.data.trip.plans[0].steps);
92
-
93
- // tcore.api.stepAdd({ plan_id: plan_id, poi_id: add_poi }).then(() => {
94
- // console.log('stepAdd');
95
- // console.log(tcore.data.trip.plans[0].steps);
96
-
97
- // newStepId = tcore.data.trip.plans[0].steps[tcore.data.trip.plans[0].steps.length - 1].id;
98
-
99
- // tcore.api.stepReplace(newStepId, { poi_id: update_poi }).then(() => {
100
- // console.log('stepReplace');
101
- // console.log(tcore.data.trip.plans[0].steps);
102
-
103
- // tcore.api.stepDelete(newStepId).then(() => {
104
- // console.log('stepDelete');
105
- // console.log(tcore.data.trip.plans[0].steps);
106
-
107
- // console.log('son');
108
- // });
109
- // });
110
- // });
111
- // });
112
- // });
113
- // });
114
- </script>
115
- </html>
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Tripian Web Core Test</title>
7
+ <!-- <script src="https://unpkg.com/@tripian/core@latest/tcore.umd.js"></script> -->
8
+ <script src="tcore.umd.js"></script>
9
+ </head>
10
+ <body></body>
11
+ <script>
12
+ const url = tcore.ENV.DEV.url; // 'https://fgzpwfdoy1.execute-api.eu-west-1.amazonaws.com/api'
13
+ const xApiKey = tcore.ENV.DEV.xApiKey; // 'oPkgR28N5W1xmZs705Lhf72HnZjj4q2p6KySXuyb'
14
+
15
+ // const url = tcore.ENV.PROD.url; // 'https://0gke6jmyse.execute-api.eu-west-1.amazonaws.com/api'
16
+ // const xApiKey = tcore.ENV.PROD.xApiKey; // '7cq5PBc7Qd2dKkbkTP7Gj3uecDODPtof8CZ3pLNZ'
17
+
18
+ // (url: string, xApiKey: string, token?: Model.Token, useCahce: boolean = true)
19
+ tcore.init(url, xApiKey, undefined, true);
20
+
21
+ // Cities
22
+ // tcore.api.citiesAll().then((cities) => console.log('cities', cities));
23
+
24
+ // Register
25
+ // tcore.api
26
+ // .register({
27
+ // email: '35@35.com',
28
+ // first_name: 'Otuz',
29
+ // last_name: 'Beş',
30
+ // password: 'Tripian*123',
31
+ // profile: {
32
+ // age: 18,
33
+ // answers: [],
34
+ // },
35
+ // })
36
+ // .then(() => {
37
+ // Login
38
+ tcore.api.login({ email: '35@35.com', password: 'Tripian*123' }).then(() => {
39
+ // User Trips
40
+ tcore.api.tripRefs().then((tripRefs) => {
41
+ console.log('tripRefs', tripRefs);
42
+ // User Trips is not empty
43
+ if (tripRefs.length > 0) {
44
+ // First Trip Data
45
+ tcore.api.trip(tripRefs[0].trip_hash).then((trip) => {
46
+ console.log('trip', trip);
47
+ // Trip City Top 10 Pois
48
+ tcore.api.topTen(tripRefs[0].city.id).then((topTenArray) => {
49
+ if (topTenArray.length > 0) console.log('topTen', topTenArray[0].top_ten_poi);
50
+ });
51
+ });
52
+ }
53
+ });
54
+ });
55
+ // });
56
+
57
+ /* Yelp Test
58
+ tcore.providers.yelpInit(undefined, false);
59
+ tcore.providers.yelp.bussiness('gR9DTbKCvezQlqvD7_FzPw').then((bussiness) => {
60
+ console.log('html yelp bussiness', bussiness);
61
+ tcore.providers.yelp.openings('rC5mIHMNF5C1Jtpb2obSkA', '2020-06-15', '12:00', 2).then((openings) => {
62
+ console.log('html yelp openings', openings);
63
+ tcore.providers.yelp.hold('rC5mIHMNF5C1Jtpb2obSkA', '2020-06-15', '12:00', 2, 'unique_mi_unique').then((hold) => {
64
+ console.log('html yelp hold', hold);
65
+ tcore.providers.yelp
66
+ .reservation(
67
+ 'rC5mIHMNF5C1Jtpb2obSkA',
68
+ '2020-06-15',
69
+ '12:00',
70
+ 2,
71
+ 'unique_mi_unique',
72
+ hold.hold_id,
73
+ 'Cenan',
74
+ 'Yunusoglu',
75
+ 'cenan@tripian.com',
76
+ '+1-555-66-777',
77
+ )
78
+ .then((reservation) => {
79
+ console.log('html yelp reservation', reservation);
80
+ });
81
+ });
82
+ });
83
+ });
84
+ */
85
+
86
+ // tcore.init(tcore.ENV.PROD.url, tcore.ENV.PROD.xApiKey);
87
+ // tcore.api.login({ email: 'umut@tripian.com', password: 'tripiaN123' }).then(() => {
88
+ // tcore.api.trip('f106b4e6dd8148778dd70f552965f686').then(() => {
89
+ // tcore.api.trip('f106b4e6dd8148778dd70f552965f686').then(() => {
90
+ // console.log('trip');
91
+ // console.log(tcore.data.trip.plans[0].steps);
92
+
93
+ // tcore.api.stepAdd({ plan_id: plan_id, poi_id: add_poi }).then(() => {
94
+ // console.log('stepAdd');
95
+ // console.log(tcore.data.trip.plans[0].steps);
96
+
97
+ // newStepId = tcore.data.trip.plans[0].steps[tcore.data.trip.plans[0].steps.length - 1].id;
98
+
99
+ // tcore.api.stepReplace(newStepId, { poi_id: update_poi }).then(() => {
100
+ // console.log('stepReplace');
101
+ // console.log(tcore.data.trip.plans[0].steps);
102
+
103
+ // tcore.api.stepDelete(newStepId).then(() => {
104
+ // console.log('stepDelete');
105
+ // console.log(tcore.data.trip.plans[0].steps);
106
+
107
+ // console.log('son');
108
+ // });
109
+ // });
110
+ // });
111
+ // });
112
+ // });
113
+ // });
114
+ </script>
115
+ </html>