@open-tender/cloud 0.4.36 → 0.4.38

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.
@@ -104,6 +104,7 @@ declare class OpenTenderAPI {
104
104
  getSubscriber(email: string): Promise<unknown>;
105
105
  postSubscriber(email: string): Promise<unknown>;
106
106
  postUnsubscribe(customer_id: string, campaign_id: string): Promise<unknown>;
107
+ postUnsubscribeByKey(key: string): Promise<unknown>;
107
108
  postSignUp(data: CustomerCreate): Promise<Customer | null | undefined>;
108
109
  postCustomerSignIn(data: CustomerSignIn): Promise<void | Auth | null | undefined>;
109
110
  postThanxLogin(email: string, origin?: string): Promise<unknown>;
@@ -512,6 +512,9 @@ class OpenTenderAPI {
512
512
  postUnsubscribe(customer_id, campaign_id) {
513
513
  return this.request(`/unsubscribe/campaign/${customer_id}/${campaign_id}`, 'POST');
514
514
  }
515
+ postUnsubscribeByKey(key) {
516
+ return this.request(`/unsubscribe/campaign/${key}`, 'POST');
517
+ }
515
518
  postSignUp(data) {
516
519
  return this.request(`/customer`, 'POST', data);
517
520
  }
@@ -6,7 +6,8 @@ export interface UnsubscribeState {
6
6
  success: boolean;
7
7
  }
8
8
  export declare enum UnsubscribeActionType {
9
- Unsubscribe = "unsubscribe/unsubscribe"
9
+ Unsubscribe = "unsubscribe/unsubscribe",
10
+ UnsubscribeByKey = "unsubscribe/unsubscribeByKey"
10
11
  }
11
12
  export declare const unsubscribe: import("@reduxjs/toolkit").AsyncThunk<void, {
12
13
  customer_id: string;
@@ -21,6 +22,18 @@ export declare const unsubscribe: import("@reduxjs/toolkit").AsyncThunk<void, {
21
22
  fulfilledMeta?: unknown;
22
23
  rejectedMeta?: unknown;
23
24
  }>;
25
+ export declare const unsubscribeByKey: import("@reduxjs/toolkit").AsyncThunk<void, {
26
+ key: string;
27
+ }, {
28
+ state: AppState;
29
+ rejectValue: RequestError;
30
+ dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
31
+ extra?: unknown;
32
+ serializedErrorType?: unknown;
33
+ pendingMeta?: unknown;
34
+ fulfilledMeta?: unknown;
35
+ rejectedMeta?: unknown;
36
+ }>;
24
37
  export declare const resetUnsubscribe: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"Unsubscribe/resetUnsubscribe">;
25
38
  export declare const selectUnsubscribe: (state: AppState) => UnsubscribeState;
26
39
  export declare const unsubscribeReducer: import("redux").Reducer<UnsubscribeState, import("redux").AnyAction>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unsubscribeReducer = exports.selectUnsubscribe = exports.resetUnsubscribe = exports.unsubscribe = exports.UnsubscribeActionType = void 0;
3
+ exports.unsubscribeReducer = exports.selectUnsubscribe = exports.resetUnsubscribe = exports.unsubscribeByKey = exports.unsubscribe = exports.UnsubscribeActionType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const types_1 = require("./types");
@@ -12,6 +12,7 @@ const initialState = {
12
12
  var UnsubscribeActionType;
13
13
  (function (UnsubscribeActionType) {
14
14
  UnsubscribeActionType["Unsubscribe"] = "unsubscribe/unsubscribe";
15
+ UnsubscribeActionType["UnsubscribeByKey"] = "unsubscribe/unsubscribeByKey";
15
16
  })(UnsubscribeActionType = exports.UnsubscribeActionType || (exports.UnsubscribeActionType = {}));
16
17
  exports.unsubscribe = (0, toolkit_1.createAsyncThunk)(UnsubscribeActionType.Unsubscribe, ({ customer_id, campaign_id }, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
17
18
  const { api } = getState().config;
@@ -25,6 +26,18 @@ exports.unsubscribe = (0, toolkit_1.createAsyncThunk)(UnsubscribeActionType.Unsu
25
26
  return rejectWithValue(err);
26
27
  }
27
28
  }));
29
+ exports.unsubscribeByKey = (0, toolkit_1.createAsyncThunk)(UnsubscribeActionType.UnsubscribeByKey, ({ key }, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
30
+ const { api } = getState().config;
31
+ if (!api)
32
+ return;
33
+ try {
34
+ yield api.postUnsubscribeByKey(key);
35
+ return;
36
+ }
37
+ catch (err) {
38
+ return rejectWithValue(err);
39
+ }
40
+ }));
28
41
  const unsubscribeSlice = (0, toolkit_1.createSlice)({
29
42
  name: types_1.ReducerType.Unsubscribe,
30
43
  initialState,
@@ -44,6 +57,18 @@ const unsubscribeSlice = (0, toolkit_1.createSlice)({
44
57
  .addCase(exports.unsubscribe.rejected, (state, action) => {
45
58
  state.loading = 'idle';
46
59
  state.error = action.payload;
60
+ })
61
+ .addCase(exports.unsubscribeByKey.fulfilled, state => {
62
+ state.success = true;
63
+ state.loading = 'idle';
64
+ state.error = null;
65
+ })
66
+ .addCase(exports.unsubscribeByKey.pending, state => {
67
+ state.loading = 'pending';
68
+ })
69
+ .addCase(exports.unsubscribeByKey.rejected, (state, action) => {
70
+ state.loading = 'idle';
71
+ state.error = action.payload;
47
72
  });
48
73
  }
49
74
  });
@@ -104,6 +104,7 @@ declare class OpenTenderAPI {
104
104
  getSubscriber(email: string): Promise<unknown>;
105
105
  postSubscriber(email: string): Promise<unknown>;
106
106
  postUnsubscribe(customer_id: string, campaign_id: string): Promise<unknown>;
107
+ postUnsubscribeByKey(key: string): Promise<unknown>;
107
108
  postSignUp(data: CustomerCreate): Promise<Customer | null | undefined>;
108
109
  postCustomerSignIn(data: CustomerSignIn): Promise<void | Auth | null | undefined>;
109
110
  postThanxLogin(email: string, origin?: string): Promise<unknown>;
@@ -510,6 +510,9 @@ class OpenTenderAPI {
510
510
  postUnsubscribe(customer_id, campaign_id) {
511
511
  return this.request(`/unsubscribe/campaign/${customer_id}/${campaign_id}`, 'POST');
512
512
  }
513
+ postUnsubscribeByKey(key) {
514
+ return this.request(`/unsubscribe/campaign/${key}`, 'POST');
515
+ }
513
516
  postSignUp(data) {
514
517
  return this.request(`/customer`, 'POST', data);
515
518
  }
@@ -6,7 +6,8 @@ export interface UnsubscribeState {
6
6
  success: boolean;
7
7
  }
8
8
  export declare enum UnsubscribeActionType {
9
- Unsubscribe = "unsubscribe/unsubscribe"
9
+ Unsubscribe = "unsubscribe/unsubscribe",
10
+ UnsubscribeByKey = "unsubscribe/unsubscribeByKey"
10
11
  }
11
12
  export declare const unsubscribe: import("@reduxjs/toolkit").AsyncThunk<void, {
12
13
  customer_id: string;
@@ -21,6 +22,18 @@ export declare const unsubscribe: import("@reduxjs/toolkit").AsyncThunk<void, {
21
22
  fulfilledMeta?: unknown;
22
23
  rejectedMeta?: unknown;
23
24
  }>;
25
+ export declare const unsubscribeByKey: import("@reduxjs/toolkit").AsyncThunk<void, {
26
+ key: string;
27
+ }, {
28
+ state: AppState;
29
+ rejectValue: RequestError;
30
+ dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
31
+ extra?: unknown;
32
+ serializedErrorType?: unknown;
33
+ pendingMeta?: unknown;
34
+ fulfilledMeta?: unknown;
35
+ rejectedMeta?: unknown;
36
+ }>;
24
37
  export declare const resetUnsubscribe: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"Unsubscribe/resetUnsubscribe">;
25
38
  export declare const selectUnsubscribe: (state: AppState) => UnsubscribeState;
26
39
  export declare const unsubscribeReducer: import("redux").Reducer<UnsubscribeState, import("redux").AnyAction>;
@@ -9,6 +9,7 @@ const initialState = {
9
9
  export var UnsubscribeActionType;
10
10
  (function (UnsubscribeActionType) {
11
11
  UnsubscribeActionType["Unsubscribe"] = "unsubscribe/unsubscribe";
12
+ UnsubscribeActionType["UnsubscribeByKey"] = "unsubscribe/unsubscribeByKey";
12
13
  })(UnsubscribeActionType || (UnsubscribeActionType = {}));
13
14
  export const unsubscribe = createAsyncThunk(UnsubscribeActionType.Unsubscribe, ({ customer_id, campaign_id }, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
14
15
  const { api } = getState().config;
@@ -22,6 +23,18 @@ export const unsubscribe = createAsyncThunk(UnsubscribeActionType.Unsubscribe, (
22
23
  return rejectWithValue(err);
23
24
  }
24
25
  }));
26
+ export const unsubscribeByKey = createAsyncThunk(UnsubscribeActionType.UnsubscribeByKey, ({ key }, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
27
+ const { api } = getState().config;
28
+ if (!api)
29
+ return;
30
+ try {
31
+ yield api.postUnsubscribeByKey(key);
32
+ return;
33
+ }
34
+ catch (err) {
35
+ return rejectWithValue(err);
36
+ }
37
+ }));
25
38
  const unsubscribeSlice = createSlice({
26
39
  name: ReducerType.Unsubscribe,
27
40
  initialState,
@@ -41,6 +54,18 @@ const unsubscribeSlice = createSlice({
41
54
  .addCase(unsubscribe.rejected, (state, action) => {
42
55
  state.loading = 'idle';
43
56
  state.error = action.payload;
57
+ })
58
+ .addCase(unsubscribeByKey.fulfilled, state => {
59
+ state.success = true;
60
+ state.loading = 'idle';
61
+ state.error = null;
62
+ })
63
+ .addCase(unsubscribeByKey.pending, state => {
64
+ state.loading = 'pending';
65
+ })
66
+ .addCase(unsubscribeByKey.rejected, (state, action) => {
67
+ state.loading = 'idle';
68
+ state.error = action.payload;
44
69
  });
45
70
  }
46
71
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/cloud",
3
- "version": "0.4.36",
3
+ "version": "0.4.38",
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,8 +34,8 @@
34
34
  "private": false,
35
35
  "devDependencies": {
36
36
  "@babel/core": "^7.19.1",
37
- "@open-tender/types": "^0.4.94",
38
- "@open-tender/utils": "^0.4.68",
37
+ "@open-tender/types": "^0.4.96",
38
+ "@open-tender/utils": "^0.4.69",
39
39
  "@reduxjs/toolkit": "^1.8.5",
40
40
  "@types/react": "^18.0.18",
41
41
  "@types/react-dom": "^18.0.6",