@open-tender/cloud 0.5.11 → 0.5.13

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.
@@ -107,9 +107,9 @@ declare class OpenTenderAPI {
107
107
  postUnsubscribeByKey(key: string): Promise<unknown>;
108
108
  postSignUp(data: CustomerCreate): Promise<Customer | null | undefined>;
109
109
  postCustomerSignIn(data: CustomerSignIn): Promise<void | Auth | null | undefined>;
110
- postThanxLogin(email: string, origin?: string): Promise<unknown>;
110
+ postThanxLogin(email: string, origin?: string, recaptcha_token?: string): Promise<unknown>;
111
111
  postThanxAuth(code: string, path: string, origin?: string): Promise<unknown>;
112
- postLogin(email: string, password: string): Promise<unknown>;
112
+ postLogin(email: string, password: string, recaptcha_token?: string): Promise<unknown>;
113
113
  postLogout(token: string): Promise<unknown>;
114
114
  postSendPasswordResetEmail(email: string, link_url: string): Promise<unknown>;
115
115
  postResetPassword(new_password: string, token: string): Promise<unknown>;
@@ -527,8 +527,10 @@ class OpenTenderAPI {
527
527
  postCustomerSignIn(data) {
528
528
  return this.request(`/customer/sign-in`, 'POST', data);
529
529
  }
530
- postThanxLogin(email, origin) {
531
- const data = origin ? { email, origin } : { email };
530
+ postThanxLogin(email, origin, recaptcha_token) {
531
+ const data = origin
532
+ ? { email, origin, recaptcha_token }
533
+ : { email, recaptcha_token };
532
534
  return this.request('/thanx-login', 'POST', data);
533
535
  }
534
536
  postThanxAuth(code, path, origin) {
@@ -536,11 +538,12 @@ class OpenTenderAPI {
536
538
  const withOrigin = origin ? Object.assign(Object.assign({}, data), { origin }) : data;
537
539
  return this.request('/thanx-auth', 'POST', withOrigin);
538
540
  }
539
- postLogin(email, password) {
541
+ postLogin(email, password, recaptcha_token) {
540
542
  const data = {
541
543
  grant_type: 'password',
542
544
  username: email,
543
- password: password
545
+ password: password,
546
+ recaptcha_token
544
547
  };
545
548
  return this.authRequest('/token', data);
546
549
  }
@@ -85,6 +85,7 @@ export declare const sendCustomerVerificationEmail: import("@reduxjs/toolkit").A
85
85
  export declare const loginCustomerThanx: import("@reduxjs/toolkit").AsyncThunk<void, {
86
86
  email: string;
87
87
  origin?: string | undefined;
88
+ recaptcha_token?: string | undefined;
88
89
  }, {
89
90
  state: AppState;
90
91
  rejectValue: RequestError;
@@ -78,10 +78,10 @@ exports.fetchCustomer = (0, toolkit_1.createAsyncThunk)(AccountActionType.FetchC
78
78
  return (0, exports.checkAuth)(error, dispatch, () => rejectWithValue(error));
79
79
  }
80
80
  }));
81
- exports.loginCustomer = (0, toolkit_1.createAsyncThunk)(AccountActionType.LoginCustomer, ({ email, password }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
81
+ exports.loginCustomer = (0, toolkit_1.createAsyncThunk)(AccountActionType.LoginCustomer, ({ email, password, recaptcha_token }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
82
82
  try {
83
83
  const api = getState().config.api;
84
- const auth = yield api.postLogin(email, password);
84
+ const auth = yield api.postLogin(email, password, recaptcha_token);
85
85
  dispatch((0, exports.setCustomerAuth)(auth));
86
86
  yield dispatch((0, exports.fetchCustomer)());
87
87
  return;
@@ -175,10 +175,10 @@ exports.sendCustomerVerificationEmail = (0, toolkit_1.createAsyncThunk)(AccountA
175
175
  return rejectWithValue(err);
176
176
  }
177
177
  }));
178
- exports.loginCustomerThanx = (0, toolkit_1.createAsyncThunk)(AccountActionType.LoginCustomerThanx, ({ email, origin }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
178
+ exports.loginCustomerThanx = (0, toolkit_1.createAsyncThunk)(AccountActionType.LoginCustomerThanx, ({ email, origin, recaptcha_token }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
179
179
  try {
180
180
  const api = getState().config.api;
181
- yield api.postThanxLogin(email, origin);
181
+ yield api.postThanxLogin(email, origin, recaptcha_token);
182
182
  dispatch((0, order_2.setAlert)({ type: 'close' }));
183
183
  dispatch((0, order_2.addMessage)('Thanks! Please check your email on this device.'));
184
184
  return;
@@ -6,6 +6,7 @@ const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const types_1 = require("../types");
7
7
  const types_2 = require("@open-tender/types");
8
8
  const account_1 = require("./account");
9
+ const notifications_1 = require("../notifications");
9
10
  const initialState = {
10
11
  entities: [],
11
12
  data: null,
@@ -31,7 +32,7 @@ exports.fetchPointsShop = (0, toolkit_1.createAsyncThunk)(PointsShopActionType.F
31
32
  return rejectWithValue(err);
32
33
  }
33
34
  }));
34
- exports.exchangePointsShopReward = (0, toolkit_1.createAsyncThunk)(PointsShopActionType.ExchangePointsShopReward, (rewardId, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
35
+ exports.exchangePointsShopReward = (0, toolkit_1.createAsyncThunk)(PointsShopActionType.ExchangePointsShopReward, (rewardId, { getState, dispatch, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
35
36
  try {
36
37
  const { api } = getState().config;
37
38
  if (!api)
@@ -40,6 +41,7 @@ exports.exchangePointsShopReward = (0, toolkit_1.createAsyncThunk)(PointsShopAct
40
41
  if (!token)
41
42
  throw new Error(types_2.MISSING_CUSTOMER);
42
43
  yield api.postPointsShopReward(token, rewardId);
44
+ dispatch((0, notifications_1.showNotification)('Reward successfully redeemed!'));
43
45
  return yield api.getPointsShop(token);
44
46
  }
45
47
  catch (err) {
@@ -6,6 +6,7 @@ const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const types_1 = require("../types");
7
7
  const types_2 = require("@open-tender/types");
8
8
  const account_1 = require("./account");
9
+ const notifications_1 = require("../notifications");
9
10
  const initialState = {
10
11
  entities: [],
11
12
  data: null,
@@ -31,7 +32,7 @@ exports.fetchTplsPointsShop = (0, toolkit_1.createAsyncThunk)(TplsPointsShopActi
31
32
  return rejectWithValue(err);
32
33
  }
33
34
  }));
34
- exports.exchangeTplsPointsShopReward = (0, toolkit_1.createAsyncThunk)(TplsPointsShopActionType.ExchangeTplsPointsShopReward, (rewardId, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
35
+ exports.exchangeTplsPointsShopReward = (0, toolkit_1.createAsyncThunk)(TplsPointsShopActionType.ExchangeTplsPointsShopReward, (rewardId, { getState, dispatch, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
35
36
  try {
36
37
  const { api } = getState().config;
37
38
  if (!api)
@@ -40,6 +41,7 @@ exports.exchangeTplsPointsShopReward = (0, toolkit_1.createAsyncThunk)(TplsPoint
40
41
  if (!token)
41
42
  throw new Error(types_2.MISSING_CUSTOMER);
42
43
  const data = yield api.postTplsPointsShopReward(token, rewardId);
44
+ dispatch((0, notifications_1.showNotification)('Reward successfully redeemed!'));
43
45
  const entities = yield api.getTplsPointsShop(token);
44
46
  return { data, entities };
45
47
  }
@@ -107,9 +107,9 @@ declare class OpenTenderAPI {
107
107
  postUnsubscribeByKey(key: string): Promise<unknown>;
108
108
  postSignUp(data: CustomerCreate): Promise<Customer | null | undefined>;
109
109
  postCustomerSignIn(data: CustomerSignIn): Promise<void | Auth | null | undefined>;
110
- postThanxLogin(email: string, origin?: string): Promise<unknown>;
110
+ postThanxLogin(email: string, origin?: string, recaptcha_token?: string): Promise<unknown>;
111
111
  postThanxAuth(code: string, path: string, origin?: string): Promise<unknown>;
112
- postLogin(email: string, password: string): Promise<unknown>;
112
+ postLogin(email: string, password: string, recaptcha_token?: string): Promise<unknown>;
113
113
  postLogout(token: string): Promise<unknown>;
114
114
  postSendPasswordResetEmail(email: string, link_url: string): Promise<unknown>;
115
115
  postResetPassword(new_password: string, token: string): Promise<unknown>;
@@ -525,8 +525,10 @@ class OpenTenderAPI {
525
525
  postCustomerSignIn(data) {
526
526
  return this.request(`/customer/sign-in`, 'POST', data);
527
527
  }
528
- postThanxLogin(email, origin) {
529
- const data = origin ? { email, origin } : { email };
528
+ postThanxLogin(email, origin, recaptcha_token) {
529
+ const data = origin
530
+ ? { email, origin, recaptcha_token }
531
+ : { email, recaptcha_token };
530
532
  return this.request('/thanx-login', 'POST', data);
531
533
  }
532
534
  postThanxAuth(code, path, origin) {
@@ -534,11 +536,12 @@ class OpenTenderAPI {
534
536
  const withOrigin = origin ? Object.assign(Object.assign({}, data), { origin }) : data;
535
537
  return this.request('/thanx-auth', 'POST', withOrigin);
536
538
  }
537
- postLogin(email, password) {
539
+ postLogin(email, password, recaptcha_token) {
538
540
  const data = {
539
541
  grant_type: 'password',
540
542
  username: email,
541
- password: password
543
+ password: password,
544
+ recaptcha_token
542
545
  };
543
546
  return this.authRequest('/token', data);
544
547
  }
@@ -85,6 +85,7 @@ export declare const sendCustomerVerificationEmail: import("@reduxjs/toolkit").A
85
85
  export declare const loginCustomerThanx: import("@reduxjs/toolkit").AsyncThunk<void, {
86
86
  email: string;
87
87
  origin?: string | undefined;
88
+ recaptcha_token?: string | undefined;
88
89
  }, {
89
90
  state: AppState;
90
91
  rejectValue: RequestError;
@@ -73,10 +73,10 @@ export const fetchCustomer = createAsyncThunk(AccountActionType.FetchCustomer,
73
73
  return checkAuth(error, dispatch, () => rejectWithValue(error));
74
74
  }
75
75
  }));
76
- export const loginCustomer = createAsyncThunk(AccountActionType.LoginCustomer, ({ email, password }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
76
+ export const loginCustomer = createAsyncThunk(AccountActionType.LoginCustomer, ({ email, password, recaptcha_token }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
77
77
  try {
78
78
  const api = getState().config.api;
79
- const auth = yield api.postLogin(email, password);
79
+ const auth = yield api.postLogin(email, password, recaptcha_token);
80
80
  dispatch(setCustomerAuth(auth));
81
81
  yield dispatch(fetchCustomer());
82
82
  return;
@@ -170,10 +170,10 @@ export const sendCustomerVerificationEmail = createAsyncThunk(AccountActionType.
170
170
  return rejectWithValue(err);
171
171
  }
172
172
  }));
173
- export const loginCustomerThanx = createAsyncThunk(AccountActionType.LoginCustomerThanx, ({ email, origin }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
173
+ export const loginCustomerThanx = createAsyncThunk(AccountActionType.LoginCustomerThanx, ({ email, origin, recaptcha_token }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
174
174
  try {
175
175
  const api = getState().config.api;
176
- yield api.postThanxLogin(email, origin);
176
+ yield api.postThanxLogin(email, origin, recaptcha_token);
177
177
  dispatch(setAlert({ type: 'close' }));
178
178
  dispatch(addMessage('Thanks! Please check your email on this device.'));
179
179
  return;
@@ -3,6 +3,7 @@ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
3
  import { ReducerType } from '../types';
4
4
  import { MISSING_CUSTOMER } from '@open-tender/types';
5
5
  import { selectToken } from './account';
6
+ import { showNotification } from '../notifications';
6
7
  const initialState = {
7
8
  entities: [],
8
9
  data: null,
@@ -28,7 +29,7 @@ export const fetchPointsShop = createAsyncThunk(PointsShopActionType.FetchPoints
28
29
  return rejectWithValue(err);
29
30
  }
30
31
  }));
31
- export const exchangePointsShopReward = createAsyncThunk(PointsShopActionType.ExchangePointsShopReward, (rewardId, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
32
+ export const exchangePointsShopReward = createAsyncThunk(PointsShopActionType.ExchangePointsShopReward, (rewardId, { getState, dispatch, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
32
33
  try {
33
34
  const { api } = getState().config;
34
35
  if (!api)
@@ -37,6 +38,7 @@ export const exchangePointsShopReward = createAsyncThunk(PointsShopActionType.Ex
37
38
  if (!token)
38
39
  throw new Error(MISSING_CUSTOMER);
39
40
  yield api.postPointsShopReward(token, rewardId);
41
+ dispatch(showNotification('Reward successfully redeemed!'));
40
42
  return yield api.getPointsShop(token);
41
43
  }
42
44
  catch (err) {
@@ -3,6 +3,7 @@ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
3
  import { ReducerType } from '../types';
4
4
  import { MISSING_CUSTOMER } from '@open-tender/types';
5
5
  import { selectToken } from './account';
6
+ import { showNotification } from '../notifications';
6
7
  const initialState = {
7
8
  entities: [],
8
9
  data: null,
@@ -28,7 +29,7 @@ export const fetchTplsPointsShop = createAsyncThunk(TplsPointsShopActionType.Fet
28
29
  return rejectWithValue(err);
29
30
  }
30
31
  }));
31
- export const exchangeTplsPointsShopReward = createAsyncThunk(TplsPointsShopActionType.ExchangeTplsPointsShopReward, (rewardId, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
32
+ export const exchangeTplsPointsShopReward = createAsyncThunk(TplsPointsShopActionType.ExchangeTplsPointsShopReward, (rewardId, { getState, dispatch, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
32
33
  try {
33
34
  const { api } = getState().config;
34
35
  if (!api)
@@ -37,6 +38,7 @@ export const exchangeTplsPointsShopReward = createAsyncThunk(TplsPointsShopActio
37
38
  if (!token)
38
39
  throw new Error(MISSING_CUSTOMER);
39
40
  const data = yield api.postTplsPointsShopReward(token, rewardId);
41
+ dispatch(showNotification('Reward successfully redeemed!'));
40
42
  const entities = yield api.getTplsPointsShop(token);
41
43
  return { data, entities };
42
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/cloud",
3
- "version": "0.5.11",
3
+ "version": "0.5.13",
4
4
  "description": "A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our cloud-based Order API.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -34,7 +34,7 @@
34
34
  "private": false,
35
35
  "devDependencies": {
36
36
  "@babel/core": "^7.19.1",
37
- "@open-tender/types": "^0.4.132",
37
+ "@open-tender/types": "^0.4.134",
38
38
  "@open-tender/utils": "^0.4.99",
39
39
  "@reduxjs/toolkit": "^1.8.5",
40
40
  "@types/react": "^18.0.18",