@learnorama/mozaik-sdk 0.12.3-staging.46.1 → 0.13.0-staging.48.1
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/README.md +25 -0
- package/dist/api/account.d.ts +1 -1
- package/dist/api/account.js.map +1 -1
- package/dist/api/admin-catalogue.d.ts +1 -1
- package/dist/api/admin-catalogue.js.map +1 -1
- package/dist/api/admin-consumption.d.ts +1 -1
- package/dist/api/admin-consumption.js.map +1 -1
- package/dist/api/admin-contracts.d.ts +1 -1
- package/dist/api/admin-contracts.js.map +1 -1
- package/dist/api/admin-desk.d.ts +1 -1
- package/dist/api/admin-desk.js.map +1 -1
- package/dist/api/admin-licenses.d.ts +1 -1
- package/dist/api/admin-licenses.js.map +1 -1
- package/dist/api/admin-partner-selections.d.ts +1 -1
- package/dist/api/admin-partner-selections.js.map +1 -1
- package/dist/api/admin-patrons.d.ts +1 -1
- package/dist/api/admin-patrons.js.map +1 -1
- package/dist/api/admin-reviews.d.ts +1 -1
- package/dist/api/admin-reviews.js.map +1 -1
- package/dist/api/admin-roles.d.ts +1 -1
- package/dist/api/admin-roles.js.map +1 -1
- package/dist/api/admin-support.d.ts +1 -1
- package/dist/api/admin-support.js.map +1 -1
- package/dist/api/admin-tenants.d.ts +1 -1
- package/dist/api/admin-tenants.js.map +1 -1
- package/dist/api/admin-tutoring.d.ts +1 -1
- package/dist/api/admin-tutoring.js.map +1 -1
- package/dist/api/auth.d.ts +1 -1
- package/dist/api/auth.js.map +1 -1
- package/dist/api/biblio-billing-webhooks.d.ts +18 -0
- package/dist/api/biblio-billing-webhooks.js +62 -0
- package/dist/api/biblio-billing-webhooks.js.map +1 -0
- package/dist/api/biblio-billing.d.ts +192 -0
- package/dist/api/biblio-billing.js +645 -0
- package/dist/api/biblio-billing.js.map +1 -0
- package/dist/api/biblio-catalogue.d.ts +1 -1
- package/dist/api/biblio-catalogue.js.map +1 -1
- package/dist/api/biblio-home.d.ts +1 -1
- package/dist/api/biblio-home.js.map +1 -1
- package/dist/api/biblio-learning-author-profiles.d.ts +108 -0
- package/dist/api/biblio-learning-author-profiles.js +331 -0
- package/dist/api/biblio-learning-author-profiles.js.map +1 -0
- package/dist/api/biblio-learning-authoring.d.ts +168 -0
- package/dist/api/biblio-learning-authoring.js +586 -0
- package/dist/api/biblio-learning-authoring.js.map +1 -0
- package/dist/api/biblio-learning-editorial.d.ts +54 -0
- package/dist/api/biblio-learning-editorial.js +149 -0
- package/dist/api/biblio-learning-editorial.js.map +1 -0
- package/dist/api/biblio-learning-feedback.d.ts +60 -0
- package/dist/api/biblio-learning-feedback.js +180 -0
- package/dist/api/biblio-learning-feedback.js.map +1 -0
- package/dist/api/biblio-learning-finance.d.ts +186 -0
- package/dist/api/biblio-learning-finance.js +622 -0
- package/dist/api/biblio-learning-finance.js.map +1 -0
- package/dist/api/biblio-learning-integrations.d.ts +60 -0
- package/dist/api/biblio-learning-integrations.js +215 -0
- package/dist/api/biblio-learning-integrations.js.map +1 -0
- package/dist/api/biblio-learning-membership.d.ts +24 -0
- package/dist/api/biblio-learning-membership.js +69 -0
- package/dist/api/biblio-learning-membership.js.map +1 -0
- package/dist/api/biblio-learning.d.ts +222 -0
- package/dist/api/biblio-learning.js +697 -0
- package/dist/api/biblio-learning.js.map +1 -0
- package/dist/api/biblio-library.d.ts +1 -1
- package/dist/api/biblio-library.js.map +1 -1
- package/dist/api/biblio-nextory.d.ts +1 -1
- package/dist/api/biblio-nextory.js.map +1 -1
- package/dist/api/biblio-press.d.ts +1 -1
- package/dist/api/biblio-press.js.map +1 -1
- package/dist/api/biblio-search.d.ts +1 -1
- package/dist/api/biblio-search.js.map +1 -1
- package/dist/api/biblio-telemetry.d.ts +1 -1
- package/dist/api/biblio-telemetry.js.map +1 -1
- package/dist/api/consumption.d.ts +1 -1
- package/dist/api/consumption.js.map +1 -1
- package/dist/api/cvs-app.d.ts +1 -1
- package/dist/api/cvs-app.js.map +1 -1
- package/dist/api/cvs-documents.d.ts +1 -1
- package/dist/api/cvs-documents.js.map +1 -1
- package/dist/api/cvs-favorites.d.ts +1 -1
- package/dist/api/cvs-favorites.js.map +1 -1
- package/dist/api/cvs-ils.d.ts +1 -1
- package/dist/api/cvs-ils.js.map +1 -1
- package/dist/api/cvs-loans.d.ts +1 -1
- package/dist/api/cvs-loans.js.map +1 -1
- package/dist/api/cvs-payments.d.ts +1 -1
- package/dist/api/cvs-payments.js.map +1 -1
- package/dist/api/cvs-streaming.d.ts +1 -1
- package/dist/api/cvs-streaming.js.map +1 -1
- package/dist/api/index.d.ts +11 -1
- package/dist/api/index.js +11 -1
- package/dist/api/partner-catalogue.d.ts +1 -1
- package/dist/api/partner-catalogue.js.map +1 -1
- package/dist/api/partner-reader.d.ts +1 -1
- package/dist/api/partner-reader.js.map +1 -1
- package/dist/api/profiles.d.ts +1 -1
- package/dist/api/profiles.js.map +1 -1
- package/dist/api/search.d.ts +1 -1
- package/dist/api/search.js.map +1 -1
- package/dist/api/tutoring-catalogue.d.ts +1 -1
- package/dist/api/tutoring-catalogue.js.map +1 -1
- package/dist/api/tutoring-chat.d.ts +1 -1
- package/dist/api/tutoring-chat.js.map +1 -1
- package/dist/api/tutoring-dispatch.d.ts +1 -1
- package/dist/api/tutoring-dispatch.js.map +1 -1
- package/dist/api/tutoring-practitioner.d.ts +1 -1
- package/dist/api/tutoring-practitioner.js.map +1 -1
- package/dist/api/tutoring-requests.d.ts +1 -1
- package/dist/api/tutoring-requests.js.map +1 -1
- package/dist/chunks/client2.d.ts +1 -1
- package/dist/chunks/connection.d.ts +1 -1
- package/dist/chunks/index.d.ts +10062 -3487
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +2 -2
- package/dist/models.js +329 -1
- package/dist/models.js.map +1 -1
- package/dist/react/account.d.ts +1 -1
- package/dist/react/account.js +1 -1
- package/dist/react/account.js.map +1 -1
- package/dist/react/admin-catalogue.d.ts +1 -1
- package/dist/react/admin-catalogue.js +1 -1
- package/dist/react/admin-catalogue.js.map +1 -1
- package/dist/react/admin-consumption.d.ts +1 -1
- package/dist/react/admin-consumption.js +1 -1
- package/dist/react/admin-consumption.js.map +1 -1
- package/dist/react/admin-contracts.d.ts +1 -1
- package/dist/react/admin-contracts.js +1 -1
- package/dist/react/admin-contracts.js.map +1 -1
- package/dist/react/admin-desk.d.ts +1 -1
- package/dist/react/admin-desk.js +1 -1
- package/dist/react/admin-desk.js.map +1 -1
- package/dist/react/admin-licenses.d.ts +1 -1
- package/dist/react/admin-licenses.js +1 -1
- package/dist/react/admin-licenses.js.map +1 -1
- package/dist/react/admin-partner-selections.d.ts +1 -1
- package/dist/react/admin-partner-selections.js +1 -1
- package/dist/react/admin-partner-selections.js.map +1 -1
- package/dist/react/admin-patrons.d.ts +1 -1
- package/dist/react/admin-patrons.js +1 -1
- package/dist/react/admin-patrons.js.map +1 -1
- package/dist/react/admin-reviews.d.ts +1 -1
- package/dist/react/admin-reviews.js +1 -1
- package/dist/react/admin-reviews.js.map +1 -1
- package/dist/react/admin-roles.d.ts +1 -1
- package/dist/react/admin-roles.js +1 -1
- package/dist/react/admin-roles.js.map +1 -1
- package/dist/react/admin-support.d.ts +1 -1
- package/dist/react/admin-support.js +1 -1
- package/dist/react/admin-support.js.map +1 -1
- package/dist/react/admin-tenants.d.ts +1 -1
- package/dist/react/admin-tenants.js +1 -1
- package/dist/react/admin-tenants.js.map +1 -1
- package/dist/react/admin-tutoring.d.ts +1 -1
- package/dist/react/admin-tutoring.js +1 -1
- package/dist/react/admin-tutoring.js.map +1 -1
- package/dist/react/auth.d.ts +1 -1
- package/dist/react/auth.js +1 -1
- package/dist/react/auth.js.map +1 -1
- package/dist/react/biblio-billing-webhooks.d.ts +56 -0
- package/dist/react/biblio-billing-webhooks.js +126 -0
- package/dist/react/biblio-billing-webhooks.js.map +1 -0
- package/dist/react/biblio-billing.d.ts +876 -0
- package/dist/react/biblio-billing.js +1491 -0
- package/dist/react/biblio-billing.js.map +1 -0
- package/dist/react/biblio-catalogue.d.ts +1 -1
- package/dist/react/biblio-catalogue.js +1 -1
- package/dist/react/biblio-catalogue.js.map +1 -1
- package/dist/react/biblio-home.d.ts +1 -1
- package/dist/react/biblio-home.js +1 -1
- package/dist/react/biblio-home.js.map +1 -1
- package/dist/react/biblio-learning-author-profiles.d.ts +513 -0
- package/dist/react/biblio-learning-author-profiles.js +795 -0
- package/dist/react/biblio-learning-author-profiles.js.map +1 -0
- package/dist/react/biblio-learning-authoring.d.ts +745 -0
- package/dist/react/biblio-learning-authoring.js +1335 -0
- package/dist/react/biblio-learning-authoring.js.map +1 -0
- package/dist/react/biblio-learning-editorial.d.ts +264 -0
- package/dist/react/biblio-learning-editorial.js +371 -0
- package/dist/react/biblio-learning-editorial.js.map +1 -0
- package/dist/react/biblio-learning-feedback.d.ts +280 -0
- package/dist/react/biblio-learning-feedback.js +433 -0
- package/dist/react/biblio-learning-feedback.js.map +1 -0
- package/dist/react/biblio-learning-finance.d.ts +868 -0
- package/dist/react/biblio-learning-finance.js +1439 -0
- package/dist/react/biblio-learning-finance.js.map +1 -0
- package/dist/react/biblio-learning-integrations.d.ts +237 -0
- package/dist/react/biblio-learning-integrations.js +483 -0
- package/dist/react/biblio-learning-integrations.js.map +1 -0
- package/dist/react/biblio-learning-membership.d.ts +99 -0
- package/dist/react/biblio-learning-membership.js +165 -0
- package/dist/react/biblio-learning-membership.js.map +1 -0
- package/dist/react/biblio-learning.d.ts +1047 -0
- package/dist/react/biblio-learning.js +1667 -0
- package/dist/react/biblio-learning.js.map +1 -0
- package/dist/react/biblio-library.d.ts +1 -1
- package/dist/react/biblio-library.js +1 -1
- package/dist/react/biblio-library.js.map +1 -1
- package/dist/react/biblio-nextory.d.ts +1 -1
- package/dist/react/biblio-nextory.js +1 -1
- package/dist/react/biblio-nextory.js.map +1 -1
- package/dist/react/biblio-press.d.ts +1 -1
- package/dist/react/biblio-press.js +1 -1
- package/dist/react/biblio-press.js.map +1 -1
- package/dist/react/biblio-search.d.ts +1 -1
- package/dist/react/biblio-search.js +1 -1
- package/dist/react/biblio-search.js.map +1 -1
- package/dist/react/biblio-telemetry.d.ts +1 -1
- package/dist/react/biblio-telemetry.js +1 -1
- package/dist/react/biblio-telemetry.js.map +1 -1
- package/dist/react/chat.d.ts +1 -1
- package/dist/react/consumption.d.ts +1 -1
- package/dist/react/consumption.js +1 -1
- package/dist/react/consumption.js.map +1 -1
- package/dist/react/cvs-app.d.ts +1 -1
- package/dist/react/cvs-app.js +1 -1
- package/dist/react/cvs-app.js.map +1 -1
- package/dist/react/cvs-documents.d.ts +1 -1
- package/dist/react/cvs-documents.js +1 -1
- package/dist/react/cvs-documents.js.map +1 -1
- package/dist/react/cvs-favorites.d.ts +1 -1
- package/dist/react/cvs-favorites.js +1 -1
- package/dist/react/cvs-favorites.js.map +1 -1
- package/dist/react/cvs-ils.d.ts +1 -1
- package/dist/react/cvs-ils.js +1 -1
- package/dist/react/cvs-ils.js.map +1 -1
- package/dist/react/cvs-loans.d.ts +1 -1
- package/dist/react/cvs-loans.js +1 -1
- package/dist/react/cvs-loans.js.map +1 -1
- package/dist/react/cvs-payments.d.ts +1 -1
- package/dist/react/cvs-payments.js +1 -1
- package/dist/react/cvs-payments.js.map +1 -1
- package/dist/react/cvs-streaming.d.ts +1 -1
- package/dist/react/cvs-streaming.js +1 -1
- package/dist/react/cvs-streaming.js.map +1 -1
- package/dist/react/index.d.ts +11 -1
- package/dist/react/index.js +11 -1
- package/dist/react/partner-catalogue.d.ts +1 -1
- package/dist/react/partner-catalogue.js +1 -1
- package/dist/react/partner-catalogue.js.map +1 -1
- package/dist/react/partner-reader.d.ts +1 -1
- package/dist/react/partner-reader.js +1 -1
- package/dist/react/partner-reader.js.map +1 -1
- package/dist/react/profiles.d.ts +1 -1
- package/dist/react/profiles.js +1 -1
- package/dist/react/profiles.js.map +1 -1
- package/dist/react/search.d.ts +1 -1
- package/dist/react/search.js +1 -1
- package/dist/react/search.js.map +1 -1
- package/dist/react/tutoring-catalogue.d.ts +1 -1
- package/dist/react/tutoring-catalogue.js +1 -1
- package/dist/react/tutoring-catalogue.js.map +1 -1
- package/dist/react/tutoring-chat.d.ts +1 -1
- package/dist/react/tutoring-chat.js +1 -1
- package/dist/react/tutoring-chat.js.map +1 -1
- package/dist/react/tutoring-dispatch.d.ts +1 -1
- package/dist/react/tutoring-dispatch.js +1 -1
- package/dist/react/tutoring-dispatch.js.map +1 -1
- package/dist/react/tutoring-practitioner.d.ts +1 -1
- package/dist/react/tutoring-practitioner.js +1 -1
- package/dist/react/tutoring-practitioner.js.map +1 -1
- package/dist/react/tutoring-requests.d.ts +1 -1
- package/dist/react/tutoring-requests.js +1 -1
- package/dist/react/tutoring-requests.js.map +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,1491 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { r as request } from "../chunks/client.js";
|
|
3
|
+
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
4
|
+
//#region src/react/biblio-billing/biblio-billing.ts
|
|
5
|
+
/**
|
|
6
|
+
* Generated by orval 🍺
|
|
7
|
+
* Do not edit manually.
|
|
8
|
+
* Mozaik backend
|
|
9
|
+
* Four products behind one API — Biblio, Médiathèques, the partner catalogues (Nextory and YouScribe) and Prof Express. Authentication is Keycloak SSO only, once, for all of them: see the **auth** section below for the browser flow and the three failure modes.
|
|
10
|
+
* OpenAPI spec version: 0.13.0
|
|
11
|
+
*/
|
|
12
|
+
const withQueryKey = (query, queryKey) => {
|
|
13
|
+
const result = { queryKey };
|
|
14
|
+
for (const key of Object.keys(query)) {
|
|
15
|
+
if (key === "queryKey") continue;
|
|
16
|
+
Object.defineProperty(result, key, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
configurable: true,
|
|
19
|
+
get: () => query[key]
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
const getBillingCreateProductUrl = (catalogueId) => {
|
|
25
|
+
return `/billing/catalogues/${catalogueId}/products`;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* A global commercial operator creates an offer and its server-owned net price/tax. New offers default to inactive. Fixed offers need accessMonths or an institutional template; recurring offers cannot use a template. Retention offers require the customer's dated agreement. Requires high-assurance authentication.
|
|
29
|
+
* @summary Create a catalogue billing offer
|
|
30
|
+
*/
|
|
31
|
+
const billingCreateProduct = async (catalogueId, billingProductWrite, options) => {
|
|
32
|
+
const getHeaders = (h) => {
|
|
33
|
+
if (!h) return {};
|
|
34
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
35
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
36
|
+
const headers = {};
|
|
37
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
38
|
+
return headers;
|
|
39
|
+
};
|
|
40
|
+
return request(getBillingCreateProductUrl(catalogueId), {
|
|
41
|
+
...options,
|
|
42
|
+
method: "POST",
|
|
43
|
+
headers: {
|
|
44
|
+
"Content-Type": "application/json",
|
|
45
|
+
...getHeaders(options?.headers)
|
|
46
|
+
},
|
|
47
|
+
body: JSON.stringify(billingProductWrite)
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
const getBillingCreateProductMutationKey = () => ["billingCreateProduct"];
|
|
51
|
+
const getBillingCreateProductMutationOptions = (options) => {
|
|
52
|
+
const mutationKey = getBillingCreateProductMutationKey();
|
|
53
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
54
|
+
...options,
|
|
55
|
+
mutation: {
|
|
56
|
+
...options.mutation,
|
|
57
|
+
mutationKey
|
|
58
|
+
}
|
|
59
|
+
} : {
|
|
60
|
+
mutation: { mutationKey },
|
|
61
|
+
request: void 0
|
|
62
|
+
};
|
|
63
|
+
const mutationFn = (props) => {
|
|
64
|
+
const { catalogueId, data } = props ?? {};
|
|
65
|
+
return billingCreateProduct(catalogueId, data, requestOptions);
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
mutationFn,
|
|
69
|
+
...mutationOptions
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* @summary Create a catalogue billing offer
|
|
74
|
+
*/
|
|
75
|
+
const useBillingCreateProduct = (options, queryClient) => {
|
|
76
|
+
return useMutation(getBillingCreateProductMutationOptions(options), queryClient);
|
|
77
|
+
};
|
|
78
|
+
const getBillingGeneratePromotionsUrl = (catalogueId) => {
|
|
79
|
+
return `/billing/catalogues/${catalogueId}/promotion-batches`;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Create 1–500 independent rules and encrypted distribution codes atomically from one reviewed template. Each code is the optional prefix followed by 20 unambiguous characters; rule.code must be null. rule.quantity is stock per generated rule, not the number of codes. Requires global commercial authority. Requires high-assurance authentication.
|
|
83
|
+
* @summary Generate a bounded promotion-code batch
|
|
84
|
+
*/
|
|
85
|
+
const billingGeneratePromotions = async (catalogueId, promotionGeneratorWrite, options) => {
|
|
86
|
+
const getHeaders = (h) => {
|
|
87
|
+
if (!h) return {};
|
|
88
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
89
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
90
|
+
const headers = {};
|
|
91
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
92
|
+
return headers;
|
|
93
|
+
};
|
|
94
|
+
return request(getBillingGeneratePromotionsUrl(catalogueId), {
|
|
95
|
+
...options,
|
|
96
|
+
method: "POST",
|
|
97
|
+
headers: {
|
|
98
|
+
"Content-Type": "application/json",
|
|
99
|
+
...getHeaders(options?.headers)
|
|
100
|
+
},
|
|
101
|
+
body: JSON.stringify(promotionGeneratorWrite)
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
const getBillingGeneratePromotionsMutationKey = () => ["billingGeneratePromotions"];
|
|
105
|
+
const getBillingGeneratePromotionsMutationOptions = (options) => {
|
|
106
|
+
const mutationKey = getBillingGeneratePromotionsMutationKey();
|
|
107
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
108
|
+
...options,
|
|
109
|
+
mutation: {
|
|
110
|
+
...options.mutation,
|
|
111
|
+
mutationKey
|
|
112
|
+
}
|
|
113
|
+
} : {
|
|
114
|
+
mutation: { mutationKey },
|
|
115
|
+
request: void 0
|
|
116
|
+
};
|
|
117
|
+
const mutationFn = (props) => {
|
|
118
|
+
const { catalogueId, data } = props ?? {};
|
|
119
|
+
return billingGeneratePromotions(catalogueId, data, requestOptions);
|
|
120
|
+
};
|
|
121
|
+
return {
|
|
122
|
+
mutationFn,
|
|
123
|
+
...mutationOptions
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* @summary Generate a bounded promotion-code batch
|
|
128
|
+
*/
|
|
129
|
+
const useBillingGeneratePromotions = (options, queryClient) => {
|
|
130
|
+
return useMutation(getBillingGeneratePromotionsMutationOptions(options), queryClient);
|
|
131
|
+
};
|
|
132
|
+
const getBillingPromotionGeneratorsUrl = (catalogueId, params) => {
|
|
133
|
+
const normalizedParams = new URLSearchParams();
|
|
134
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
135
|
+
if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
|
|
136
|
+
});
|
|
137
|
+
const stringifiedParams = normalizedParams.toString();
|
|
138
|
+
return stringifiedParams.length > 0 ? `/billing/catalogues/${catalogueId}/promotion-generators?${stringifiedParams}` : `/billing/catalogues/${catalogueId}/promotion-generators`;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Global commercial operators list safe generator definitions, newest first. Includes historical sourceMask and partial rule fields when known; codes and private source metadata require a separate audited export.
|
|
142
|
+
* @summary List catalogue promotion generators
|
|
143
|
+
*/
|
|
144
|
+
const billingPromotionGenerators = async (catalogueId, params, options) => {
|
|
145
|
+
return request(getBillingPromotionGeneratorsUrl(catalogueId, params), {
|
|
146
|
+
...options,
|
|
147
|
+
method: "GET"
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
const getBillingPromotionGeneratorsQueryKey = (catalogueId, params) => {
|
|
151
|
+
return [`/billing/catalogues/${catalogueId}/promotion-generators`, ...params ? [params] : []];
|
|
152
|
+
};
|
|
153
|
+
const getBillingPromotionGeneratorsQueryOptions = (catalogueId, params, options) => {
|
|
154
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
155
|
+
const queryKey = queryOptions?.queryKey ?? getBillingPromotionGeneratorsQueryKey(catalogueId, params);
|
|
156
|
+
const queryFn = ({ signal }) => billingPromotionGenerators(catalogueId, params, {
|
|
157
|
+
signal,
|
|
158
|
+
...requestOptions
|
|
159
|
+
});
|
|
160
|
+
return {
|
|
161
|
+
queryKey,
|
|
162
|
+
queryFn,
|
|
163
|
+
enabled: catalogueId !== null && catalogueId !== void 0,
|
|
164
|
+
...queryOptions
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* @summary List catalogue promotion generators
|
|
169
|
+
*/
|
|
170
|
+
function useBillingPromotionGenerators(catalogueId, params, options, queryClient) {
|
|
171
|
+
const queryOptions = getBillingPromotionGeneratorsQueryOptions(catalogueId, params, options);
|
|
172
|
+
const query = useQuery(queryOptions, queryClient);
|
|
173
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
174
|
+
}
|
|
175
|
+
const getBillingListPromotionsUrl = (catalogueId, params) => {
|
|
176
|
+
const normalizedParams = new URLSearchParams();
|
|
177
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
178
|
+
if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
|
|
179
|
+
});
|
|
180
|
+
const stringifiedParams = normalizedParams.toString();
|
|
181
|
+
return stringifiedParams.length > 0 ? `/billing/catalogues/${catalogueId}/promotions?${stringifiedParams}` : `/billing/catalogues/${catalogueId}/promotions`;
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Catalogue finance operators list rule metadata, including inactive rules, ordered by promotion ID. Codes are deliberately omitted; explicit audited reveal or export is required to distribute codes.
|
|
185
|
+
* @summary List catalogue promotion rules
|
|
186
|
+
*/
|
|
187
|
+
const billingListPromotions = async (catalogueId, params, options) => {
|
|
188
|
+
return request(getBillingListPromotionsUrl(catalogueId, params), {
|
|
189
|
+
...options,
|
|
190
|
+
method: "GET"
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
const getBillingListPromotionsQueryKey = (catalogueId, params) => {
|
|
194
|
+
return [`/billing/catalogues/${catalogueId}/promotions`, ...params ? [params] : []];
|
|
195
|
+
};
|
|
196
|
+
const getBillingListPromotionsQueryOptions = (catalogueId, params, options) => {
|
|
197
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
198
|
+
const queryKey = queryOptions?.queryKey ?? getBillingListPromotionsQueryKey(catalogueId, params);
|
|
199
|
+
const queryFn = ({ signal }) => billingListPromotions(catalogueId, params, {
|
|
200
|
+
signal,
|
|
201
|
+
...requestOptions
|
|
202
|
+
});
|
|
203
|
+
return {
|
|
204
|
+
queryKey,
|
|
205
|
+
queryFn,
|
|
206
|
+
enabled: catalogueId !== null && catalogueId !== void 0,
|
|
207
|
+
...queryOptions
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* @summary List catalogue promotion rules
|
|
212
|
+
*/
|
|
213
|
+
function useBillingListPromotions(catalogueId, params, options, queryClient) {
|
|
214
|
+
const queryOptions = getBillingListPromotionsQueryOptions(catalogueId, params, options);
|
|
215
|
+
const query = useQuery(queryOptions, queryClient);
|
|
216
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
217
|
+
}
|
|
218
|
+
const getBillingCreatePromotionUrl = (catalogueId) => {
|
|
219
|
+
return `/billing/catalogues/${catalogueId}/promotions`;
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* A global commercial operator creates bounded promotion stock for a catalogue. Discounts apply to explicit checkouts; benefits without payment-method requirements can be redeemed directly. Null code generates three groups of six unambiguous characters. Explicit codes retain their display form; lookup uses NFKC, trim and casefold normalization. Targets must belong to the catalogue. Requires high-assurance authentication.
|
|
223
|
+
* @summary Create a discount or access benefit
|
|
224
|
+
*/
|
|
225
|
+
const billingCreatePromotion = async (catalogueId, promotionWrite, options) => {
|
|
226
|
+
const getHeaders = (h) => {
|
|
227
|
+
if (!h) return {};
|
|
228
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
229
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
230
|
+
const headers = {};
|
|
231
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
232
|
+
return headers;
|
|
233
|
+
};
|
|
234
|
+
return request(getBillingCreatePromotionUrl(catalogueId), {
|
|
235
|
+
...options,
|
|
236
|
+
method: "POST",
|
|
237
|
+
headers: {
|
|
238
|
+
"Content-Type": "application/json",
|
|
239
|
+
...getHeaders(options?.headers)
|
|
240
|
+
},
|
|
241
|
+
body: JSON.stringify(promotionWrite)
|
|
242
|
+
});
|
|
243
|
+
};
|
|
244
|
+
const getBillingCreatePromotionMutationKey = () => ["billingCreatePromotion"];
|
|
245
|
+
const getBillingCreatePromotionMutationOptions = (options) => {
|
|
246
|
+
const mutationKey = getBillingCreatePromotionMutationKey();
|
|
247
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
248
|
+
...options,
|
|
249
|
+
mutation: {
|
|
250
|
+
...options.mutation,
|
|
251
|
+
mutationKey
|
|
252
|
+
}
|
|
253
|
+
} : {
|
|
254
|
+
mutation: { mutationKey },
|
|
255
|
+
request: void 0
|
|
256
|
+
};
|
|
257
|
+
const mutationFn = (props) => {
|
|
258
|
+
const { catalogueId, data } = props ?? {};
|
|
259
|
+
return billingCreatePromotion(catalogueId, data, requestOptions);
|
|
260
|
+
};
|
|
261
|
+
return {
|
|
262
|
+
mutationFn,
|
|
263
|
+
...mutationOptions
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* @summary Create a discount or access benefit
|
|
268
|
+
*/
|
|
269
|
+
const useBillingCreatePromotion = (options, queryClient) => {
|
|
270
|
+
return useMutation(getBillingCreatePromotionMutationOptions(options), queryClient);
|
|
271
|
+
};
|
|
272
|
+
const getBillingExportPromotionCodesUrl = (catalogueId) => {
|
|
273
|
+
return `/billing/catalogues/${catalogueId}/promotions/export`;
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* Global commercial operators decrypt selected catalogue codes in one audited transaction. Supply unique promotionIds and a reason; all IDs must belong to the selected catalogue or the entire export is refused. The JSON data is ordered by promotion ID. Responses are private, no-store. Requires high-assurance authentication.
|
|
277
|
+
* @summary Export selected promotion codes with an audit reason
|
|
278
|
+
*/
|
|
279
|
+
const billingExportPromotionCodes = async (catalogueId, promotionExportWrite, options) => {
|
|
280
|
+
const getHeaders = (h) => {
|
|
281
|
+
if (!h) return {};
|
|
282
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
283
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
284
|
+
const headers = {};
|
|
285
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
286
|
+
return headers;
|
|
287
|
+
};
|
|
288
|
+
return request(getBillingExportPromotionCodesUrl(catalogueId), {
|
|
289
|
+
...options,
|
|
290
|
+
method: "POST",
|
|
291
|
+
headers: {
|
|
292
|
+
"Content-Type": "application/json",
|
|
293
|
+
...getHeaders(options?.headers)
|
|
294
|
+
},
|
|
295
|
+
body: JSON.stringify(promotionExportWrite)
|
|
296
|
+
});
|
|
297
|
+
};
|
|
298
|
+
const getBillingExportPromotionCodesMutationKey = () => ["billingExportPromotionCodes"];
|
|
299
|
+
const getBillingExportPromotionCodesMutationOptions = (options) => {
|
|
300
|
+
const mutationKey = getBillingExportPromotionCodesMutationKey();
|
|
301
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
302
|
+
...options,
|
|
303
|
+
mutation: {
|
|
304
|
+
...options.mutation,
|
|
305
|
+
mutationKey
|
|
306
|
+
}
|
|
307
|
+
} : {
|
|
308
|
+
mutation: { mutationKey },
|
|
309
|
+
request: void 0
|
|
310
|
+
};
|
|
311
|
+
const mutationFn = (props) => {
|
|
312
|
+
const { catalogueId, data } = props ?? {};
|
|
313
|
+
return billingExportPromotionCodes(catalogueId, data, requestOptions);
|
|
314
|
+
};
|
|
315
|
+
return {
|
|
316
|
+
mutationFn,
|
|
317
|
+
...mutationOptions
|
|
318
|
+
};
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* @summary Export selected promotion codes with an audit reason
|
|
322
|
+
*/
|
|
323
|
+
const useBillingExportPromotionCodes = (options, queryClient) => {
|
|
324
|
+
return useMutation(getBillingExportPromotionCodesMutationOptions(options), queryClient);
|
|
325
|
+
};
|
|
326
|
+
const getBillingQuoteCheckoutUrl = () => {
|
|
327
|
+
return `/billing/checkouts`;
|
|
328
|
+
};
|
|
329
|
+
/**
|
|
330
|
+
* Freeze server-priced purchase and renewal terms for 15 minutes and reserve promotion stock. Reuse requestKey with the same product and normalized promotion set to retrieve the same checkout; changing either under the same key returns 409. No payment is submitted by quoting. Display recurring, renewalAmount and expiresAt before obtaining consent. A fully discounted offer without a required payment method can become fixed access without renewal. Uses the authenticated independent profile in the Biblio product context; support impersonation is refused. Responses are private and must not be cached. Requires high-assurance authentication.
|
|
331
|
+
* @summary Quote a personal checkout
|
|
332
|
+
*/
|
|
333
|
+
const billingQuoteCheckout = async (billingQuoteWrite, options) => {
|
|
334
|
+
const getHeaders = (h) => {
|
|
335
|
+
if (!h) return {};
|
|
336
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
337
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
338
|
+
const headers = {};
|
|
339
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
340
|
+
return headers;
|
|
341
|
+
};
|
|
342
|
+
return request(getBillingQuoteCheckoutUrl(), {
|
|
343
|
+
...options,
|
|
344
|
+
method: "POST",
|
|
345
|
+
headers: {
|
|
346
|
+
"Content-Type": "application/json",
|
|
347
|
+
...getHeaders(options?.headers)
|
|
348
|
+
},
|
|
349
|
+
body: JSON.stringify(billingQuoteWrite)
|
|
350
|
+
});
|
|
351
|
+
};
|
|
352
|
+
const getBillingQuoteCheckoutMutationKey = () => ["billingQuoteCheckout"];
|
|
353
|
+
const getBillingQuoteCheckoutMutationOptions = (options) => {
|
|
354
|
+
const mutationKey = getBillingQuoteCheckoutMutationKey();
|
|
355
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
356
|
+
...options,
|
|
357
|
+
mutation: {
|
|
358
|
+
...options.mutation,
|
|
359
|
+
mutationKey
|
|
360
|
+
}
|
|
361
|
+
} : {
|
|
362
|
+
mutation: { mutationKey },
|
|
363
|
+
request: void 0
|
|
364
|
+
};
|
|
365
|
+
const mutationFn = (props) => {
|
|
366
|
+
const { data } = props ?? {};
|
|
367
|
+
return billingQuoteCheckout(data, requestOptions);
|
|
368
|
+
};
|
|
369
|
+
return {
|
|
370
|
+
mutationFn,
|
|
371
|
+
...mutationOptions
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
/**
|
|
375
|
+
* @summary Quote a personal checkout
|
|
376
|
+
*/
|
|
377
|
+
const useBillingQuoteCheckout = (options, queryClient) => {
|
|
378
|
+
return useMutation(getBillingQuoteCheckoutMutationOptions(options), queryClient);
|
|
379
|
+
};
|
|
380
|
+
const getBillingReadCheckoutUrl = (checkoutId) => {
|
|
381
|
+
return `/billing/checkouts/${checkoutId}`;
|
|
382
|
+
};
|
|
383
|
+
/**
|
|
384
|
+
* Return persisted quote and outcome without contacting the payment provider. A submitting or unknown checkout requires the explicit reconcile operation; reading it does not retry payment. Uses the authenticated independent profile in the Biblio product context; support impersonation is refused. Responses are private and must not be cached.
|
|
385
|
+
* @summary Read the current profile's checkout
|
|
386
|
+
*/
|
|
387
|
+
const billingReadCheckout = async (checkoutId, options) => {
|
|
388
|
+
return request(getBillingReadCheckoutUrl(checkoutId), {
|
|
389
|
+
...options,
|
|
390
|
+
method: "GET"
|
|
391
|
+
});
|
|
392
|
+
};
|
|
393
|
+
const getBillingReadCheckoutQueryKey = (checkoutId) => {
|
|
394
|
+
return [`/billing/checkouts/${checkoutId}`];
|
|
395
|
+
};
|
|
396
|
+
const getBillingReadCheckoutQueryOptions = (checkoutId, options) => {
|
|
397
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
398
|
+
const queryKey = queryOptions?.queryKey ?? getBillingReadCheckoutQueryKey(checkoutId);
|
|
399
|
+
const queryFn = ({ signal }) => billingReadCheckout(checkoutId, {
|
|
400
|
+
signal,
|
|
401
|
+
...requestOptions
|
|
402
|
+
});
|
|
403
|
+
return {
|
|
404
|
+
queryKey,
|
|
405
|
+
queryFn,
|
|
406
|
+
enabled: checkoutId !== null && checkoutId !== void 0,
|
|
407
|
+
...queryOptions
|
|
408
|
+
};
|
|
409
|
+
};
|
|
410
|
+
/**
|
|
411
|
+
* @summary Read the current profile's checkout
|
|
412
|
+
*/
|
|
413
|
+
function useBillingReadCheckout(checkoutId, options, queryClient) {
|
|
414
|
+
const queryOptions = getBillingReadCheckoutQueryOptions(checkoutId, options);
|
|
415
|
+
const query = useQuery(queryOptions, queryClient);
|
|
416
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
417
|
+
}
|
|
418
|
+
const getBillingReconcileCheckoutUrl = (checkoutId) => {
|
|
419
|
+
return `/billing/checkouts/${checkoutId}/reconcile`;
|
|
420
|
+
};
|
|
421
|
+
/**
|
|
422
|
+
* Look up provider evidence using the checkout's existing operation identity and complete the same purchase when a matching receipt is found. This never resubmits payment. An absent receipt leaves the checkout submitting or unknown; terminal and quoted states are returned unchanged. Environment and quote integrity must match before access can be granted. Uses the authenticated independent profile in the Biblio product context; support impersonation is refused. Responses are private and must not be cached. Requires high-assurance authentication.
|
|
423
|
+
* @summary Reconcile an uncertain checkout
|
|
424
|
+
*/
|
|
425
|
+
const billingReconcileCheckout = async (checkoutId, options) => {
|
|
426
|
+
return request(getBillingReconcileCheckoutUrl(checkoutId), {
|
|
427
|
+
...options,
|
|
428
|
+
method: "POST"
|
|
429
|
+
});
|
|
430
|
+
};
|
|
431
|
+
const getBillingReconcileCheckoutMutationKey = () => ["billingReconcileCheckout"];
|
|
432
|
+
const getBillingReconcileCheckoutMutationOptions = (options) => {
|
|
433
|
+
const mutationKey = getBillingReconcileCheckoutMutationKey();
|
|
434
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
435
|
+
...options,
|
|
436
|
+
mutation: {
|
|
437
|
+
...options.mutation,
|
|
438
|
+
mutationKey
|
|
439
|
+
}
|
|
440
|
+
} : {
|
|
441
|
+
mutation: { mutationKey },
|
|
442
|
+
request: void 0
|
|
443
|
+
};
|
|
444
|
+
const mutationFn = (props) => {
|
|
445
|
+
const { checkoutId } = props ?? {};
|
|
446
|
+
return billingReconcileCheckout(checkoutId, requestOptions);
|
|
447
|
+
};
|
|
448
|
+
return {
|
|
449
|
+
mutationFn,
|
|
450
|
+
...mutationOptions
|
|
451
|
+
};
|
|
452
|
+
};
|
|
453
|
+
/**
|
|
454
|
+
* @summary Reconcile an uncertain checkout
|
|
455
|
+
*/
|
|
456
|
+
const useBillingReconcileCheckout = (options, queryClient) => {
|
|
457
|
+
return useMutation(getBillingReconcileCheckoutMutationOptions(options), queryClient);
|
|
458
|
+
};
|
|
459
|
+
const getBillingSubmitCheckoutUrl = (checkoutId) => {
|
|
460
|
+
return `/billing/checkouts/${checkoutId}/submit`;
|
|
461
|
+
};
|
|
462
|
+
/**
|
|
463
|
+
* Submit the owned quote with acceptedTerms=true and a single-use provider nonce when payment or renewal requires it. Completed, submitting and unknown checkouts are returned without another charge. HTTP 200 alone does not mean payment succeeded: complete confirms the receipt, failed records a refusal, and unknown preserves an ambiguous provider outcome. Reconcile the same checkout after uncertainty; do not create a replacement payment. Uses the authenticated independent profile in the Biblio product context; support impersonation is refused. Responses are private and must not be cached. Requires high-assurance authentication.
|
|
464
|
+
* @summary Submit an accepted checkout
|
|
465
|
+
*/
|
|
466
|
+
const billingSubmitCheckout = async (checkoutId, billingCheckoutSubmitWrite, options) => {
|
|
467
|
+
const getHeaders = (h) => {
|
|
468
|
+
if (!h) return {};
|
|
469
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
470
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
471
|
+
const headers = {};
|
|
472
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
473
|
+
return headers;
|
|
474
|
+
};
|
|
475
|
+
return request(getBillingSubmitCheckoutUrl(checkoutId), {
|
|
476
|
+
...options,
|
|
477
|
+
method: "POST",
|
|
478
|
+
headers: {
|
|
479
|
+
"Content-Type": "application/json",
|
|
480
|
+
...getHeaders(options?.headers)
|
|
481
|
+
},
|
|
482
|
+
body: JSON.stringify(billingCheckoutSubmitWrite)
|
|
483
|
+
});
|
|
484
|
+
};
|
|
485
|
+
const getBillingSubmitCheckoutMutationKey = () => ["billingSubmitCheckout"];
|
|
486
|
+
const getBillingSubmitCheckoutMutationOptions = (options) => {
|
|
487
|
+
const mutationKey = getBillingSubmitCheckoutMutationKey();
|
|
488
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
489
|
+
...options,
|
|
490
|
+
mutation: {
|
|
491
|
+
...options.mutation,
|
|
492
|
+
mutationKey
|
|
493
|
+
}
|
|
494
|
+
} : {
|
|
495
|
+
mutation: { mutationKey },
|
|
496
|
+
request: void 0
|
|
497
|
+
};
|
|
498
|
+
const mutationFn = (props) => {
|
|
499
|
+
const { checkoutId, data } = props ?? {};
|
|
500
|
+
return billingSubmitCheckout(checkoutId, data, requestOptions);
|
|
501
|
+
};
|
|
502
|
+
return {
|
|
503
|
+
mutationFn,
|
|
504
|
+
...mutationOptions
|
|
505
|
+
};
|
|
506
|
+
};
|
|
507
|
+
/**
|
|
508
|
+
* @summary Submit an accepted checkout
|
|
509
|
+
*/
|
|
510
|
+
const useBillingSubmitCheckout = (options, queryClient) => {
|
|
511
|
+
return useMutation(getBillingSubmitCheckoutMutationOptions(options), queryClient);
|
|
512
|
+
};
|
|
513
|
+
const getBillingCreateClientTokenUrl = () => {
|
|
514
|
+
return `/billing/client-token`;
|
|
515
|
+
};
|
|
516
|
+
/**
|
|
517
|
+
* Obtain a Braintree client token for an owned, unexpired quoted checkout in the current environment. Pass it to the provider SDK to collect a single-use paymentMethodNonce, then submit the checkout. The token is sensitive and must not be logged or persisted in client analytics. Uses the authenticated independent profile in the Biblio product context; support impersonation is refused. Responses are private and must not be cached. Requires high-assurance authentication.
|
|
518
|
+
* @summary Create a checkout payment client token
|
|
519
|
+
*/
|
|
520
|
+
const billingCreateClientToken = async (billingClientTokenWrite, options) => {
|
|
521
|
+
const getHeaders = (h) => {
|
|
522
|
+
if (!h) return {};
|
|
523
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
524
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
525
|
+
const headers = {};
|
|
526
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
527
|
+
return headers;
|
|
528
|
+
};
|
|
529
|
+
return request(getBillingCreateClientTokenUrl(), {
|
|
530
|
+
...options,
|
|
531
|
+
method: "POST",
|
|
532
|
+
headers: {
|
|
533
|
+
"Content-Type": "application/json",
|
|
534
|
+
...getHeaders(options?.headers)
|
|
535
|
+
},
|
|
536
|
+
body: JSON.stringify(billingClientTokenWrite)
|
|
537
|
+
});
|
|
538
|
+
};
|
|
539
|
+
const getBillingCreateClientTokenMutationKey = () => ["billingCreateClientToken"];
|
|
540
|
+
const getBillingCreateClientTokenMutationOptions = (options) => {
|
|
541
|
+
const mutationKey = getBillingCreateClientTokenMutationKey();
|
|
542
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
543
|
+
...options,
|
|
544
|
+
mutation: {
|
|
545
|
+
...options.mutation,
|
|
546
|
+
mutationKey
|
|
547
|
+
}
|
|
548
|
+
} : {
|
|
549
|
+
mutation: { mutationKey },
|
|
550
|
+
request: void 0
|
|
551
|
+
};
|
|
552
|
+
const mutationFn = (props) => {
|
|
553
|
+
const { data } = props ?? {};
|
|
554
|
+
return billingCreateClientToken(data, requestOptions);
|
|
555
|
+
};
|
|
556
|
+
return {
|
|
557
|
+
mutationFn,
|
|
558
|
+
...mutationOptions
|
|
559
|
+
};
|
|
560
|
+
};
|
|
561
|
+
/**
|
|
562
|
+
* @summary Create a checkout payment client token
|
|
563
|
+
*/
|
|
564
|
+
const useBillingCreateClientToken = (options, queryClient) => {
|
|
565
|
+
return useMutation(getBillingCreateClientTokenMutationOptions(options), queryClient);
|
|
566
|
+
};
|
|
567
|
+
const getBillingPrepareIdentityUrl = () => {
|
|
568
|
+
return `/billing/identity`;
|
|
569
|
+
};
|
|
570
|
+
/**
|
|
571
|
+
* Return or create the stable server-issued billing subject for the selected provider in the configured environment. Supply this subject to the mobile billing SDK; never substitute a profile ID or email. This explicit request does not grant course access or charge a payment method. Uses the authenticated independent profile in the Biblio product context; support impersonation is refused. Responses are private and must not be cached. Requires high-assurance authentication.
|
|
572
|
+
* @summary Prepare the current profile's billing identity
|
|
573
|
+
*/
|
|
574
|
+
const billingPrepareIdentity = async (billingIdentityWrite, options) => {
|
|
575
|
+
const getHeaders = (h) => {
|
|
576
|
+
if (!h) return {};
|
|
577
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
578
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
579
|
+
const headers = {};
|
|
580
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
581
|
+
return headers;
|
|
582
|
+
};
|
|
583
|
+
return request(getBillingPrepareIdentityUrl(), {
|
|
584
|
+
...options,
|
|
585
|
+
method: "POST",
|
|
586
|
+
headers: {
|
|
587
|
+
"Content-Type": "application/json",
|
|
588
|
+
...getHeaders(options?.headers)
|
|
589
|
+
},
|
|
590
|
+
body: JSON.stringify(billingIdentityWrite)
|
|
591
|
+
});
|
|
592
|
+
};
|
|
593
|
+
const getBillingPrepareIdentityMutationKey = () => ["billingPrepareIdentity"];
|
|
594
|
+
const getBillingPrepareIdentityMutationOptions = (options) => {
|
|
595
|
+
const mutationKey = getBillingPrepareIdentityMutationKey();
|
|
596
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
597
|
+
...options,
|
|
598
|
+
mutation: {
|
|
599
|
+
...options.mutation,
|
|
600
|
+
mutationKey
|
|
601
|
+
}
|
|
602
|
+
} : {
|
|
603
|
+
mutation: { mutationKey },
|
|
604
|
+
request: void 0
|
|
605
|
+
};
|
|
606
|
+
const mutationFn = (props) => {
|
|
607
|
+
const { data } = props ?? {};
|
|
608
|
+
return billingPrepareIdentity(data, requestOptions);
|
|
609
|
+
};
|
|
610
|
+
return {
|
|
611
|
+
mutationFn,
|
|
612
|
+
...mutationOptions
|
|
613
|
+
};
|
|
614
|
+
};
|
|
615
|
+
/**
|
|
616
|
+
* @summary Prepare the current profile's billing identity
|
|
617
|
+
*/
|
|
618
|
+
const useBillingPrepareIdentity = (options, queryClient) => {
|
|
619
|
+
return useMutation(getBillingPrepareIdentityMutationOptions(options), queryClient);
|
|
620
|
+
};
|
|
621
|
+
const getBillingListProductsUrl = (params) => {
|
|
622
|
+
const normalizedParams = new URLSearchParams();
|
|
623
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
624
|
+
if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
|
|
625
|
+
});
|
|
626
|
+
const stringifiedParams = normalizedParams.toString();
|
|
627
|
+
return stringifiedParams.length > 0 ? `/billing/products?${stringifiedParams}` : `/billing/products`;
|
|
628
|
+
};
|
|
629
|
+
/**
|
|
630
|
+
* List active offers visible to the profile, with server-calculated tax-inclusive prices. Retention offers appear only within seven days of their exact institution agreement's end. checkoutAvailable reflects configured web payment capability; providerProducts identifies active mappings in the current billing environment. Listing never starts a purchase. Uses the authenticated independent profile in the Biblio product context; support impersonation is refused. Responses are private and must not be cached.
|
|
631
|
+
* @summary List personal purchase offers
|
|
632
|
+
*/
|
|
633
|
+
const billingListProducts = async (params, options) => {
|
|
634
|
+
return request(getBillingListProductsUrl(params), {
|
|
635
|
+
...options,
|
|
636
|
+
method: "GET"
|
|
637
|
+
});
|
|
638
|
+
};
|
|
639
|
+
const getBillingListProductsQueryKey = (params) => {
|
|
640
|
+
return [`/billing/products`, ...params ? [params] : []];
|
|
641
|
+
};
|
|
642
|
+
const getBillingListProductsQueryOptions = (params, options) => {
|
|
643
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
644
|
+
const queryKey = queryOptions?.queryKey ?? getBillingListProductsQueryKey(params);
|
|
645
|
+
const queryFn = ({ signal }) => billingListProducts(params, {
|
|
646
|
+
signal,
|
|
647
|
+
...requestOptions
|
|
648
|
+
});
|
|
649
|
+
return {
|
|
650
|
+
queryKey,
|
|
651
|
+
queryFn,
|
|
652
|
+
...queryOptions
|
|
653
|
+
};
|
|
654
|
+
};
|
|
655
|
+
/**
|
|
656
|
+
* @summary List personal purchase offers
|
|
657
|
+
*/
|
|
658
|
+
function useBillingListProducts(params, options, queryClient) {
|
|
659
|
+
const queryOptions = getBillingListProductsQueryOptions(params, options);
|
|
660
|
+
const query = useQuery(queryOptions, queryClient);
|
|
661
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
662
|
+
}
|
|
663
|
+
const getBillingSetOfferAvailabilityUrl = (productId) => {
|
|
664
|
+
return `/billing/products/${productId}/availability`;
|
|
665
|
+
};
|
|
666
|
+
/**
|
|
667
|
+
* Set offer availability after commercial review and record the reason in the audit trail. Requires catalogue finance and global commercial authority. Returns 204 with no response body. Requires high-assurance authentication.
|
|
668
|
+
* @summary Activate or withdraw an offer
|
|
669
|
+
*/
|
|
670
|
+
const billingSetOfferAvailability = async (productId, billingProductAvailabilityWrite, options) => {
|
|
671
|
+
const getHeaders = (h) => {
|
|
672
|
+
if (!h) return {};
|
|
673
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
674
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
675
|
+
const headers = {};
|
|
676
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
677
|
+
return headers;
|
|
678
|
+
};
|
|
679
|
+
return request(getBillingSetOfferAvailabilityUrl(productId), {
|
|
680
|
+
...options,
|
|
681
|
+
method: "PUT",
|
|
682
|
+
headers: {
|
|
683
|
+
"Content-Type": "application/json",
|
|
684
|
+
...getHeaders(options?.headers)
|
|
685
|
+
},
|
|
686
|
+
body: JSON.stringify(billingProductAvailabilityWrite)
|
|
687
|
+
});
|
|
688
|
+
};
|
|
689
|
+
const getBillingSetOfferAvailabilityMutationKey = () => ["billingSetOfferAvailability"];
|
|
690
|
+
const getBillingSetOfferAvailabilityMutationOptions = (options) => {
|
|
691
|
+
const mutationKey = getBillingSetOfferAvailabilityMutationKey();
|
|
692
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
693
|
+
...options,
|
|
694
|
+
mutation: {
|
|
695
|
+
...options.mutation,
|
|
696
|
+
mutationKey
|
|
697
|
+
}
|
|
698
|
+
} : {
|
|
699
|
+
mutation: { mutationKey },
|
|
700
|
+
request: void 0
|
|
701
|
+
};
|
|
702
|
+
const mutationFn = (props) => {
|
|
703
|
+
const { productId, data } = props ?? {};
|
|
704
|
+
return billingSetOfferAvailability(productId, data, requestOptions);
|
|
705
|
+
};
|
|
706
|
+
return {
|
|
707
|
+
mutationFn,
|
|
708
|
+
...mutationOptions
|
|
709
|
+
};
|
|
710
|
+
};
|
|
711
|
+
/**
|
|
712
|
+
* @summary Activate or withdraw an offer
|
|
713
|
+
*/
|
|
714
|
+
const useBillingSetOfferAvailability = (options, queryClient) => {
|
|
715
|
+
return useMutation(getBillingSetOfferAvailabilityMutationOptions(options), queryClient);
|
|
716
|
+
};
|
|
717
|
+
const getBillingBindProviderProductUrl = (productId) => {
|
|
718
|
+
return `/billing/products/${productId}/provider`;
|
|
719
|
+
};
|
|
720
|
+
/**
|
|
721
|
+
* Catalogue finance operators associate an offer with an exact provider product and sandbox or production environment. A provider/environment/product identifier cannot be shared by different offers. Store products must be public recurring offers. Returns 204 with no response body. Requires high-assurance authentication.
|
|
722
|
+
* @summary Bind an offer to a provider product
|
|
723
|
+
*/
|
|
724
|
+
const billingBindProviderProduct = async (productId, billingProviderProductWrite, options) => {
|
|
725
|
+
const getHeaders = (h) => {
|
|
726
|
+
if (!h) return {};
|
|
727
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
728
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
729
|
+
const headers = {};
|
|
730
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
731
|
+
return headers;
|
|
732
|
+
};
|
|
733
|
+
return request(getBillingBindProviderProductUrl(productId), {
|
|
734
|
+
...options,
|
|
735
|
+
method: "PUT",
|
|
736
|
+
headers: {
|
|
737
|
+
"Content-Type": "application/json",
|
|
738
|
+
...getHeaders(options?.headers)
|
|
739
|
+
},
|
|
740
|
+
body: JSON.stringify(billingProviderProductWrite)
|
|
741
|
+
});
|
|
742
|
+
};
|
|
743
|
+
const getBillingBindProviderProductMutationKey = () => ["billingBindProviderProduct"];
|
|
744
|
+
const getBillingBindProviderProductMutationOptions = (options) => {
|
|
745
|
+
const mutationKey = getBillingBindProviderProductMutationKey();
|
|
746
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
747
|
+
...options,
|
|
748
|
+
mutation: {
|
|
749
|
+
...options.mutation,
|
|
750
|
+
mutationKey
|
|
751
|
+
}
|
|
752
|
+
} : {
|
|
753
|
+
mutation: { mutationKey },
|
|
754
|
+
request: void 0
|
|
755
|
+
};
|
|
756
|
+
const mutationFn = (props) => {
|
|
757
|
+
const { productId, data } = props ?? {};
|
|
758
|
+
return billingBindProviderProduct(productId, data, requestOptions);
|
|
759
|
+
};
|
|
760
|
+
return {
|
|
761
|
+
mutationFn,
|
|
762
|
+
...mutationOptions
|
|
763
|
+
};
|
|
764
|
+
};
|
|
765
|
+
/**
|
|
766
|
+
* @summary Bind an offer to a provider product
|
|
767
|
+
*/
|
|
768
|
+
const useBillingBindProviderProduct = (options, queryClient) => {
|
|
769
|
+
return useMutation(getBillingBindProviderProductMutationOptions(options), queryClient);
|
|
770
|
+
};
|
|
771
|
+
const getBillingPromotionGeneratorUrl = (generatorId) => {
|
|
772
|
+
return `/billing/promotion-generators/${generatorId}`;
|
|
773
|
+
};
|
|
774
|
+
/**
|
|
775
|
+
* Return a safe definition to a global commercial operator. batchSize counts generated codes while rule.quantity describes permitted uses of each code. Historical missing rule values stay null.
|
|
776
|
+
* @summary Read a promotion generator definition
|
|
777
|
+
*/
|
|
778
|
+
const billingPromotionGenerator = async (generatorId, options) => {
|
|
779
|
+
return request(getBillingPromotionGeneratorUrl(generatorId), {
|
|
780
|
+
...options,
|
|
781
|
+
method: "GET"
|
|
782
|
+
});
|
|
783
|
+
};
|
|
784
|
+
const getBillingPromotionGeneratorQueryKey = (generatorId) => {
|
|
785
|
+
return [`/billing/promotion-generators/${generatorId}`];
|
|
786
|
+
};
|
|
787
|
+
const getBillingPromotionGeneratorQueryOptions = (generatorId, options) => {
|
|
788
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
789
|
+
const queryKey = queryOptions?.queryKey ?? getBillingPromotionGeneratorQueryKey(generatorId);
|
|
790
|
+
const queryFn = ({ signal }) => billingPromotionGenerator(generatorId, {
|
|
791
|
+
signal,
|
|
792
|
+
...requestOptions
|
|
793
|
+
});
|
|
794
|
+
return {
|
|
795
|
+
queryKey,
|
|
796
|
+
queryFn,
|
|
797
|
+
enabled: generatorId !== null && generatorId !== void 0,
|
|
798
|
+
...queryOptions
|
|
799
|
+
};
|
|
800
|
+
};
|
|
801
|
+
/**
|
|
802
|
+
* @summary Read a promotion generator definition
|
|
803
|
+
*/
|
|
804
|
+
function useBillingPromotionGenerator(generatorId, options, queryClient) {
|
|
805
|
+
const queryOptions = getBillingPromotionGeneratorQueryOptions(generatorId, options);
|
|
806
|
+
const query = useQuery(queryOptions, queryClient);
|
|
807
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
808
|
+
}
|
|
809
|
+
const getBillingRedeemPromotionUrl = () => {
|
|
810
|
+
return `/billing/promotions/redeem`;
|
|
811
|
+
};
|
|
812
|
+
/**
|
|
813
|
+
* Redeem a usable benefit code that does not require a payment method, atomically consuming stock and creating personal access through shared contracts. Discounts use checkout instead. Reusing requestKey for the same promotion returns the previous redemption; reuse for another code returns 409. Case/Unicode-normalized lookup, per-user stock and access-window limits apply. Uses the authenticated independent profile in the Biblio product context; support impersonation is refused. Responses are private and must not be cached. Requires high-assurance authentication.
|
|
814
|
+
* @summary Redeem an access benefit for the current profile
|
|
815
|
+
*/
|
|
816
|
+
const billingRedeemPromotion = async (promotionRedeemWrite, options) => {
|
|
817
|
+
const getHeaders = (h) => {
|
|
818
|
+
if (!h) return {};
|
|
819
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
820
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
821
|
+
const headers = {};
|
|
822
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
823
|
+
return headers;
|
|
824
|
+
};
|
|
825
|
+
return request(getBillingRedeemPromotionUrl(), {
|
|
826
|
+
...options,
|
|
827
|
+
method: "POST",
|
|
828
|
+
headers: {
|
|
829
|
+
"Content-Type": "application/json",
|
|
830
|
+
...getHeaders(options?.headers)
|
|
831
|
+
},
|
|
832
|
+
body: JSON.stringify(promotionRedeemWrite)
|
|
833
|
+
});
|
|
834
|
+
};
|
|
835
|
+
const getBillingRedeemPromotionMutationKey = () => ["billingRedeemPromotion"];
|
|
836
|
+
const getBillingRedeemPromotionMutationOptions = (options) => {
|
|
837
|
+
const mutationKey = getBillingRedeemPromotionMutationKey();
|
|
838
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
839
|
+
...options,
|
|
840
|
+
mutation: {
|
|
841
|
+
...options.mutation,
|
|
842
|
+
mutationKey
|
|
843
|
+
}
|
|
844
|
+
} : {
|
|
845
|
+
mutation: { mutationKey },
|
|
846
|
+
request: void 0
|
|
847
|
+
};
|
|
848
|
+
const mutationFn = (props) => {
|
|
849
|
+
const { data } = props ?? {};
|
|
850
|
+
return billingRedeemPromotion(data, requestOptions);
|
|
851
|
+
};
|
|
852
|
+
return {
|
|
853
|
+
mutationFn,
|
|
854
|
+
...mutationOptions
|
|
855
|
+
};
|
|
856
|
+
};
|
|
857
|
+
/**
|
|
858
|
+
* @summary Redeem an access benefit for the current profile
|
|
859
|
+
*/
|
|
860
|
+
const useBillingRedeemPromotion = (options, queryClient) => {
|
|
861
|
+
return useMutation(getBillingRedeemPromotionMutationOptions(options), queryClient);
|
|
862
|
+
};
|
|
863
|
+
const getBillingPromotionCapacityUrl = (promotionId) => {
|
|
864
|
+
return `/billing/promotions/${promotionId}/capacity`;
|
|
865
|
+
};
|
|
866
|
+
/**
|
|
867
|
+
* Global commercial operators inspect total and per-user limits, redeemed stock and live reservations. Submitting or unknown checkouts keep reservations even after quote expiry. remaining is max(0, quantity - redeemed - reserved); a positive count alone does not prove a rule is active or usable.
|
|
868
|
+
* @summary Inspect promotion stock and payment reservations
|
|
869
|
+
*/
|
|
870
|
+
const billingPromotionCapacity = async (promotionId, options) => {
|
|
871
|
+
return request(getBillingPromotionCapacityUrl(promotionId), {
|
|
872
|
+
...options,
|
|
873
|
+
method: "GET"
|
|
874
|
+
});
|
|
875
|
+
};
|
|
876
|
+
const getBillingPromotionCapacityQueryKey = (promotionId) => {
|
|
877
|
+
return [`/billing/promotions/${promotionId}/capacity`];
|
|
878
|
+
};
|
|
879
|
+
const getBillingPromotionCapacityQueryOptions = (promotionId, options) => {
|
|
880
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
881
|
+
const queryKey = queryOptions?.queryKey ?? getBillingPromotionCapacityQueryKey(promotionId);
|
|
882
|
+
const queryFn = ({ signal }) => billingPromotionCapacity(promotionId, {
|
|
883
|
+
signal,
|
|
884
|
+
...requestOptions
|
|
885
|
+
});
|
|
886
|
+
return {
|
|
887
|
+
queryKey,
|
|
888
|
+
queryFn,
|
|
889
|
+
enabled: promotionId !== null && promotionId !== void 0,
|
|
890
|
+
...queryOptions
|
|
891
|
+
};
|
|
892
|
+
};
|
|
893
|
+
/**
|
|
894
|
+
* @summary Inspect promotion stock and payment reservations
|
|
895
|
+
*/
|
|
896
|
+
function useBillingPromotionCapacity(promotionId, options, queryClient) {
|
|
897
|
+
const queryOptions = getBillingPromotionCapacityQueryOptions(promotionId, options);
|
|
898
|
+
const query = useQuery(queryOptions, queryClient);
|
|
899
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
900
|
+
}
|
|
901
|
+
const getBillingRevealPromotionCodeUrl = (promotionId) => {
|
|
902
|
+
return `/billing/promotions/${promotionId}/code`;
|
|
903
|
+
};
|
|
904
|
+
/**
|
|
905
|
+
* A catalogue finance operator decrypts one distribution code and records the supplied reason. The response is private, no-store; do not expose it in public reports. Requires high-assurance authentication.
|
|
906
|
+
* @summary Reveal one promotion code with an audit reason
|
|
907
|
+
*/
|
|
908
|
+
const billingRevealPromotionCode = async (promotionId, promotionRevealWrite, options) => {
|
|
909
|
+
const getHeaders = (h) => {
|
|
910
|
+
if (!h) return {};
|
|
911
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
912
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
913
|
+
const headers = {};
|
|
914
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
915
|
+
return headers;
|
|
916
|
+
};
|
|
917
|
+
return request(getBillingRevealPromotionCodeUrl(promotionId), {
|
|
918
|
+
...options,
|
|
919
|
+
method: "POST",
|
|
920
|
+
headers: {
|
|
921
|
+
"Content-Type": "application/json",
|
|
922
|
+
...getHeaders(options?.headers)
|
|
923
|
+
},
|
|
924
|
+
body: JSON.stringify(promotionRevealWrite)
|
|
925
|
+
});
|
|
926
|
+
};
|
|
927
|
+
const getBillingRevealPromotionCodeMutationKey = () => ["billingRevealPromotionCode"];
|
|
928
|
+
const getBillingRevealPromotionCodeMutationOptions = (options) => {
|
|
929
|
+
const mutationKey = getBillingRevealPromotionCodeMutationKey();
|
|
930
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
931
|
+
...options,
|
|
932
|
+
mutation: {
|
|
933
|
+
...options.mutation,
|
|
934
|
+
mutationKey
|
|
935
|
+
}
|
|
936
|
+
} : {
|
|
937
|
+
mutation: { mutationKey },
|
|
938
|
+
request: void 0
|
|
939
|
+
};
|
|
940
|
+
const mutationFn = (props) => {
|
|
941
|
+
const { promotionId, data } = props ?? {};
|
|
942
|
+
return billingRevealPromotionCode(promotionId, data, requestOptions);
|
|
943
|
+
};
|
|
944
|
+
return {
|
|
945
|
+
mutationFn,
|
|
946
|
+
...mutationOptions
|
|
947
|
+
};
|
|
948
|
+
};
|
|
949
|
+
/**
|
|
950
|
+
* @summary Reveal one promotion code with an audit reason
|
|
951
|
+
*/
|
|
952
|
+
const useBillingRevealPromotionCode = (options, queryClient) => {
|
|
953
|
+
return useMutation(getBillingRevealPromotionCodeMutationOptions(options), queryClient);
|
|
954
|
+
};
|
|
955
|
+
const getBillingPromotionRedemptionsUrl = (promotionId, params) => {
|
|
956
|
+
const normalizedParams = new URLSearchParams();
|
|
957
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
958
|
+
if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
|
|
959
|
+
});
|
|
960
|
+
const stringifiedParams = normalizedParams.toString();
|
|
961
|
+
return stringifiedParams.length > 0 ? `/billing/promotions/${promotionId}/redemptions?${stringifiedParams}` : `/billing/promotions/${promotionId}/redemptions`;
|
|
962
|
+
};
|
|
963
|
+
/**
|
|
964
|
+
* Global commercial operators list a promotion's native and imported redemptions, newest first. Historical beneficiary, contract, transaction, discount and time references can be null; do not infer a payment from a redemption. Codes and raw source identifiers are omitted.
|
|
965
|
+
* @summary List promotion redemption evidence
|
|
966
|
+
*/
|
|
967
|
+
const billingPromotionRedemptions = async (promotionId, params, options) => {
|
|
968
|
+
return request(getBillingPromotionRedemptionsUrl(promotionId, params), {
|
|
969
|
+
...options,
|
|
970
|
+
method: "GET"
|
|
971
|
+
});
|
|
972
|
+
};
|
|
973
|
+
const getBillingPromotionRedemptionsQueryKey = (promotionId, params) => {
|
|
974
|
+
return [`/billing/promotions/${promotionId}/redemptions`, ...params ? [params] : []];
|
|
975
|
+
};
|
|
976
|
+
const getBillingPromotionRedemptionsQueryOptions = (promotionId, params, options) => {
|
|
977
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
978
|
+
const queryKey = queryOptions?.queryKey ?? getBillingPromotionRedemptionsQueryKey(promotionId, params);
|
|
979
|
+
const queryFn = ({ signal }) => billingPromotionRedemptions(promotionId, params, {
|
|
980
|
+
signal,
|
|
981
|
+
...requestOptions
|
|
982
|
+
});
|
|
983
|
+
return {
|
|
984
|
+
queryKey,
|
|
985
|
+
queryFn,
|
|
986
|
+
enabled: promotionId !== null && promotionId !== void 0,
|
|
987
|
+
...queryOptions
|
|
988
|
+
};
|
|
989
|
+
};
|
|
990
|
+
/**
|
|
991
|
+
* @summary List promotion redemption evidence
|
|
992
|
+
*/
|
|
993
|
+
function useBillingPromotionRedemptions(promotionId, params, options, queryClient) {
|
|
994
|
+
const queryOptions = getBillingPromotionRedemptionsQueryOptions(promotionId, params, options);
|
|
995
|
+
const query = useQuery(queryOptions, queryClient);
|
|
996
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
997
|
+
}
|
|
998
|
+
const getBillingRestoreStorePurchasesUrl = () => {
|
|
999
|
+
return `/billing/store/restore`;
|
|
1000
|
+
};
|
|
1001
|
+
/**
|
|
1002
|
+
* Fetch RevenueCat evidence for the server-issued billing subject and reconcile supported store receipts in the current environment with active provider mappings. Receipts belonging to another profile are refused. Unknown receipt price, tax or renewal values stay unknown. The returned page contains restored subscriptions and can be empty; there is no client-supplied receipt-owner ID. Uses the authenticated independent profile in the Biblio product context; support impersonation is refused. Responses are private and must not be cached. Requires high-assurance authentication.
|
|
1003
|
+
* @summary Restore the current profile's mobile purchases
|
|
1004
|
+
*/
|
|
1005
|
+
const billingRestoreStorePurchases = async (billingIdentityWrite, options) => {
|
|
1006
|
+
const getHeaders = (h) => {
|
|
1007
|
+
if (!h) return {};
|
|
1008
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
1009
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
1010
|
+
const headers = {};
|
|
1011
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
1012
|
+
return headers;
|
|
1013
|
+
};
|
|
1014
|
+
return request(getBillingRestoreStorePurchasesUrl(), {
|
|
1015
|
+
...options,
|
|
1016
|
+
method: "POST",
|
|
1017
|
+
headers: {
|
|
1018
|
+
"Content-Type": "application/json",
|
|
1019
|
+
...getHeaders(options?.headers)
|
|
1020
|
+
},
|
|
1021
|
+
body: JSON.stringify(billingIdentityWrite)
|
|
1022
|
+
});
|
|
1023
|
+
};
|
|
1024
|
+
const getBillingRestoreStorePurchasesMutationKey = () => ["billingRestoreStorePurchases"];
|
|
1025
|
+
const getBillingRestoreStorePurchasesMutationOptions = (options) => {
|
|
1026
|
+
const mutationKey = getBillingRestoreStorePurchasesMutationKey();
|
|
1027
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
1028
|
+
...options,
|
|
1029
|
+
mutation: {
|
|
1030
|
+
...options.mutation,
|
|
1031
|
+
mutationKey
|
|
1032
|
+
}
|
|
1033
|
+
} : {
|
|
1034
|
+
mutation: { mutationKey },
|
|
1035
|
+
request: void 0
|
|
1036
|
+
};
|
|
1037
|
+
const mutationFn = (props) => {
|
|
1038
|
+
const { data } = props ?? {};
|
|
1039
|
+
return billingRestoreStorePurchases(data, requestOptions);
|
|
1040
|
+
};
|
|
1041
|
+
return {
|
|
1042
|
+
mutationFn,
|
|
1043
|
+
...mutationOptions
|
|
1044
|
+
};
|
|
1045
|
+
};
|
|
1046
|
+
/**
|
|
1047
|
+
* @summary Restore the current profile's mobile purchases
|
|
1048
|
+
*/
|
|
1049
|
+
const useBillingRestoreStorePurchases = (options, queryClient) => {
|
|
1050
|
+
return useMutation(getBillingRestoreStorePurchasesMutationOptions(options), queryClient);
|
|
1051
|
+
};
|
|
1052
|
+
const getBillingListSubscriptionsUrl = (params) => {
|
|
1053
|
+
const normalizedParams = new URLSearchParams();
|
|
1054
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1055
|
+
if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
|
|
1056
|
+
});
|
|
1057
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1058
|
+
return stringifiedParams.length > 0 ? `/billing/subscriptions?${stringifiedParams}` : `/billing/subscriptions`;
|
|
1059
|
+
};
|
|
1060
|
+
/**
|
|
1061
|
+
* List local subscription projections, newest first. No provider refresh occurs. autoRenew=null means renewal is unknown, and unknown historical price/currency remain null; use explicit reconciliation or store restoration to obtain current evidence. Uses the authenticated independent profile in the Biblio product context; support impersonation is refused. Responses are private and must not be cached.
|
|
1062
|
+
* @summary List the current profile's subscriptions
|
|
1063
|
+
*/
|
|
1064
|
+
const billingListSubscriptions = async (params, options) => {
|
|
1065
|
+
return request(getBillingListSubscriptionsUrl(params), {
|
|
1066
|
+
...options,
|
|
1067
|
+
method: "GET"
|
|
1068
|
+
});
|
|
1069
|
+
};
|
|
1070
|
+
const getBillingListSubscriptionsQueryKey = (params) => {
|
|
1071
|
+
return [`/billing/subscriptions`, ...params ? [params] : []];
|
|
1072
|
+
};
|
|
1073
|
+
const getBillingListSubscriptionsQueryOptions = (params, options) => {
|
|
1074
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
1075
|
+
const queryKey = queryOptions?.queryKey ?? getBillingListSubscriptionsQueryKey(params);
|
|
1076
|
+
const queryFn = ({ signal }) => billingListSubscriptions(params, {
|
|
1077
|
+
signal,
|
|
1078
|
+
...requestOptions
|
|
1079
|
+
});
|
|
1080
|
+
return {
|
|
1081
|
+
queryKey,
|
|
1082
|
+
queryFn,
|
|
1083
|
+
...queryOptions
|
|
1084
|
+
};
|
|
1085
|
+
};
|
|
1086
|
+
/**
|
|
1087
|
+
* @summary List the current profile's subscriptions
|
|
1088
|
+
*/
|
|
1089
|
+
function useBillingListSubscriptions(params, options, queryClient) {
|
|
1090
|
+
const queryOptions = getBillingListSubscriptionsQueryOptions(params, options);
|
|
1091
|
+
const query = useQuery(queryOptions, queryClient);
|
|
1092
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
1093
|
+
}
|
|
1094
|
+
const getBillingReadSubscriptionUrl = (subscriptionId) => {
|
|
1095
|
+
return `/billing/subscriptions/${subscriptionId}`;
|
|
1096
|
+
};
|
|
1097
|
+
/**
|
|
1098
|
+
* Read the local subscription and its known access, price and renewal terms. managementUrl is provided for mobile store subscriptions. This GET neither refreshes receipts nor changes renewal. Uses the authenticated independent profile in the Biblio product context; support impersonation is refused. Responses are private and must not be cached.
|
|
1099
|
+
* @summary Read the current profile's subscription
|
|
1100
|
+
*/
|
|
1101
|
+
const billingReadSubscription = async (subscriptionId, options) => {
|
|
1102
|
+
return request(getBillingReadSubscriptionUrl(subscriptionId), {
|
|
1103
|
+
...options,
|
|
1104
|
+
method: "GET"
|
|
1105
|
+
});
|
|
1106
|
+
};
|
|
1107
|
+
const getBillingReadSubscriptionQueryKey = (subscriptionId) => {
|
|
1108
|
+
return [`/billing/subscriptions/${subscriptionId}`];
|
|
1109
|
+
};
|
|
1110
|
+
const getBillingReadSubscriptionQueryOptions = (subscriptionId, options) => {
|
|
1111
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
1112
|
+
const queryKey = queryOptions?.queryKey ?? getBillingReadSubscriptionQueryKey(subscriptionId);
|
|
1113
|
+
const queryFn = ({ signal }) => billingReadSubscription(subscriptionId, {
|
|
1114
|
+
signal,
|
|
1115
|
+
...requestOptions
|
|
1116
|
+
});
|
|
1117
|
+
return {
|
|
1118
|
+
queryKey,
|
|
1119
|
+
queryFn,
|
|
1120
|
+
enabled: subscriptionId !== null && subscriptionId !== void 0,
|
|
1121
|
+
...queryOptions
|
|
1122
|
+
};
|
|
1123
|
+
};
|
|
1124
|
+
/**
|
|
1125
|
+
* @summary Read the current profile's subscription
|
|
1126
|
+
*/
|
|
1127
|
+
function useBillingReadSubscription(subscriptionId, options, queryClient) {
|
|
1128
|
+
const queryOptions = getBillingReadSubscriptionQueryOptions(subscriptionId, options);
|
|
1129
|
+
const query = useQuery(queryOptions, queryClient);
|
|
1130
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
1131
|
+
}
|
|
1132
|
+
const getBillingCancelSubscriptionUrl = (subscriptionId) => {
|
|
1133
|
+
return `/billing/subscriptions/${subscriptionId}/cancel`;
|
|
1134
|
+
};
|
|
1135
|
+
/**
|
|
1136
|
+
* Cancel Braintree renewal and project the provider-confirmed access end, or cancel a local fixed subscription. Existing paid access follows the confirmed period. Optional feedback is stored separately. Mobile store renewal must be managed through managementUrl; this operation returns 409 for stores. Uses the authenticated independent profile in the Biblio product context; support impersonation is refused. Responses are private and must not be cached. Requires high-assurance authentication.
|
|
1137
|
+
* @summary Cancel a personal subscription's renewal
|
|
1138
|
+
*/
|
|
1139
|
+
const billingCancelSubscription = async (subscriptionId, billingCancelWrite, options) => {
|
|
1140
|
+
const getHeaders = (h) => {
|
|
1141
|
+
if (!h) return {};
|
|
1142
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
1143
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
1144
|
+
const headers = {};
|
|
1145
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
1146
|
+
return headers;
|
|
1147
|
+
};
|
|
1148
|
+
return request(getBillingCancelSubscriptionUrl(subscriptionId), {
|
|
1149
|
+
...options,
|
|
1150
|
+
method: "POST",
|
|
1151
|
+
headers: {
|
|
1152
|
+
"Content-Type": "application/json",
|
|
1153
|
+
...getHeaders(options?.headers)
|
|
1154
|
+
},
|
|
1155
|
+
body: JSON.stringify(billingCancelWrite)
|
|
1156
|
+
});
|
|
1157
|
+
};
|
|
1158
|
+
const getBillingCancelSubscriptionMutationKey = () => ["billingCancelSubscription"];
|
|
1159
|
+
const getBillingCancelSubscriptionMutationOptions = (options) => {
|
|
1160
|
+
const mutationKey = getBillingCancelSubscriptionMutationKey();
|
|
1161
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
1162
|
+
...options,
|
|
1163
|
+
mutation: {
|
|
1164
|
+
...options.mutation,
|
|
1165
|
+
mutationKey
|
|
1166
|
+
}
|
|
1167
|
+
} : {
|
|
1168
|
+
mutation: { mutationKey },
|
|
1169
|
+
request: void 0
|
|
1170
|
+
};
|
|
1171
|
+
const mutationFn = (props) => {
|
|
1172
|
+
const { subscriptionId, data } = props ?? {};
|
|
1173
|
+
return billingCancelSubscription(subscriptionId, data, requestOptions);
|
|
1174
|
+
};
|
|
1175
|
+
return {
|
|
1176
|
+
mutationFn,
|
|
1177
|
+
...mutationOptions
|
|
1178
|
+
};
|
|
1179
|
+
};
|
|
1180
|
+
/**
|
|
1181
|
+
* @summary Cancel a personal subscription's renewal
|
|
1182
|
+
*/
|
|
1183
|
+
const useBillingCancelSubscription = (options, queryClient) => {
|
|
1184
|
+
return useMutation(getBillingCancelSubscriptionMutationOptions(options), queryClient);
|
|
1185
|
+
};
|
|
1186
|
+
const getBillingCancellationFeedbackUrl = (subscriptionId, params) => {
|
|
1187
|
+
const normalizedParams = new URLSearchParams();
|
|
1188
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1189
|
+
if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
|
|
1190
|
+
});
|
|
1191
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1192
|
+
return stringifiedParams.length > 0 ? `/billing/subscriptions/${subscriptionId}/cancellation-feedback?${stringifiedParams}` : `/billing/subscriptions/${subscriptionId}/cancellation-feedback`;
|
|
1193
|
+
};
|
|
1194
|
+
/**
|
|
1195
|
+
* List only this profile's recorded cancellation feedback for the owned subscription, newest first. Missing historical answers and dates stay null. Feedback is not evidence of current provider renewal state. Uses the authenticated independent profile in the Biblio product context; support impersonation is refused. Responses are private and must not be cached.
|
|
1196
|
+
* @summary List an owned subscription's cancellation feedback
|
|
1197
|
+
*/
|
|
1198
|
+
const billingCancellationFeedback = async (subscriptionId, params, options) => {
|
|
1199
|
+
return request(getBillingCancellationFeedbackUrl(subscriptionId, params), {
|
|
1200
|
+
...options,
|
|
1201
|
+
method: "GET"
|
|
1202
|
+
});
|
|
1203
|
+
};
|
|
1204
|
+
const getBillingCancellationFeedbackQueryKey = (subscriptionId, params) => {
|
|
1205
|
+
return [`/billing/subscriptions/${subscriptionId}/cancellation-feedback`, ...params ? [params] : []];
|
|
1206
|
+
};
|
|
1207
|
+
const getBillingCancellationFeedbackQueryOptions = (subscriptionId, params, options) => {
|
|
1208
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
1209
|
+
const queryKey = queryOptions?.queryKey ?? getBillingCancellationFeedbackQueryKey(subscriptionId, params);
|
|
1210
|
+
const queryFn = ({ signal }) => billingCancellationFeedback(subscriptionId, params, {
|
|
1211
|
+
signal,
|
|
1212
|
+
...requestOptions
|
|
1213
|
+
});
|
|
1214
|
+
return {
|
|
1215
|
+
queryKey,
|
|
1216
|
+
queryFn,
|
|
1217
|
+
enabled: subscriptionId !== null && subscriptionId !== void 0,
|
|
1218
|
+
...queryOptions
|
|
1219
|
+
};
|
|
1220
|
+
};
|
|
1221
|
+
/**
|
|
1222
|
+
* @summary List an owned subscription's cancellation feedback
|
|
1223
|
+
*/
|
|
1224
|
+
function useBillingCancellationFeedback(subscriptionId, params, options, queryClient) {
|
|
1225
|
+
const queryOptions = getBillingCancellationFeedbackQueryOptions(subscriptionId, params, options);
|
|
1226
|
+
const query = useQuery(queryOptions, queryClient);
|
|
1227
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
1228
|
+
}
|
|
1229
|
+
const getBillingSubscriptionClientTokenUrl = (subscriptionId) => {
|
|
1230
|
+
return `/billing/subscriptions/${subscriptionId}/client-token`;
|
|
1231
|
+
};
|
|
1232
|
+
/**
|
|
1233
|
+
* Initialize payment-method collection for an owned Braintree subscription whose renewal is confirmed active. Unknown renewal must be reconciled first; store and nonrenewing subscriptions are not editable here. Uses the authenticated independent profile in the Biblio product context; support impersonation is refused. Responses are private and must not be cached. Requires high-assurance authentication.
|
|
1234
|
+
* @summary Create a subscription payment-method token
|
|
1235
|
+
*/
|
|
1236
|
+
const billingSubscriptionClientToken = async (subscriptionId, options) => {
|
|
1237
|
+
return request(getBillingSubscriptionClientTokenUrl(subscriptionId), {
|
|
1238
|
+
...options,
|
|
1239
|
+
method: "POST"
|
|
1240
|
+
});
|
|
1241
|
+
};
|
|
1242
|
+
const getBillingSubscriptionClientTokenMutationKey = () => ["billingSubscriptionClientToken"];
|
|
1243
|
+
const getBillingSubscriptionClientTokenMutationOptions = (options) => {
|
|
1244
|
+
const mutationKey = getBillingSubscriptionClientTokenMutationKey();
|
|
1245
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
1246
|
+
...options,
|
|
1247
|
+
mutation: {
|
|
1248
|
+
...options.mutation,
|
|
1249
|
+
mutationKey
|
|
1250
|
+
}
|
|
1251
|
+
} : {
|
|
1252
|
+
mutation: { mutationKey },
|
|
1253
|
+
request: void 0
|
|
1254
|
+
};
|
|
1255
|
+
const mutationFn = (props) => {
|
|
1256
|
+
const { subscriptionId } = props ?? {};
|
|
1257
|
+
return billingSubscriptionClientToken(subscriptionId, requestOptions);
|
|
1258
|
+
};
|
|
1259
|
+
return {
|
|
1260
|
+
mutationFn,
|
|
1261
|
+
...mutationOptions
|
|
1262
|
+
};
|
|
1263
|
+
};
|
|
1264
|
+
/**
|
|
1265
|
+
* @summary Create a subscription payment-method token
|
|
1266
|
+
*/
|
|
1267
|
+
const useBillingSubscriptionClientToken = (options, queryClient) => {
|
|
1268
|
+
return useMutation(getBillingSubscriptionClientTokenMutationOptions(options), queryClient);
|
|
1269
|
+
};
|
|
1270
|
+
const getBillingSubscriptionHistoryUrl = (subscriptionId, params) => {
|
|
1271
|
+
const normalizedParams = new URLSearchParams();
|
|
1272
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1273
|
+
if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
|
|
1274
|
+
});
|
|
1275
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1276
|
+
return stringifiedParams.length > 0 ? `/billing/subscriptions/${subscriptionId}/history?${stringifiedParams}` : `/billing/subscriptions/${subscriptionId}/history`;
|
|
1277
|
+
};
|
|
1278
|
+
/**
|
|
1279
|
+
* List preserved subscription events, newest local identifier first. Source status and transactionType are evidence labels, not current renewal guarantees. Unknown source times remain null with clockBasis; amount may also be null and this projection does not supply a currency. Uses the authenticated independent profile in the Biblio product context; support impersonation is refused. Responses are private and must not be cached.
|
|
1280
|
+
* @summary List an owned subscription's source events
|
|
1281
|
+
*/
|
|
1282
|
+
const billingSubscriptionHistory = async (subscriptionId, params, options) => {
|
|
1283
|
+
return request(getBillingSubscriptionHistoryUrl(subscriptionId, params), {
|
|
1284
|
+
...options,
|
|
1285
|
+
method: "GET"
|
|
1286
|
+
});
|
|
1287
|
+
};
|
|
1288
|
+
const getBillingSubscriptionHistoryQueryKey = (subscriptionId, params) => {
|
|
1289
|
+
return [`/billing/subscriptions/${subscriptionId}/history`, ...params ? [params] : []];
|
|
1290
|
+
};
|
|
1291
|
+
const getBillingSubscriptionHistoryQueryOptions = (subscriptionId, params, options) => {
|
|
1292
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
1293
|
+
const queryKey = queryOptions?.queryKey ?? getBillingSubscriptionHistoryQueryKey(subscriptionId, params);
|
|
1294
|
+
const queryFn = ({ signal }) => billingSubscriptionHistory(subscriptionId, params, {
|
|
1295
|
+
signal,
|
|
1296
|
+
...requestOptions
|
|
1297
|
+
});
|
|
1298
|
+
return {
|
|
1299
|
+
queryKey,
|
|
1300
|
+
queryFn,
|
|
1301
|
+
enabled: subscriptionId !== null && subscriptionId !== void 0,
|
|
1302
|
+
...queryOptions
|
|
1303
|
+
};
|
|
1304
|
+
};
|
|
1305
|
+
/**
|
|
1306
|
+
* @summary List an owned subscription's source events
|
|
1307
|
+
*/
|
|
1308
|
+
function useBillingSubscriptionHistory(subscriptionId, params, options, queryClient) {
|
|
1309
|
+
const queryOptions = getBillingSubscriptionHistoryQueryOptions(subscriptionId, params, options);
|
|
1310
|
+
const query = useQuery(queryOptions, queryClient);
|
|
1311
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
1312
|
+
}
|
|
1313
|
+
const getBillingUpdatePaymentMethodUrl = (subscriptionId) => {
|
|
1314
|
+
return `/billing/subscriptions/${subscriptionId}/payment-method`;
|
|
1315
|
+
};
|
|
1316
|
+
/**
|
|
1317
|
+
* Use a new provider SDK nonce to update the current profile's renewing Braintree subscription and apply the returned receipt. acceptedOutstandingBalance explicitly allows collection of an outstanding balance; it defaults to false. Store subscriptions use their original provider. Uses the authenticated independent profile in the Biblio product context; support impersonation is refused. Responses are private and must not be cached. Requires high-assurance authentication.
|
|
1318
|
+
* @summary Update a renewing subscription's payment method
|
|
1319
|
+
*/
|
|
1320
|
+
const billingUpdatePaymentMethod = async (subscriptionId, billingPaymentMethodWrite, options) => {
|
|
1321
|
+
const getHeaders = (h) => {
|
|
1322
|
+
if (!h) return {};
|
|
1323
|
+
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
1324
|
+
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
1325
|
+
const headers = {};
|
|
1326
|
+
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
1327
|
+
return headers;
|
|
1328
|
+
};
|
|
1329
|
+
return request(getBillingUpdatePaymentMethodUrl(subscriptionId), {
|
|
1330
|
+
...options,
|
|
1331
|
+
method: "PUT",
|
|
1332
|
+
headers: {
|
|
1333
|
+
"Content-Type": "application/json",
|
|
1334
|
+
...getHeaders(options?.headers)
|
|
1335
|
+
},
|
|
1336
|
+
body: JSON.stringify(billingPaymentMethodWrite)
|
|
1337
|
+
});
|
|
1338
|
+
};
|
|
1339
|
+
const getBillingUpdatePaymentMethodMutationKey = () => ["billingUpdatePaymentMethod"];
|
|
1340
|
+
const getBillingUpdatePaymentMethodMutationOptions = (options) => {
|
|
1341
|
+
const mutationKey = getBillingUpdatePaymentMethodMutationKey();
|
|
1342
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
1343
|
+
...options,
|
|
1344
|
+
mutation: {
|
|
1345
|
+
...options.mutation,
|
|
1346
|
+
mutationKey
|
|
1347
|
+
}
|
|
1348
|
+
} : {
|
|
1349
|
+
mutation: { mutationKey },
|
|
1350
|
+
request: void 0
|
|
1351
|
+
};
|
|
1352
|
+
const mutationFn = (props) => {
|
|
1353
|
+
const { subscriptionId, data } = props ?? {};
|
|
1354
|
+
return billingUpdatePaymentMethod(subscriptionId, data, requestOptions);
|
|
1355
|
+
};
|
|
1356
|
+
return {
|
|
1357
|
+
mutationFn,
|
|
1358
|
+
...mutationOptions
|
|
1359
|
+
};
|
|
1360
|
+
};
|
|
1361
|
+
/**
|
|
1362
|
+
* @summary Update a renewing subscription's payment method
|
|
1363
|
+
*/
|
|
1364
|
+
const useBillingUpdatePaymentMethod = (options, queryClient) => {
|
|
1365
|
+
return useMutation(getBillingUpdatePaymentMethodMutationOptions(options), queryClient);
|
|
1366
|
+
};
|
|
1367
|
+
const getBillingReconcileSubscriptionUrl = (subscriptionId) => {
|
|
1368
|
+
return `/billing/subscriptions/${subscriptionId}/reconcile`;
|
|
1369
|
+
};
|
|
1370
|
+
/**
|
|
1371
|
+
* Read the existing Braintree subscription, refresh authoritative renewal/access terms and project shared contract access. The existing provider identity and current billing environment must match. Use store restoration for App Store and Play Store subscriptions. Uses the authenticated independent profile in the Biblio product context; support impersonation is refused. Responses are private and must not be cached. Requires high-assurance authentication.
|
|
1372
|
+
* @summary Refresh a Braintree subscription from its receipt
|
|
1373
|
+
*/
|
|
1374
|
+
const billingReconcileSubscription = async (subscriptionId, options) => {
|
|
1375
|
+
return request(getBillingReconcileSubscriptionUrl(subscriptionId), {
|
|
1376
|
+
...options,
|
|
1377
|
+
method: "POST"
|
|
1378
|
+
});
|
|
1379
|
+
};
|
|
1380
|
+
const getBillingReconcileSubscriptionMutationKey = () => ["billingReconcileSubscription"];
|
|
1381
|
+
const getBillingReconcileSubscriptionMutationOptions = (options) => {
|
|
1382
|
+
const mutationKey = getBillingReconcileSubscriptionMutationKey();
|
|
1383
|
+
const { mutation: mutationOptions, request: requestOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : {
|
|
1384
|
+
...options,
|
|
1385
|
+
mutation: {
|
|
1386
|
+
...options.mutation,
|
|
1387
|
+
mutationKey
|
|
1388
|
+
}
|
|
1389
|
+
} : {
|
|
1390
|
+
mutation: { mutationKey },
|
|
1391
|
+
request: void 0
|
|
1392
|
+
};
|
|
1393
|
+
const mutationFn = (props) => {
|
|
1394
|
+
const { subscriptionId } = props ?? {};
|
|
1395
|
+
return billingReconcileSubscription(subscriptionId, requestOptions);
|
|
1396
|
+
};
|
|
1397
|
+
return {
|
|
1398
|
+
mutationFn,
|
|
1399
|
+
...mutationOptions
|
|
1400
|
+
};
|
|
1401
|
+
};
|
|
1402
|
+
/**
|
|
1403
|
+
* @summary Refresh a Braintree subscription from its receipt
|
|
1404
|
+
*/
|
|
1405
|
+
const useBillingReconcileSubscription = (options, queryClient) => {
|
|
1406
|
+
return useMutation(getBillingReconcileSubscriptionMutationOptions(options), queryClient);
|
|
1407
|
+
};
|
|
1408
|
+
const getBillingListTransactionsUrl = (params) => {
|
|
1409
|
+
const normalizedParams = new URLSearchParams();
|
|
1410
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
1411
|
+
if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
|
|
1412
|
+
});
|
|
1413
|
+
const stringifiedParams = normalizedParams.toString();
|
|
1414
|
+
return stringifiedParams.length > 0 ? `/billing/transactions?${stringifiedParams}` : `/billing/transactions`;
|
|
1415
|
+
};
|
|
1416
|
+
/**
|
|
1417
|
+
* List private native and imported transactions, newest local identifier first. Historical timestamps, money and currency remain null when unverified. amountBasis distinguishes verified_receipt, historical_provider_evidence and unknown. listedAmountBeforeDiscount and calculatedAmountAfterDiscount preserve source arithmetic; they must not be presented as confirmed paid amounts. clockBasis describes time evidence. Uses the authenticated independent profile in the Biblio product context; support impersonation is refused. Responses are private and must not be cached.
|
|
1418
|
+
* @summary List the current profile's payment history
|
|
1419
|
+
*/
|
|
1420
|
+
const billingListTransactions = async (params, options) => {
|
|
1421
|
+
return request(getBillingListTransactionsUrl(params), {
|
|
1422
|
+
...options,
|
|
1423
|
+
method: "GET"
|
|
1424
|
+
});
|
|
1425
|
+
};
|
|
1426
|
+
const getBillingListTransactionsQueryKey = (params) => {
|
|
1427
|
+
return [`/billing/transactions`, ...params ? [params] : []];
|
|
1428
|
+
};
|
|
1429
|
+
const getBillingListTransactionsQueryOptions = (params, options) => {
|
|
1430
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
1431
|
+
const queryKey = queryOptions?.queryKey ?? getBillingListTransactionsQueryKey(params);
|
|
1432
|
+
const queryFn = ({ signal }) => billingListTransactions(params, {
|
|
1433
|
+
signal,
|
|
1434
|
+
...requestOptions
|
|
1435
|
+
});
|
|
1436
|
+
return {
|
|
1437
|
+
queryKey,
|
|
1438
|
+
queryFn,
|
|
1439
|
+
...queryOptions
|
|
1440
|
+
};
|
|
1441
|
+
};
|
|
1442
|
+
/**
|
|
1443
|
+
* @summary List the current profile's payment history
|
|
1444
|
+
*/
|
|
1445
|
+
function useBillingListTransactions(params, options, queryClient) {
|
|
1446
|
+
const queryOptions = getBillingListTransactionsQueryOptions(params, options);
|
|
1447
|
+
const query = useQuery(queryOptions, queryClient);
|
|
1448
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
1449
|
+
}
|
|
1450
|
+
const getBillingReadTransactionUrl = (transactionId) => {
|
|
1451
|
+
return `/billing/transactions/${transactionId}`;
|
|
1452
|
+
};
|
|
1453
|
+
/**
|
|
1454
|
+
* Return one transaction belonging to the authenticated profile. Historical timestamps, money and currency remain null when unverified. amountBasis distinguishes verified_receipt, historical_provider_evidence and unknown. listedAmountBeforeDiscount and calculatedAmountAfterDiscount preserve source arithmetic; they must not be presented as confirmed paid amounts. clockBasis describes time evidence. Uses the authenticated independent profile in the Biblio product context; support impersonation is refused. Responses are private and must not be cached.
|
|
1455
|
+
* @summary Read an owned transaction's payment evidence
|
|
1456
|
+
*/
|
|
1457
|
+
const billingReadTransaction = async (transactionId, options) => {
|
|
1458
|
+
return request(getBillingReadTransactionUrl(transactionId), {
|
|
1459
|
+
...options,
|
|
1460
|
+
method: "GET"
|
|
1461
|
+
});
|
|
1462
|
+
};
|
|
1463
|
+
const getBillingReadTransactionQueryKey = (transactionId) => {
|
|
1464
|
+
return [`/billing/transactions/${transactionId}`];
|
|
1465
|
+
};
|
|
1466
|
+
const getBillingReadTransactionQueryOptions = (transactionId, options) => {
|
|
1467
|
+
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
1468
|
+
const queryKey = queryOptions?.queryKey ?? getBillingReadTransactionQueryKey(transactionId);
|
|
1469
|
+
const queryFn = ({ signal }) => billingReadTransaction(transactionId, {
|
|
1470
|
+
signal,
|
|
1471
|
+
...requestOptions
|
|
1472
|
+
});
|
|
1473
|
+
return {
|
|
1474
|
+
queryKey,
|
|
1475
|
+
queryFn,
|
|
1476
|
+
enabled: transactionId !== null && transactionId !== void 0,
|
|
1477
|
+
...queryOptions
|
|
1478
|
+
};
|
|
1479
|
+
};
|
|
1480
|
+
/**
|
|
1481
|
+
* @summary Read an owned transaction's payment evidence
|
|
1482
|
+
*/
|
|
1483
|
+
function useBillingReadTransaction(transactionId, options, queryClient) {
|
|
1484
|
+
const queryOptions = getBillingReadTransactionQueryOptions(transactionId, options);
|
|
1485
|
+
const query = useQuery(queryOptions, queryClient);
|
|
1486
|
+
return withQueryKey(query, queryOptions.queryKey);
|
|
1487
|
+
}
|
|
1488
|
+
//#endregion
|
|
1489
|
+
export { billingBindProviderProduct, billingCancelSubscription, billingCancellationFeedback, billingCreateClientToken, billingCreateProduct, billingCreatePromotion, billingExportPromotionCodes, billingGeneratePromotions, billingListProducts, billingListPromotions, billingListSubscriptions, billingListTransactions, billingPrepareIdentity, billingPromotionCapacity, billingPromotionGenerator, billingPromotionGenerators, billingPromotionRedemptions, billingQuoteCheckout, billingReadCheckout, billingReadSubscription, billingReadTransaction, billingReconcileCheckout, billingReconcileSubscription, billingRedeemPromotion, billingRestoreStorePurchases, billingRevealPromotionCode, billingSetOfferAvailability, billingSubmitCheckout, billingSubscriptionClientToken, billingSubscriptionHistory, billingUpdatePaymentMethod, getBillingBindProviderProductMutationKey, getBillingBindProviderProductMutationOptions, getBillingBindProviderProductUrl, getBillingCancelSubscriptionMutationKey, getBillingCancelSubscriptionMutationOptions, getBillingCancelSubscriptionUrl, getBillingCancellationFeedbackQueryKey, getBillingCancellationFeedbackQueryOptions, getBillingCancellationFeedbackUrl, getBillingCreateClientTokenMutationKey, getBillingCreateClientTokenMutationOptions, getBillingCreateClientTokenUrl, getBillingCreateProductMutationKey, getBillingCreateProductMutationOptions, getBillingCreateProductUrl, getBillingCreatePromotionMutationKey, getBillingCreatePromotionMutationOptions, getBillingCreatePromotionUrl, getBillingExportPromotionCodesMutationKey, getBillingExportPromotionCodesMutationOptions, getBillingExportPromotionCodesUrl, getBillingGeneratePromotionsMutationKey, getBillingGeneratePromotionsMutationOptions, getBillingGeneratePromotionsUrl, getBillingListProductsQueryKey, getBillingListProductsQueryOptions, getBillingListProductsUrl, getBillingListPromotionsQueryKey, getBillingListPromotionsQueryOptions, getBillingListPromotionsUrl, getBillingListSubscriptionsQueryKey, getBillingListSubscriptionsQueryOptions, getBillingListSubscriptionsUrl, getBillingListTransactionsQueryKey, getBillingListTransactionsQueryOptions, getBillingListTransactionsUrl, getBillingPrepareIdentityMutationKey, getBillingPrepareIdentityMutationOptions, getBillingPrepareIdentityUrl, getBillingPromotionCapacityQueryKey, getBillingPromotionCapacityQueryOptions, getBillingPromotionCapacityUrl, getBillingPromotionGeneratorQueryKey, getBillingPromotionGeneratorQueryOptions, getBillingPromotionGeneratorUrl, getBillingPromotionGeneratorsQueryKey, getBillingPromotionGeneratorsQueryOptions, getBillingPromotionGeneratorsUrl, getBillingPromotionRedemptionsQueryKey, getBillingPromotionRedemptionsQueryOptions, getBillingPromotionRedemptionsUrl, getBillingQuoteCheckoutMutationKey, getBillingQuoteCheckoutMutationOptions, getBillingQuoteCheckoutUrl, getBillingReadCheckoutQueryKey, getBillingReadCheckoutQueryOptions, getBillingReadCheckoutUrl, getBillingReadSubscriptionQueryKey, getBillingReadSubscriptionQueryOptions, getBillingReadSubscriptionUrl, getBillingReadTransactionQueryKey, getBillingReadTransactionQueryOptions, getBillingReadTransactionUrl, getBillingReconcileCheckoutMutationKey, getBillingReconcileCheckoutMutationOptions, getBillingReconcileCheckoutUrl, getBillingReconcileSubscriptionMutationKey, getBillingReconcileSubscriptionMutationOptions, getBillingReconcileSubscriptionUrl, getBillingRedeemPromotionMutationKey, getBillingRedeemPromotionMutationOptions, getBillingRedeemPromotionUrl, getBillingRestoreStorePurchasesMutationKey, getBillingRestoreStorePurchasesMutationOptions, getBillingRestoreStorePurchasesUrl, getBillingRevealPromotionCodeMutationKey, getBillingRevealPromotionCodeMutationOptions, getBillingRevealPromotionCodeUrl, getBillingSetOfferAvailabilityMutationKey, getBillingSetOfferAvailabilityMutationOptions, getBillingSetOfferAvailabilityUrl, getBillingSubmitCheckoutMutationKey, getBillingSubmitCheckoutMutationOptions, getBillingSubmitCheckoutUrl, getBillingSubscriptionClientTokenMutationKey, getBillingSubscriptionClientTokenMutationOptions, getBillingSubscriptionClientTokenUrl, getBillingSubscriptionHistoryQueryKey, getBillingSubscriptionHistoryQueryOptions, getBillingSubscriptionHistoryUrl, getBillingUpdatePaymentMethodMutationKey, getBillingUpdatePaymentMethodMutationOptions, getBillingUpdatePaymentMethodUrl, useBillingBindProviderProduct, useBillingCancelSubscription, useBillingCancellationFeedback, useBillingCreateClientToken, useBillingCreateProduct, useBillingCreatePromotion, useBillingExportPromotionCodes, useBillingGeneratePromotions, useBillingListProducts, useBillingListPromotions, useBillingListSubscriptions, useBillingListTransactions, useBillingPrepareIdentity, useBillingPromotionCapacity, useBillingPromotionGenerator, useBillingPromotionGenerators, useBillingPromotionRedemptions, useBillingQuoteCheckout, useBillingReadCheckout, useBillingReadSubscription, useBillingReadTransaction, useBillingReconcileCheckout, useBillingReconcileSubscription, useBillingRedeemPromotion, useBillingRestoreStorePurchases, useBillingRevealPromotionCode, useBillingSetOfferAvailability, useBillingSubmitCheckout, useBillingSubscriptionClientToken, useBillingSubscriptionHistory, useBillingUpdatePaymentMethod };
|
|
1490
|
+
|
|
1491
|
+
//# sourceMappingURL=biblio-billing.js.map
|