@outseta/node-sdk 0.3.35 → 0.3.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +7 -7
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -52,11 +52,11 @@ async function verifyJwtWithProfile(client, token) {
|
|
|
52
52
|
return { payload, profile };
|
|
53
53
|
}
|
|
54
54
|
// src/generate-token.ts
|
|
55
|
-
async function generateAccessToken(client,
|
|
55
|
+
async function generateAccessToken(client, email) {
|
|
56
56
|
const response = await client("tokens", {
|
|
57
57
|
method: "POST",
|
|
58
58
|
headers: { "Content-Type": "application/json" },
|
|
59
|
-
body: JSON.stringify({ username:
|
|
59
|
+
body: JSON.stringify({ username: email })
|
|
60
60
|
});
|
|
61
61
|
if (!response.ok) {
|
|
62
62
|
throw new Error(`Failed to generate access token: ${response.status} ${response.statusText}`);
|
|
@@ -86,8 +86,8 @@ function getErrorMessage(body) {
|
|
|
86
86
|
async function assertOk(response, endpoint) {
|
|
87
87
|
const body = await readResponseBody(response);
|
|
88
88
|
if (!response.ok) {
|
|
89
|
-
const
|
|
90
|
-
throw new Error(`${endpoint}: [${response.status}] ${
|
|
89
|
+
const message = getErrorMessage(body);
|
|
90
|
+
throw new Error(`${endpoint}: [${response.status}] ${message || response.statusText}`);
|
|
91
91
|
}
|
|
92
92
|
return body;
|
|
93
93
|
}
|
|
@@ -95,9 +95,9 @@ async function trackUsage(client, params) {
|
|
|
95
95
|
const fields = new URLSearchParams({ fields: USAGE_ACCOUNT_FIELDS });
|
|
96
96
|
const accountEndpoint = `crm/accounts/${params.accountUid}?${fields.toString()}`;
|
|
97
97
|
const accountResponse = await client(accountEndpoint, { method: "GET" });
|
|
98
|
-
const
|
|
99
|
-
const addOnSubscriptions =
|
|
100
|
-
const targetAddOnSubscription = addOnSubscriptions.find((
|
|
98
|
+
const account = await assertOk(accountResponse, "/api/v1/crm/accounts/:accountUid");
|
|
99
|
+
const addOnSubscriptions = account.CurrentSubscription?.SubscriptionAddOns ?? [];
|
|
100
|
+
const targetAddOnSubscription = addOnSubscriptions.find((subscriptionAddOn) => subscriptionAddOn.AddOn?.Uid === params.addOnUid);
|
|
101
101
|
if (!targetAddOnSubscription?.Uid) {
|
|
102
102
|
throw new Error(`Subscription for add-on with UID ${params.addOnUid} not found for account ${params.accountUid}`);
|
|
103
103
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outseta/node-sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.37",
|
|
4
4
|
"description": "Node.js SDK for the Outseta API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"jose": "^6.2.1",
|
|
22
|
-
"@outseta/api-client": "0.3.
|
|
22
|
+
"@outseta/api-client": "0.3.37"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^25.9.1",
|