@tripian/core 4.6.0 → 5.0.2

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,79 +1,79 @@
1
- import Model from '@tripian/model';
2
- /**
3
- *
4
- * Cities
5
- *
6
- */
7
- export declare const cityCached: (cities: Model.City[], id: number) => Model.City | undefined;
8
- export declare const citiesConcat: (cities: Model.City[], newCities: Model.City[]) => Model.City[] | undefined;
9
- /**
10
- *
11
- * POI
12
- *
13
- */
14
- export declare const poiCached: (pois: Model.Poi[], id: number) => Model.Poi | undefined;
15
- export declare const poisConcat: (pois: Model.Poi[], newPois: Model.Poi[]) => Model.Poi[];
16
- /**
17
- ******************************************************************************
18
- *
19
- * Questions
20
- *
21
- */
22
- export declare const questionCached: (questions: Model.Question[], id: number) => Model.Question | undefined;
23
- export declare const questionsConcat: (questions: Model.Question[], newQuestions: Model.Question[]) => Model.Question[];
24
- /**
25
- *
26
- * Trip Refs
27
- *
28
- */
29
- export declare const tripRefCached: (tripRefs: Model.TripReference[], id: number) => Model.TripReference | undefined;
30
- export declare const tripRefsConcatOne: (tripRefs: Model.TripReference[], newTripRef: Model.TripReference) => Model.TripReference[] | undefined;
31
- /**
32
- *
33
- * Trips
34
- *
35
- */
36
- export declare const tripCached: (trips: Model.Trip[], id: number) => Model.Trip | undefined;
37
- export declare const tripsConcatOne: (trips: Model.Trip[], newTrip: Model.Trip) => Model.Trip[];
38
- /**
39
- *
40
- * Plan
41
- *
42
- */
43
- export declare const planUpdated: (updatedPlan: Model.Plan, trip?: Model.Trip) => Model.Trip | undefined;
44
- /**
45
- *
46
- * Step
47
- *
48
- */
49
- export declare const stepAdded: (planId: number, addedStep: Model.Step, trip?: Model.Trip) => Model.Trip | undefined;
50
- export declare const stepUpdated: (updatedStep: Model.Step, trip?: Model.Trip) => Model.Trip | undefined;
51
- export declare const stepDeleted: (deletedStepId: number, trip?: Model.Trip) => Model.Trip | undefined;
52
- /**
53
- *
54
- * Companions
55
- *
56
- */
57
- export declare const favoriteCached: (favorites: Model.Favorite[], id: number) => Model.Favorite | undefined;
58
- export declare const favoriteConcatOne: (favorites: Model.Favorite[], newFavorite: Model.Favorite) => Model.Favorite[];
59
- /**
60
- *
61
- * Companions
62
- *
63
- */
64
- export declare const companionCached: (companions: Model.Companion[], id: number) => Model.Companion | undefined;
65
- export declare const companionConcatOne: (companions: Model.Companion[], newCompanion: Model.Companion) => Model.Companion[] | undefined;
66
- /**
67
- *
68
- * Reservations
69
- *
70
- */
71
- export declare const reservationCached: (reservations: Model.UserReservation[], id: number) => Model.UserReservation | undefined;
72
- export declare const reservationConcatOne: (reservations: Model.UserReservation[], newReservation: Model.UserReservation) => Model.UserReservation[];
73
- /**
74
- *
75
- * Reactions
76
- *
77
- */
78
- export declare const reactionCached: (reactions: Model.UserReaction[], id: number) => Model.UserReaction | undefined;
79
- export declare const reactionConcatOne: (reactions: Model.UserReaction[], newReaction: Model.UserReaction) => Model.UserReaction[];
1
+ import Model from '@tripian/model';
2
+ /**
3
+ *
4
+ * Cities
5
+ *
6
+ */
7
+ export declare const cityCached: (cities: Model.City[], id: number) => Model.City | undefined;
8
+ export declare const citiesConcat: (cities: Model.City[], newCities: Model.City[]) => Model.City[] | undefined;
9
+ /**
10
+ *
11
+ * POI
12
+ *
13
+ */
14
+ export declare const poiCached: (pois: Model.Poi[], id: number) => Model.Poi | undefined;
15
+ export declare const poisConcat: (pois: Model.Poi[], newPois: Model.Poi[]) => Model.Poi[];
16
+ /**
17
+ ******************************************************************************
18
+ *
19
+ * Questions
20
+ *
21
+ */
22
+ export declare const questionCached: (questions: Model.Question[], id: number) => Model.Question | undefined;
23
+ export declare const questionsConcat: (questions: Model.Question[], newQuestions: Model.Question[]) => Model.Question[];
24
+ /**
25
+ *
26
+ * Trip Refs
27
+ *
28
+ */
29
+ export declare const tripRefCached: (tripRefs: Model.TripReference[], id: number) => Model.TripReference | undefined;
30
+ export declare const tripRefsConcatOne: (tripRefs: Model.TripReference[], newTripRef: Model.TripReference) => Model.TripReference[] | undefined;
31
+ /**
32
+ *
33
+ * Trips
34
+ *
35
+ */
36
+ export declare const tripCached: (trips: Model.Trip[], id: number) => Model.Trip | undefined;
37
+ export declare const tripsConcatOne: (trips: Model.Trip[], newTrip: Model.Trip) => Model.Trip[];
38
+ /**
39
+ *
40
+ * Plan
41
+ *
42
+ */
43
+ export declare const planUpdated: (updatedPlan: Model.Plan, trip?: Model.Trip) => Model.Trip | undefined;
44
+ /**
45
+ *
46
+ * Step
47
+ *
48
+ */
49
+ export declare const stepAdded: (planId: number, addedStep: Model.Step, trip?: Model.Trip) => Model.Trip | undefined;
50
+ export declare const stepUpdated: (updatedStep: Model.Step, trip?: Model.Trip) => Model.Trip | undefined;
51
+ export declare const stepDeleted: (deletedStepId: number, trip?: Model.Trip) => Model.Trip | undefined;
52
+ /**
53
+ *
54
+ * Companions
55
+ *
56
+ */
57
+ export declare const favoriteCached: (favorites: Model.Favorite[], id: number) => Model.Favorite | undefined;
58
+ export declare const favoriteConcatOne: (favorites: Model.Favorite[], newFavorite: Model.Favorite) => Model.Favorite[];
59
+ /**
60
+ *
61
+ * Companions
62
+ *
63
+ */
64
+ export declare const companionCached: (companions: Model.Companion[], id: number) => Model.Companion | undefined;
65
+ export declare const companionConcatOne: (companions: Model.Companion[], newCompanion: Model.Companion) => Model.Companion[] | undefined;
66
+ /**
67
+ *
68
+ * Reservations
69
+ *
70
+ */
71
+ export declare const reservationCached: (reservations: Model.UserReservation[], id: number) => Model.UserReservation | undefined;
72
+ export declare const reservationConcatOne: (reservations: Model.UserReservation[], newReservation: Model.UserReservation) => Model.UserReservation[];
73
+ /**
74
+ *
75
+ * Reactions
76
+ *
77
+ */
78
+ export declare const reactionCached: (reactions: Model.UserReaction[], id: number) => Model.UserReaction | undefined;
79
+ export declare const reactionConcatOne: (reactions: Model.UserReaction[], newReaction: Model.UserReaction) => Model.UserReaction[];
@@ -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,43 +1,36 @@
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, 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 };
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 easy from './easy/easy';
6
+ import ProvidersYelpAPI from './providers/yelp/API';
7
+ import ProvidersGlxAPI from './providers/glx/API';
8
+ import ProvidersGygAPI from './providers/gyg/API';
9
+ import ProvidersBbAPI from './providers/bb/API';
10
+ /**
11
+ * Env
12
+ */
13
+ declare const ENV: {
14
+ DEV: {
15
+ url: string;
16
+ xApiKey: string;
17
+ };
18
+ };
19
+ declare let api: API;
20
+ /**
21
+ * This function initilize for web sdk.
22
+ */
23
+ declare const init: (url: string, xApiKey: string, token?: Model.Token, useCahce?: boolean) => void;
24
+ declare type Providers = {
25
+ yelp?: ProvidersYelpAPI;
26
+ glx?: ProvidersGlxAPI;
27
+ gyg?: ProvidersGygAPI;
28
+ bb?: ProvidersBbAPI;
29
+ yelpInit: (sandbox?: boolean) => void;
30
+ glxInit: () => Promise<Providers.Glx.Token>;
31
+ gygInit: (sandbox?: boolean) => void;
32
+ bbInit: (sandbox?: boolean) => Promise<void>;
33
+ };
34
+ declare const providers: Providers;
35
+ declare const ver: string;
36
+ export { ver, random, data, api, init, easy, 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>