@open-tender/cloud 0.1.12 → 0.1.14

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,5 +1,5 @@
1
1
  import { AppState } from '../../app';
2
- import { CreditCard, CreditCards, RequestError, RequestStatus } from '@open-tender/types';
2
+ import { CreditCardData, CreditCards, RequestError, RequestStatus } from '@open-tender/types';
3
3
  export interface CustomerCreditCardsState {
4
4
  entities: CreditCards;
5
5
  error: RequestError;
@@ -26,7 +26,7 @@ export declare const fetchCustomerCreditCards: import("@reduxjs/toolkit").AsyncT
26
26
  }>;
27
27
  export declare const updateCustomerCreditCard: import("@reduxjs/toolkit").AsyncThunk<CreditCards, {
28
28
  cardId: number;
29
- data: CreditCard;
29
+ data: CreditCardData;
30
30
  callback?: (() => void) | undefined;
31
31
  }, {
32
32
  state: AppState;
@@ -52,7 +52,7 @@ export declare const removeCustomerCreditCard: import("@reduxjs/toolkit").AsyncT
52
52
  rejectedMeta?: unknown;
53
53
  }>;
54
54
  export declare const addCustomerCreditCard: import("@reduxjs/toolkit").AsyncThunk<CreditCards, {
55
- data: CreditCard;
55
+ data: CreditCardData;
56
56
  callback?: (() => void) | undefined;
57
57
  }, {
58
58
  state: AppState;
@@ -66,5 +66,5 @@ export declare const addCustomerCreditCard: import("@reduxjs/toolkit").AsyncThun
66
66
  }>;
67
67
  export declare const resetCustomerCreditCards: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"creditCards/resetCustomerCreditCards">, resetCustomerCreditCardsError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"creditCards/resetCustomerCreditCardsError">, setCustomerCreditCards: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "creditCards/setCustomerCreditCards">;
68
68
  export declare const selectCustomerCreditCards: (state: AppState) => CustomerCreditCardsState;
69
- export declare const selectCustomerCreditCardsForPayment: (state: AppState) => CreditCard[];
69
+ export declare const selectCustomerCreditCardsForPayment: (state: AppState) => import("@open-tender/types").CreditCard[];
70
70
  export declare const customerCreditCardsReducer: import("redux").Reducer<CustomerCreditCardsState, import("redux").AnyAction>;
@@ -35,18 +35,18 @@ exports.fetchCustomerCreditCards = (0, toolkit_1.createAsyncThunk)(CustomerCredi
35
35
  return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(error));
36
36
  }
37
37
  }));
