@nimee/api-clients 1.1.116 → 1.1.119
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.
- package/dist/src/crm.d.ts +39 -0
- package/dist/src/crm.js +44 -1
- package/dist/src/crm.js.map +1 -1
- package/package.json +2 -2
- package/src/crm.ts +75 -1
package/dist/src/crm.d.ts
CHANGED
|
@@ -45,6 +45,45 @@ export declare class CrmClient {
|
|
|
45
45
|
endUserPhone?: string;
|
|
46
46
|
customer?: Record<string, unknown>;
|
|
47
47
|
}): Promise<IDiningCommitCreateResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Settles exactly the given commits against a charge the caller already created (e.g. via
|
|
50
|
+
* `chargeEndUser`). Forwards the caller's `jwt` header — CRM derives `settledBy`/`settledByName`
|
|
51
|
+
* from that JWT itself, same as `settle-selected`'s other callers.
|
|
52
|
+
*/
|
|
53
|
+
settleSelectedDining(params: {
|
|
54
|
+
jwt: string;
|
|
55
|
+
marketplaceId: string;
|
|
56
|
+
sellerId: string;
|
|
57
|
+
endUserId: string;
|
|
58
|
+
commitIds: string[];
|
|
59
|
+
chargeId: string;
|
|
60
|
+
}): Promise<{
|
|
61
|
+
settledCount: number;
|
|
62
|
+
total: number;
|
|
63
|
+
balance: number;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* INTERNAL. Stamps the refund state of a charge onto the meals that charge collected, so the
|
|
67
|
+
* guest's own dining page can show the money came back. `jwt` must be JWT_ADMIN — the CRM route
|
|
68
|
+
* compares it literally before verifying anything, because a seller token proves identity, not
|
|
69
|
+
* the right to rewrite a member's meal history. No marketplaceId in the path: that route has no
|
|
70
|
+
* `checkRole` to key on one, and a manual charge never carries a marketplace to supply it.
|
|
71
|
+
*
|
|
72
|
+
* "full" is per-meal truthful (each meal's own effectiveAmount is what came back); "partial" is
|
|
73
|
+
* charge-level and deliberately carries no per-meal figure — one charge covers several meals, and
|
|
74
|
+
* splitting a partial refund across them would invent numbers nobody agreed to.
|
|
75
|
+
*/
|
|
76
|
+
markDiningChargeRefunded(params: {
|
|
77
|
+
jwt: string;
|
|
78
|
+
sellerId: string;
|
|
79
|
+
endUserId: string;
|
|
80
|
+
chargeId: string;
|
|
81
|
+
refundState: "partial" | "full";
|
|
82
|
+
/** Everything returned against this charge so far, in SHEKELS — CRM apportions it across the meals. */
|
|
83
|
+
refundedTotal?: number;
|
|
84
|
+
}): Promise<{
|
|
85
|
+
updatedCommits: number;
|
|
86
|
+
}>;
|
|
48
87
|
getDiningBalance(params: {
|
|
49
88
|
jwt: string;
|
|
50
89
|
marketplaceId: string;
|
package/dist/src/crm.js
CHANGED
|
@@ -55,7 +55,14 @@ class CrmClient {
|
|
|
55
55
|
createAutoExitVisit(params) {
|
|
56
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
57
|
const { jwt, marketplaceId, sellerId, endUserId, guests, endUserSeasonTicketId, seasonTicketId, scannerSessionId } = params;
|
|
58
|
-
if (!jwt ||
|
|
58
|
+
if (!jwt ||
|
|
59
|
+
!marketplaceId ||
|
|
60
|
+
!sellerId ||
|
|
61
|
+
!endUserId ||
|
|
62
|
+
!endUserSeasonTicketId ||
|
|
63
|
+
!seasonTicketId ||
|
|
64
|
+
!scannerSessionId ||
|
|
65
|
+
guests === undefined) {
|
|
59
66
|
throw new error_handler_1.CustomError("param_are_missing_in_createAutoExitVisit", 400, `params are: ${JSON.stringify(params)}`);
|
|
60
67
|
}
|
|
61
68
|
const response = yield axios_1.default.post(`${crmUrl}/visit/${marketplaceId}/${sellerId}/${endUserId}`, { guests, autoExit: true, endUserSeasonTicketId, seasonTicketId, scannerSessionId }, { headers: { jwt } });
|
|
@@ -72,6 +79,42 @@ class CrmClient {
|
|
|
72
79
|
return response === null || response === void 0 ? void 0 : response.data;
|
|
73
80
|
});
|
|
74
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Settles exactly the given commits against a charge the caller already created (e.g. via
|
|
84
|
+
* `chargeEndUser`). Forwards the caller's `jwt` header — CRM derives `settledBy`/`settledByName`
|
|
85
|
+
* from that JWT itself, same as `settle-selected`'s other callers.
|
|
86
|
+
*/
|
|
87
|
+
settleSelectedDining(params) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
const { jwt, marketplaceId, sellerId, endUserId, commitIds, chargeId } = params;
|
|
90
|
+
if (!jwt || !marketplaceId || !sellerId || !endUserId || !(commitIds === null || commitIds === void 0 ? void 0 : commitIds.length) || !chargeId) {
|
|
91
|
+
throw new error_handler_1.CustomError("param_are_missing_in_settleSelectedDining", 400, `params are: ${JSON.stringify({ marketplaceId, sellerId, endUserId, commitIds, chargeId })}`);
|
|
92
|
+
}
|
|
93
|
+
const response = yield axios_1.default.post(`${crmUrl}/dining/commits/settle-selected/${marketplaceId}/${sellerId}/${endUserId}`, { commitIds, chargeId }, { headers: { jwt } });
|
|
94
|
+
return response === null || response === void 0 ? void 0 : response.data;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* INTERNAL. Stamps the refund state of a charge onto the meals that charge collected, so the
|
|
99
|
+
* guest's own dining page can show the money came back. `jwt` must be JWT_ADMIN — the CRM route
|
|
100
|
+
* compares it literally before verifying anything, because a seller token proves identity, not
|
|
101
|
+
* the right to rewrite a member's meal history. No marketplaceId in the path: that route has no
|
|
102
|
+
* `checkRole` to key on one, and a manual charge never carries a marketplace to supply it.
|
|
103
|
+
*
|
|
104
|
+
* "full" is per-meal truthful (each meal's own effectiveAmount is what came back); "partial" is
|
|
105
|
+
* charge-level and deliberately carries no per-meal figure — one charge covers several meals, and
|
|
106
|
+
* splitting a partial refund across them would invent numbers nobody agreed to.
|
|
107
|
+
*/
|
|
108
|
+
markDiningChargeRefunded(params) {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
const { jwt, sellerId, endUserId, chargeId, refundState, refundedTotal } = params;
|
|
111
|
+
if (!jwt || !sellerId || !endUserId || !chargeId || !refundState) {
|
|
112
|
+
throw new error_handler_1.CustomError("param_are_missing_in_markDiningChargeRefunded", 400, `params are: ${JSON.stringify({ sellerId, endUserId, chargeId, refundState })}`);
|
|
113
|
+
}
|
|
114
|
+
const response = yield axios_1.default.post(`${crmUrl}/dining/charges/refunded/${sellerId}/${endUserId}`, Object.assign({ chargeId, refundState }, (refundedTotal === undefined ? {} : { refundedTotal })), { headers: { jwt } });
|
|
115
|
+
return response === null || response === void 0 ? void 0 : response.data;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
75
118
|
getDiningBalance(params) {
|
|
76
119
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
120
|
const { jwt, marketplaceId, sellerId, endUserId } = params;
|
package/dist/src/crm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crm.js","sourceRoot":"","sources":["../../src/crm.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,wDAAmD;AAGnD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;AAClC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC;AAC7F,MAAM,MAAM,GAAG,GAAG,QAAQ,MAAM,CAAC;AAEjC,MAAa,SAAS;IACd,yBAAyB,CAAC,MAAsF;;YACpH,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;YAC9D,IAAI,CAAC,GAAG,IAAI,CAAC,aAAa,IAAI,CAAC,QAAQ,IAAI,CAAC,YAAY,EAAE,CAAC;gBACzD,MAAM,IAAI,2BAAW,CAAC,gDAAgD,EAAE,GAAG,EAAE,eAAe,MAAM,EAAE,CAAC,CAAC;YACxG,CAAC;YACD,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC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json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nimee/api-clients",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.119",
|
|
4
4
|
"description": "communication http for each ms",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"author": "dan goldberg",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@nimee/error-handler": "0.0.14",
|
|
40
40
|
"@nimee/logger": "^1.0.27",
|
|
41
|
-
"@nimee/shared-types": "^1.0.
|
|
41
|
+
"@nimee/shared-types": "^1.0.336",
|
|
42
42
|
"axios": "1.2.1"
|
|
43
43
|
}
|
|
44
44
|
}
|
package/src/crm.ts
CHANGED
|
@@ -51,7 +51,16 @@ export class CrmClient {
|
|
|
51
51
|
scannerSessionId: string;
|
|
52
52
|
}): Promise<{ visit: any; todayVisits: any[] }> {
|
|
53
53
|
const { jwt, marketplaceId, sellerId, endUserId, guests, endUserSeasonTicketId, seasonTicketId, scannerSessionId } = params;
|
|
54
|
-
if (
|
|
54
|
+
if (
|
|
55
|
+
!jwt ||
|
|
56
|
+
!marketplaceId ||
|
|
57
|
+
!sellerId ||
|
|
58
|
+
!endUserId ||
|
|
59
|
+
!endUserSeasonTicketId ||
|
|
60
|
+
!seasonTicketId ||
|
|
61
|
+
!scannerSessionId ||
|
|
62
|
+
guests === undefined
|
|
63
|
+
) {
|
|
55
64
|
throw new CustomError("param_are_missing_in_createAutoExitVisit", 400, `params are: ${JSON.stringify(params)}`);
|
|
56
65
|
}
|
|
57
66
|
const response = await axios.post(
|
|
@@ -94,6 +103,71 @@ export class CrmClient {
|
|
|
94
103
|
return response?.data;
|
|
95
104
|
}
|
|
96
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Settles exactly the given commits against a charge the caller already created (e.g. via
|
|
108
|
+
* `chargeEndUser`). Forwards the caller's `jwt` header — CRM derives `settledBy`/`settledByName`
|
|
109
|
+
* from that JWT itself, same as `settle-selected`'s other callers.
|
|
110
|
+
*/
|
|
111
|
+
async settleSelectedDining(params: {
|
|
112
|
+
jwt: string;
|
|
113
|
+
marketplaceId: string;
|
|
114
|
+
sellerId: string;
|
|
115
|
+
endUserId: string;
|
|
116
|
+
commitIds: string[];
|
|
117
|
+
chargeId: string;
|
|
118
|
+
}): Promise<{ settledCount: number; total: number; balance: number }> {
|
|
119
|
+
const { jwt, marketplaceId, sellerId, endUserId, commitIds, chargeId } = params;
|
|
120
|
+
if (!jwt || !marketplaceId || !sellerId || !endUserId || !commitIds?.length || !chargeId) {
|
|
121
|
+
throw new CustomError(
|
|
122
|
+
"param_are_missing_in_settleSelectedDining",
|
|
123
|
+
400,
|
|
124
|
+
`params are: ${JSON.stringify({ marketplaceId, sellerId, endUserId, commitIds, chargeId })}`
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
const response = await axios.post(
|
|
128
|
+
`${crmUrl}/dining/commits/settle-selected/${marketplaceId}/${sellerId}/${endUserId}`,
|
|
129
|
+
{ commitIds, chargeId },
|
|
130
|
+
{ headers: { jwt } }
|
|
131
|
+
);
|
|
132
|
+
return response?.data;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* INTERNAL. Stamps the refund state of a charge onto the meals that charge collected, so the
|
|
137
|
+
* guest's own dining page can show the money came back. `jwt` must be JWT_ADMIN — the CRM route
|
|
138
|
+
* compares it literally before verifying anything, because a seller token proves identity, not
|
|
139
|
+
* the right to rewrite a member's meal history. No marketplaceId in the path: that route has no
|
|
140
|
+
* `checkRole` to key on one, and a manual charge never carries a marketplace to supply it.
|
|
141
|
+
*
|
|
142
|
+
* "full" is per-meal truthful (each meal's own effectiveAmount is what came back); "partial" is
|
|
143
|
+
* charge-level and deliberately carries no per-meal figure — one charge covers several meals, and
|
|
144
|
+
* splitting a partial refund across them would invent numbers nobody agreed to.
|
|
145
|
+
*/
|
|
146
|
+
async markDiningChargeRefunded(params: {
|
|
147
|
+
jwt: string;
|
|
148
|
+
sellerId: string;
|
|
149
|
+
endUserId: string;
|
|
150
|
+
chargeId: string;
|
|
151
|
+
refundState: "partial" | "full";
|
|
152
|
+
/** Everything returned against this charge so far, in SHEKELS — CRM apportions it across the meals. */
|
|
153
|
+
refundedTotal?: number;
|
|
154
|
+
}): Promise<{ updatedCommits: number }> {
|
|
155
|
+
const { jwt, sellerId, endUserId, chargeId, refundState, refundedTotal } = params;
|
|
156
|
+
if (!jwt || !sellerId || !endUserId || !chargeId || !refundState) {
|
|
157
|
+
throw new CustomError(
|
|
158
|
+
"param_are_missing_in_markDiningChargeRefunded",
|
|
159
|
+
400,
|
|
160
|
+
`params are: ${JSON.stringify({ sellerId, endUserId, chargeId, refundState })}`
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
const response = await axios.post(
|
|
164
|
+
`${crmUrl}/dining/charges/refunded/${sellerId}/${endUserId}`,
|
|
165
|
+
{ chargeId, refundState, ...(refundedTotal === undefined ? {} : { refundedTotal }) },
|
|
166
|
+
{ headers: { jwt } }
|
|
167
|
+
);
|
|
168
|
+
return response?.data;
|
|
169
|
+
}
|
|
170
|
+
|
|
97
171
|
async getDiningBalance(params: {
|
|
98
172
|
jwt: string;
|
|
99
173
|
marketplaceId: string;
|