@unboundcx/sdk 4.13.152 → 4.13.153
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.153",
|
|
4
4
|
"description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -46,6 +46,75 @@ export class DiscountApprovalsService {
|
|
|
46
46
|
body,
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Round-2 fix 1 (margin-in-discount-popover) -- numbers-free D9 dry-run
|
|
52
|
+
* for one or more lines on an opportunity. Never locks or writes
|
|
53
|
+
* anything server-side. `marginPercent` is included on each returned
|
|
54
|
+
* line ONLY when the calling session holds `crm:margin:view` -- this
|
|
55
|
+
* method never asks for it and can't force it; everyone else gets
|
|
56
|
+
* `belowMarginFloor` only.
|
|
57
|
+
* @param {string} opportunityId
|
|
58
|
+
* @param {Array<{lineId: string, price?: number, discountType?: 'percent'|'amount', discountValue?: number}>} lines
|
|
59
|
+
* @returns {Promise<{lines: Array<{lineId: string, belowMarginFloor: boolean, marginPercent?: number}>}>}
|
|
60
|
+
*/
|
|
61
|
+
async marginPreview(opportunityId, lines) {
|
|
62
|
+
this.sdk.validateParams(
|
|
63
|
+
{ opportunityId, lines },
|
|
64
|
+
{
|
|
65
|
+
opportunityId: { type: 'string', required: true },
|
|
66
|
+
lines: { type: 'array', required: true },
|
|
67
|
+
},
|
|
68
|
+
);
|
|
69
|
+
return internalRequest(
|
|
70
|
+
this.sdk,
|
|
71
|
+
'/discount-approvals/margin-preview',
|
|
72
|
+
'POST',
|
|
73
|
+
{ body: { opportunityId, lines } },
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Round-2 fix 3 (bulk discount) -- one `discountType`/`discountValue`
|
|
79
|
+
* applied to every line in `lineIds`, through ONE `evaluateLineWrite`
|
|
80
|
+
* call -> at most one `discountApprovals` row for the whole selection,
|
|
81
|
+
* never one request per line. `discountValue` with
|
|
82
|
+
* `discountType='amount'` is a PER-UNIT amount off each selected
|
|
83
|
+
* line's own listPrice (the same semantics a single-line
|
|
84
|
+
* `discountType='amount'` edit already has) -- never prorated across
|
|
85
|
+
* the selection. Lines that are closed/locked, already have a pending
|
|
86
|
+
* discount request, or aren't found are skipped server-side and
|
|
87
|
+
* reported back in `skipped`, never merged or silently dropped.
|
|
88
|
+
* @param {string} opportunityId
|
|
89
|
+
* @param {string[]} lineIds
|
|
90
|
+
* @param {Object} options
|
|
91
|
+
* @param {'percent'|'amount'} options.discountType
|
|
92
|
+
* @param {number} options.discountValue
|
|
93
|
+
* @param {string} [options.reason]
|
|
94
|
+
* @returns {Promise<{opportunityId: string, committed: string[], held: string[], skipped: Array<{lineId: string, reason: string}>, skippedCount: number, rollup: Object}>}
|
|
95
|
+
*/
|
|
96
|
+
async bulkDiscount(opportunityId, lineIds, { discountType, discountValue, reason } = {}) {
|
|
97
|
+
this.sdk.validateParams(
|
|
98
|
+
{ opportunityId, lineIds, discountType, discountValue },
|
|
99
|
+
{
|
|
100
|
+
opportunityId: { type: 'string', required: true },
|
|
101
|
+
lineIds: { type: 'array', required: true },
|
|
102
|
+
discountType: { type: 'string', required: true },
|
|
103
|
+
discountValue: { type: 'number', required: true },
|
|
104
|
+
},
|
|
105
|
+
);
|
|
106
|
+
if (!['percent', 'amount'].includes(discountType)) {
|
|
107
|
+
throw new Error("discountType must be one of 'percent', 'amount'");
|
|
108
|
+
}
|
|
109
|
+
const body = { opportunityId, lineIds, discountType, discountValue };
|
|
110
|
+
if (reason !== undefined) body.reason = reason;
|
|
111
|
+
return internalRequest(
|
|
112
|
+
this.sdk,
|
|
113
|
+
'/discount-approvals/bulk-discount',
|
|
114
|
+
'POST',
|
|
115
|
+
{ body },
|
|
116
|
+
);
|
|
117
|
+
}
|
|
49
118
|
}
|
|
50
119
|
|
|
51
120
|
export default DiscountApprovalsService;
|