38
- exports.updateCustomerCreditCard = (0, toolkit_1.createAsyncThunk)(CustomerCreditCardsActionType.UpdateCustomerCreditCard, (requestData, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
38
+ exports.updateCustomerCreditCard = (0, toolkit_1.createAsyncThunk)(CustomerCreditCardsActionType.UpdateCustomerCreditCard, ({ cardId, data, callback }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
39
39
  try {
40
40
  const api = getState().config.api;
41
41
  const token = (0, account_1.selectToken)(getState());
42
42
  if (!token)
43
43
  throw new Error(types_2.MISSING_CUSTOMER);
44
- yield api.putCustomerCreditCard(token, requestData.cardId, requestData.data);
44
+ yield api.putCustomerCreditCard(token, cardId, data);
45
45
  const includeLinked = true;
46
46
  const creditCards = yield api.getCustomerCreditCards(token, includeLinked);
47
47
  dispatch((0, notifications_1.showNotification)('Credit card updated!'));
48
- if (requestData.callback)
49
- requestData.callback();
48
+ if (callback)
49
+ callback();
50
50
  return creditCards;
51
51
  }
52
52
  catch (err) {
@@ -54,18 +54,18 @@ exports.updateCustomerCreditCard = (0, toolkit_1.createAsyncThunk)(CustomerCredi
54
54
  return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(error));
55
55
  }
56
56
  }));
57
- exports.removeCustomerCreditCard = (0, toolkit_1.createAsyncThunk)(CustomerCreditCardsActionType.RemoveCustomerCreditCard, (requestData, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
57
+ exports.removeCustomerCreditCard = (0, toolkit_1.createAsyncThunk)(CustomerCreditCardsActionType.RemoveCustomerCreditCard, ({ cardId, callback }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
58
58
  try {
59
59
  const api = getState().config.api;
60
60
  const token = (0, account_1.selectToken)(getState());
61
61
  if (!token)
62
62
  throw new Error(types_2.MISSING_CUSTOMER);
63
- yield api.deleteCustomerCreditCard(token, requestData.cardId);
63
+ yield api.deleteCustomerCreditCard(token, cardId);
64
64
  const includeLinked = true;
65
65
  const creditCards = yield api.getCustomerCreditCards(token, includeLinked);
66
66
  dispatch((0, notifications_1.showNotification)('Credit card removed!'));
67
- if (requestData.callback)
68
- requestData.callback();
67
+ if (callback)
68
+ callback();
69
69
  return creditCards;
70
70
  }
71
71
  catch (err) {
@@ -73,18 +73,18 @@ exports.removeCustomerCreditCard = (0, toolkit_1.createAsyncThunk)(CustomerCredi
73
73
  return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(error));
74
74
  }
75
75
  }));
76
- exports.addCustomerCreditCard = (0, toolkit_1.createAsyncThunk)(CustomerCreditCardsActionType.AddCustomerCreditCard, (requestData, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
76
+ exports.addCustomerCreditCard = (0, toolkit_1.createAsyncThunk)(CustomerCreditCardsActionType.AddCustomerCreditCard, ({ data, callback }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
77
77
  try {
78
78
  const api = getState().config.api;
79
79
  const token = (0, account_1.selectToken)(getState());
80
80
  if (!token)
81
81
  throw new Error(types_2.MISSING_CUSTOMER);
82
- yield api.postCustomerCreditCard(token, requestData.data);
82
+ yield api.postCustomerCreditCard(token, data);
83
83
  const includeLinked = true;
84
84
  const creditCards = yield api.getCustomerCreditCards(token, includeLinked);
85
85
  dispatch((0, notifications_1.showNotification)('Credit card added!'));
86
- if (requestData.callback)
87
- requestData.callback();
86
+ if (callback)
87
+ callback();
88
88
  return creditCards;
89
89
  }
90
90
  catch (err) {
@@ -1,5 +1,5 @@
1
1
  import { AppState } from '../app';
2
- import { GiftCard, GiftCards, RequestError, RequestStatus } from '@open-tender/types';
2
+ import { GiftCards, GiftCardsPurchase, RequestError, RequestStatus } from '@open-tender/types';
3
3
  export interface GiftCardsState {
4
4
  loading: RequestStatus;
5
5
  error: RequestError;
@@ -10,7 +10,7 @@ export declare enum GiftCardsActionType {
10
10
  PurchaseGiftCards = "giftCards/purchaseGiftCards"
11
11
  }
12
12
  export declare const purchaseGiftCards: import("@reduxjs/toolkit").AsyncThunk<GiftCards, {
13
- data: Partial<GiftCard>;
13
+ data: GiftCardsPurchase;
14
14
  callback?: (() => void) | undefined;
15
15
  }, {
16
16
  state: AppState;
@@ -14,14 +14,14 @@ var GiftCardsActionType;
14
14
  (function (GiftCardsActionType) {
15
15
  GiftCardsActionType["PurchaseGiftCards"] = "giftCards/purchaseGiftCards";
16
16
  })(GiftCardsActionType = exports.GiftCardsActionType || (exports.GiftCardsActionType = {}));
17
- exports.purchaseGiftCards = (0, toolkit_1.createAsyncThunk)(GiftCardsActionType.PurchaseGiftCards, (requestData, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
17
+ exports.purchaseGiftCards = (0, toolkit_1.createAsyncThunk)(GiftCardsActionType.PurchaseGiftCards, ({ data, callback }, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
18
18
  const { api } = getState().config;
19
19
  if (!api)
20
20
  return;
21
21
  try {
22
- const giftCards = yield api.postPurchaseGiftCards(requestData.data);
23
- if (requestData.callback)
24
- requestData.callback();
22
+ const giftCards = yield api.postPurchaseGiftCards(data);
23
+ if (callback)
24
+ callback();
25
25
  return giftCards;
26
26
  }
27
27
  catch (err) {
@@ -1,5 +1,5 @@
1
1
  import { AppState } from '../../app';
2
- import { CreditCard, CreditCards, RequestError, RequestStatus } from '@open-tender/types';
2
+ import { CreditCardData, CreditCards, RequestError, RequestStatus } from '@open-tender/types';
3
3
  export interface CustomerCreditCardsState {
4
4
  entities: CreditCards;
5
5
  error: RequestError;
@@ -26,7 +26,7 @@ export declare const fetchCustomerCreditCards: import("@reduxjs/toolkit").AsyncT
26
26
  }>;
27
27
  export declare const updateCustomerCreditCard: import("@reduxjs/toolkit").AsyncThunk<CreditCards, {
28
28
  cardId: number;
29
- data: CreditCard;
29
+ data: CreditCardData;
30
30
  callback?: (() => void) | undefined;
31
31
  }, {
32
32
  state: AppState;
@@ -52,7 +52,7 @@ export declare const removeCustomerCreditCard: import("@reduxjs/toolkit").AsyncT
52
52
  rejectedMeta?: unknown;
53
53
  }>;
54
54
  export declare const addCustomerCreditCard: import("@reduxjs/toolkit").AsyncThunk<CreditCards, {
55
- data: CreditCard;
55
+ data: CreditCardData;
56
56
  callback?: (() => void) | undefined;
57
57
  }, {
58
58
  state: AppState;
@@ -66,5 +66,5 @@ export declare const addCustomerCreditCard: import("@reduxjs/toolkit").AsyncThun
66
66
  }>;
67
67
  export declare const resetCustomerCreditCards: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"creditCards/resetCustomerCreditCards">, resetCustomerCreditCardsError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"creditCards/resetCustomerCreditCardsError">, setCustomerCreditCards: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "creditCards/setCustomerCreditCards">;
68
68
  export declare const selectCustomerCreditCards: (state: AppState) => CustomerCreditCardsState;
69
- export declare const selectCustomerCreditCardsForPayment: (state: AppState) => CreditCard[];
69
+ export declare const selectCustomerCreditCardsForPayment: (state: AppState) => import("@open-tender/types").CreditCard[];
70
70
  export declare const customerCreditCardsReducer: import("redux").Reducer<CustomerCreditCardsState, import("redux").AnyAction>;
@@ -31,18 +31,18 @@ export const fetchCustomerCreditCards = createAsyncThunk(CustomerCreditCardsActi
31
31
  return checkAuth(error, dispatch, () => rejectWithValue(error));
32
32
  }
33
33
  }));
34
- export const updateCustomerCreditCard = createAsyncThunk(CustomerCreditCardsActionType.UpdateCustomerCreditCard, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
34
+ export const updateCustomerCreditCard = createAsyncThunk(CustomerCreditCardsActionType.UpdateCustomerCreditCard, ({ cardId, data, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
35
35
  try {
36
36
  const api = getState().config.api;
37
37
  const token = selectToken(getState());
38
38
  if (!token)
39
39
  throw new Error(MISSING_CUSTOMER);
40
- yield api.putCustomerCreditCard(token, requestData.cardId, requestData.data);
40
+ yield api.putCustomerCreditCard(token, cardId, data);
41
41
  const includeLinked = true;
42
42
  const creditCards = yield api.getCustomerCreditCards(token, includeLinked);
43
43
  dispatch(showNotification('Credit card updated!'));
44
- if (requestData.callback)
45
- requestData.callback();
44
+ if (callback)
45
+ callback();
46
46
  return creditCards;
47
47
  }
48
48
  catch (err) {
@@ -50,18 +50,18 @@ export const updateCustomerCreditCard = createAsyncThunk(CustomerCreditCardsActi
50
50
  return checkAuth(error, dispatch, () => rejectWithValue(error));
51
51
  }
52
52
  }));
53
- export const removeCustomerCreditCard = createAsyncThunk(CustomerCreditCardsActionType.RemoveCustomerCreditCard, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
53
+ export const removeCustomerCreditCard = createAsyncThunk(CustomerCreditCardsActionType.RemoveCustomerCreditCard, ({ cardId, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
54
54
  try {
55
55
  const api = getState().config.api;
56
56
  const token = selectToken(getState());
57
57
  if (!token)
58
58
  throw new Error(MISSING_CUSTOMER);
59
- yield api.deleteCustomerCreditCard(token, requestData.cardId);
59
+ yield api.deleteCustomerCreditCard(token, cardId);
60
60
  const includeLinked = true;
61
61
  const creditCards = yield api.getCustomerCreditCards(token, includeLinked);
62
62
  dispatch(showNotification('Credit card removed!'));
63
- if (requestData.callback)
64
- requestData.callback();
63
+ if (callback)
64
+ callback();
65
65
  return creditCards;
66
66
  }
67
67
  catch (err) {
@@ -69,18 +69,18 @@ export const removeCustomerCreditCard = createAsyncThunk(CustomerCreditCardsActi
69
69
  return checkAuth(error, dispatch, () => rejectWithValue(error));
70
70
  }
71
71
  }));
72
- export const addCustomerCreditCard = createAsyncThunk(CustomerCreditCardsActionType.AddCustomerCreditCard, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
72
+ export const addCustomerCreditCard = createAsyncThunk(CustomerCreditCardsActionType.AddCustomerCreditCard, ({ data, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
73
73
  try {
74
74
  const api = getState().config.api;
75
75
  const token = selectToken(getState());
76
76
  if (!token)
77
77
  throw new Error(MISSING_CUSTOMER);
78
- yield api.postCustomerCreditCard(token, requestData.data);
78
+ yield api.postCustomerCreditCard(token, data);
79
79
  const includeLinked = true;
80
80
  const creditCards = yield api.getCustomerCreditCards(token, includeLinked);
81
81
  dispatch(showNotification('Credit card added!'));
82
- if (requestData.callback)
83
- requestData.callback();
82
+ if (callback)
83
+ callback();
84
84
  return creditCards;
85
85
  }
86
86
  catch (err) {
@@ -1,5 +1,5 @@
1
1
  import { AppState } from '../app';
2
- import { GiftCard, GiftCards, RequestError, RequestStatus } from '@open-tender/types';
2
+ import { GiftCards, GiftCardsPurchase, RequestError, RequestStatus } from '@open-tender/types';
3
3
  export interface GiftCardsState {
4
4
  loading: RequestStatus;
5
5
  error: RequestError;
@@ -10,7 +10,7 @@ export declare enum GiftCardsActionType {
10
10
  PurchaseGiftCards = "giftCards/purchaseGiftCards"
11
11
  }
12
12
  export declare const purchaseGiftCards: import("@reduxjs/toolkit").AsyncThunk<GiftCards, {
13
- data: Partial<GiftCard>;
13
+ data: GiftCardsPurchase;
14
14
  callback?: (() => void) | undefined;
15
15
  }, {
16
16
  state: AppState;
@@ -11,14 +11,14 @@ export var GiftCardsActionType;
11
11
  (function (GiftCardsActionType) {
12
12
  GiftCardsActionType["PurchaseGiftCards"] = "giftCards/purchaseGiftCards";
13
13
  })(GiftCardsActionType || (GiftCardsActionType = {}));
14
- export const purchaseGiftCards = createAsyncThunk(GiftCardsActionType.PurchaseGiftCards, (requestData, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
14
+ export const purchaseGiftCards = createAsyncThunk(GiftCardsActionType.PurchaseGiftCards, ({ data, callback }, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
15
15
  const { api } = getState().config;
16
16
  if (!api)
17
17
  return;
18
18
  try {
19
- const giftCards = yield api.postPurchaseGiftCards(requestData.data);
20
- if (requestData.callback)
21
- requestData.callback();
19
+ const giftCards = yield api.postPurchaseGiftCards(data);
20
+ if (callback)
21
+ callback();
22
22
  return giftCards;
23
23
  }
24
24
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/cloud",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
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",