@parra/parra-js-sdk 0.2.42 → 0.2.45
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/ParraAPI.d.ts +22 -1
- package/dist/ParraAPI.js +55 -32
- package/dist/index.js +6 -2
- package/package.json +4 -4
package/dist/ParraAPI.d.ts
CHANGED
|
@@ -99,6 +99,21 @@ export interface TenantPlansResponse {
|
|
|
99
99
|
}
|
|
100
100
|
export interface StripeEvent {
|
|
101
101
|
}
|
|
102
|
+
export interface CreateAudienceRequestBody {
|
|
103
|
+
tenant_id: string;
|
|
104
|
+
name: string;
|
|
105
|
+
}
|
|
106
|
+
export interface Audience {
|
|
107
|
+
id: string;
|
|
108
|
+
created_at: string;
|
|
109
|
+
updated_at: string;
|
|
110
|
+
deleted_at?: string | null;
|
|
111
|
+
tenant_id: string;
|
|
112
|
+
name: string;
|
|
113
|
+
}
|
|
114
|
+
export interface CreateSubscriberRequestBody {
|
|
115
|
+
email: string;
|
|
116
|
+
}
|
|
102
117
|
export interface Entitlement {
|
|
103
118
|
}
|
|
104
119
|
export declare type Entitlements = Array<Entitlement>;
|
|
@@ -167,7 +182,7 @@ export interface ApiKeyCollectionResponse {
|
|
|
167
182
|
export interface AnswerData {
|
|
168
183
|
}
|
|
169
184
|
export interface FeedbackMetrics {
|
|
170
|
-
|
|
185
|
+
questions_created_this_month: number;
|
|
171
186
|
}
|
|
172
187
|
export interface Answer {
|
|
173
188
|
id: string;
|
|
@@ -404,6 +419,9 @@ export interface UserCollectionResponse {
|
|
|
404
419
|
export interface CheckAuthorizationRequestBody {
|
|
405
420
|
scope: string;
|
|
406
421
|
}
|
|
422
|
+
export interface AuthToken {
|
|
423
|
+
access_token: boolean;
|
|
424
|
+
}
|
|
407
425
|
export interface CheckAuthorization {
|
|
408
426
|
allowed: boolean;
|
|
409
427
|
}
|
|
@@ -421,6 +439,8 @@ declare class ParraAPI {
|
|
|
421
439
|
createBillingPortalSession: (tenant_id: string) => Promise<BillingPortalSession>;
|
|
422
440
|
createCheckoutSession: (body?: CreateCheckoutSessionRequestBody | undefined) => Promise<CheckoutSession>;
|
|
423
441
|
getPlansForTenantById: (tenant_id: string) => Promise<TenantPlansResponse>;
|
|
442
|
+
createAudience: (body?: CreateAudienceRequestBody | undefined) => Promise<Audience>;
|
|
443
|
+
createSubscriberForAudienceById: (audience_id: string, body?: CreateSubscriberRequestBody | undefined) => Promise<Response>;
|
|
424
444
|
getTenantById: (tenant_id: string) => Promise<Tenant>;
|
|
425
445
|
createTenantForUserById: (user_id: string, body?: CreateTenantRequestBody | undefined) => Promise<Tenant>;
|
|
426
446
|
getTenantsForUserById: (user_id: string) => Promise<TenantListResponse>;
|
|
@@ -464,5 +484,6 @@ declare class ParraAPI {
|
|
|
464
484
|
getUserByProviderAndProviderUserId: (provider: string, provider_user_id: string) => Promise<UserResponse>;
|
|
465
485
|
checkAuthorization: (body?: CheckAuthorizationRequestBody | undefined) => Promise<CheckAuthorization>;
|
|
466
486
|
getUserInfo: () => Promise<UserInfoResponse>;
|
|
487
|
+
getParraAuthToken: () => Promise<AuthToken>;
|
|
467
488
|
}
|
|
468
489
|
export default ParraAPI;
|
package/dist/ParraAPI.js
CHANGED
|
@@ -46,7 +46,7 @@ var ParraAPI = /** @class */ (function () {
|
|
|
46
46
|
this.http = http;
|
|
47
47
|
this.options = options;
|
|
48
48
|
this.createCustomer = function (body) {
|
|
49
|
-
return _this.http.execute(_this.options.baseUrl
|
|
49
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/customers"), {
|
|
50
50
|
method: "post",
|
|
51
51
|
body: JSON.stringify(body),
|
|
52
52
|
headers: {
|
|
@@ -55,17 +55,17 @@ var ParraAPI = /** @class */ (function () {
|
|
|
55
55
|
});
|
|
56
56
|
};
|
|
57
57
|
this.updateEntitlementsForCustomerById = function (customer_id) {
|
|
58
|
-
return _this.http.execute(_this.options.baseUrl
|
|
58
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/customers/").concat(customer_id, "/entitlements"), {
|
|
59
59
|
method: "post",
|
|
60
60
|
});
|
|
61
61
|
};
|
|
62
62
|
this.createBillingPortalSession = function (tenant_id) {
|
|
63
|
-
return _this.http.execute(_this.options.baseUrl
|
|
63
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/tenants/").concat(tenant_id, "/billing-portal/sessions"), {
|
|
64
64
|
method: "post",
|
|
65
65
|
});
|
|
66
66
|
};
|
|
67
67
|
this.createCheckoutSession = function (body) {
|
|
68
|
-
return _this.http.execute(_this.options.baseUrl
|
|
68
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/checkout/sessions"), {
|
|
69
69
|
method: "post",
|
|
70
70
|
body: JSON.stringify(body),
|
|
71
71
|
headers: {
|
|
@@ -74,17 +74,35 @@ var ParraAPI = /** @class */ (function () {
|
|
|
74
74
|
});
|
|
75
75
|
};
|
|
76
76
|
this.getPlansForTenantById = function (tenant_id) {
|
|
77
|
-
return _this.http.execute(_this.options.baseUrl
|
|
77
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/tenants/").concat(tenant_id, "/plans"), {
|
|
78
78
|
method: "post",
|
|
79
79
|
});
|
|
80
80
|
};
|
|
81
|
+
this.createAudience = function (body) {
|
|
82
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/email/audiences"), {
|
|
83
|
+
method: "post",
|
|
84
|
+
body: JSON.stringify(body),
|
|
85
|
+
headers: {
|
|
86
|
+
"content-type": "application/json",
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
this.createSubscriberForAudienceById = function (audience_id, body) {
|
|
91
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/email/audiences/").concat(audience_id, "/subscribers"), {
|
|
92
|
+
method: "post",
|
|
93
|
+
body: JSON.stringify(body),
|
|
94
|
+
headers: {
|
|
95
|
+
"content-type": "application/json",
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
};
|
|
81
99
|
this.getTenantById = function (tenant_id) {
|
|
82
|
-
return _this.http.execute(_this.options.baseUrl
|
|
100
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/tenants/").concat(tenant_id), {
|
|
83
101
|
method: "get",
|
|
84
102
|
});
|
|
85
103
|
};
|
|
86
104
|
this.createTenantForUserById = function (user_id, body) {
|
|
87
|
-
return _this.http.execute(_this.options.baseUrl
|
|
105
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/users/").concat(user_id, "/tenants"), {
|
|
88
106
|
method: "post",
|
|
89
107
|
body: JSON.stringify(body),
|
|
90
108
|
headers: {
|
|
@@ -93,12 +111,12 @@ var ParraAPI = /** @class */ (function () {
|
|
|
93
111
|
});
|
|
94
112
|
};
|
|
95
113
|
this.getTenantsForUserById = function (user_id) {
|
|
96
|
-
return _this.http.execute(_this.options.baseUrl
|
|
114
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/users/").concat(user_id, "/tenants"), {
|
|
97
115
|
method: "get",
|
|
98
116
|
});
|
|
99
117
|
};
|
|
100
118
|
this.createApiKeyForTenantById = function (tenant_id, body) {
|
|
101
|
-
return _this.http.execute(_this.options.baseUrl
|
|
119
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/tenants/").concat(tenant_id, "/api-keys"), {
|
|
102
120
|
method: "post",
|
|
103
121
|
body: JSON.stringify(body),
|
|
104
122
|
headers: {
|
|
@@ -107,27 +125,27 @@ var ParraAPI = /** @class */ (function () {
|
|
|
107
125
|
});
|
|
108
126
|
};
|
|
109
127
|
this.getApiKeysForTenantById = function (tenant_id) {
|
|
110
|
-
return _this.http.execute(_this.options.baseUrl
|
|
128
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/tenants/").concat(tenant_id, "/api-keys"), {
|
|
111
129
|
method: "get",
|
|
112
130
|
});
|
|
113
131
|
};
|
|
114
132
|
this.deleteApiKeyForTenantById = function (tenant_id, api_key_id) {
|
|
115
|
-
return _this.http.execute(_this.options.baseUrl
|
|
133
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/tenants/").concat(tenant_id, "/api-keys/").concat(api_key_id), {
|
|
116
134
|
method: "delete",
|
|
117
135
|
});
|
|
118
136
|
};
|
|
119
137
|
this.getTenantForApiKeyById = function (api_key_id) {
|
|
120
|
-
return _this.http.execute(_this.options.baseUrl
|
|
138
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/api-keys/").concat(api_key_id, "/tenant"), {
|
|
121
139
|
method: "get",
|
|
122
140
|
});
|
|
123
141
|
};
|
|
124
142
|
this.getCards = function () {
|
|
125
|
-
return _this.http.execute(_this.options.baseUrl
|
|
143
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/cards"), {
|
|
126
144
|
method: "get",
|
|
127
145
|
});
|
|
128
146
|
};
|
|
129
147
|
this.createQuestion = function (body) {
|
|
130
|
-
return _this.http.execute(_this.options.baseUrl
|
|
148
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/questions"), {
|
|
131
149
|
method: "post",
|
|
132
150
|
body: JSON.stringify(body),
|
|
133
151
|
headers: {
|
|
@@ -136,18 +154,18 @@ var ParraAPI = /** @class */ (function () {
|
|
|
136
154
|
});
|
|
137
155
|
};
|
|
138
156
|
this.paginateQuestions = function (query) {
|
|
139
|
-
return _this.http.execute(_this.options.baseUrl
|
|
157
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/questions"), {
|
|
140
158
|
method: "get",
|
|
141
159
|
query: query,
|
|
142
160
|
});
|
|
143
161
|
};
|
|
144
162
|
this.getQuestionById = function (question_id) {
|
|
145
|
-
return _this.http.execute(_this.options.baseUrl
|
|
163
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/questions/").concat(question_id), {
|
|
146
164
|
method: "get",
|
|
147
165
|
});
|
|
148
166
|
};
|
|
149
167
|
this.updateQuestionById = function (question_id, body) {
|
|
150
|
-
return _this.http.execute(_this.options.baseUrl
|
|
168
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/questions/").concat(question_id), {
|
|
151
169
|
method: "put",
|
|
152
170
|
body: JSON.stringify(body),
|
|
153
171
|
headers: {
|
|
@@ -156,22 +174,22 @@ var ParraAPI = /** @class */ (function () {
|
|
|
156
174
|
});
|
|
157
175
|
};
|
|
158
176
|
this.deleteQuestionById = function (question_id) {
|
|
159
|
-
return _this.http.execute(_this.options.baseUrl
|
|
177
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/questions/").concat(question_id), {
|
|
160
178
|
method: "delete",
|
|
161
179
|
});
|
|
162
180
|
};
|
|
163
181
|
this.closeQuestionById = function (question_id) {
|
|
164
|
-
return _this.http.execute(_this.options.baseUrl
|
|
182
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/questions/").concat(question_id, "/close"), {
|
|
165
183
|
method: "post",
|
|
166
184
|
});
|
|
167
185
|
};
|
|
168
186
|
this.createMetricsForQuestionById = function (question_id) {
|
|
169
|
-
return _this.http.execute(_this.options.baseUrl
|
|
187
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/questions/").concat(question_id, "/metrics"), {
|
|
170
188
|
method: "post",
|
|
171
189
|
});
|
|
172
190
|
};
|
|
173
191
|
this.answerQuestionById = function (question_id, body) {
|
|
174
|
-
return _this.http.execute(_this.options.baseUrl
|
|
192
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/questions/").concat(question_id, "/answer"), {
|
|
175
193
|
method: "put",
|
|
176
194
|
body: JSON.stringify(body),
|
|
177
195
|
headers: {
|
|
@@ -180,7 +198,7 @@ var ParraAPI = /** @class */ (function () {
|
|
|
180
198
|
});
|
|
181
199
|
};
|
|
182
200
|
this.bulkAnswerQuestions = function (body) {
|
|
183
|
-
return _this.http.execute(_this.options.baseUrl
|
|
201
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/bulk/questions/answer"), {
|
|
184
202
|
method: "post",
|
|
185
203
|
body: JSON.stringify(body),
|
|
186
204
|
headers: {
|
|
@@ -189,7 +207,7 @@ var ParraAPI = /** @class */ (function () {
|
|
|
189
207
|
});
|
|
190
208
|
};
|
|
191
209
|
this.createUser = function (body) {
|
|
192
|
-
return _this.http.execute(_this.options.baseUrl
|
|
210
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/users"), {
|
|
193
211
|
method: "post",
|
|
194
212
|
body: JSON.stringify(body),
|
|
195
213
|
headers: {
|
|
@@ -198,18 +216,18 @@ var ParraAPI = /** @class */ (function () {
|
|
|
198
216
|
});
|
|
199
217
|
};
|
|
200
218
|
this.listUsers = function (query) {
|
|
201
|
-
return _this.http.execute(_this.options.baseUrl
|
|
219
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/users"), {
|
|
202
220
|
method: "get",
|
|
203
221
|
query: query,
|
|
204
222
|
});
|
|
205
223
|
};
|
|
206
224
|
this.getUserById = function (user_id) {
|
|
207
|
-
return _this.http.execute(_this.options.baseUrl
|
|
225
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/users/").concat(user_id), {
|
|
208
226
|
method: "get",
|
|
209
227
|
});
|
|
210
228
|
};
|
|
211
229
|
this.updateUserById = function (user_id, body) {
|
|
212
|
-
return _this.http.execute(_this.options.baseUrl
|
|
230
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/users/").concat(user_id), {
|
|
213
231
|
method: "put",
|
|
214
232
|
body: JSON.stringify(body),
|
|
215
233
|
headers: {
|
|
@@ -218,12 +236,12 @@ var ParraAPI = /** @class */ (function () {
|
|
|
218
236
|
});
|
|
219
237
|
};
|
|
220
238
|
this.deleteUserById = function (user_id) {
|
|
221
|
-
return _this.http.execute(_this.options.baseUrl
|
|
239
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/users/").concat(user_id), {
|
|
222
240
|
method: "delete",
|
|
223
241
|
});
|
|
224
242
|
};
|
|
225
243
|
this.createIdentityForUserById = function (user_id, body) {
|
|
226
|
-
return _this.http.execute(_this.options.baseUrl
|
|
244
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/users/").concat(user_id, "/identities"), {
|
|
227
245
|
method: "post",
|
|
228
246
|
body: JSON.stringify(body),
|
|
229
247
|
headers: {
|
|
@@ -232,17 +250,17 @@ var ParraAPI = /** @class */ (function () {
|
|
|
232
250
|
});
|
|
233
251
|
};
|
|
234
252
|
this.listIdentitiesForUserById = function (user_id) {
|
|
235
|
-
return _this.http.execute(_this.options.baseUrl
|
|
253
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/users/").concat(user_id, "/identities"), {
|
|
236
254
|
method: "get",
|
|
237
255
|
});
|
|
238
256
|
};
|
|
239
257
|
this.getUserByProviderAndProviderUserId = function (provider, provider_user_id) {
|
|
240
|
-
return _this.http.execute(_this.options.baseUrl
|
|
258
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/providers/").concat(provider, "/identities/").concat(provider_user_id, "/user"), {
|
|
241
259
|
method: "get",
|
|
242
260
|
});
|
|
243
261
|
};
|
|
244
262
|
this.checkAuthorization = function (body) {
|
|
245
|
-
return _this.http.execute(_this.options.baseUrl
|
|
263
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/tenants/authorization/check"), {
|
|
246
264
|
method: "post",
|
|
247
265
|
body: JSON.stringify(body),
|
|
248
266
|
headers: {
|
|
@@ -251,10 +269,15 @@ var ParraAPI = /** @class */ (function () {
|
|
|
251
269
|
});
|
|
252
270
|
};
|
|
253
271
|
this.getUserInfo = function () {
|
|
254
|
-
return _this.http.execute(_this.options.baseUrl
|
|
272
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/user-info"), {
|
|
255
273
|
method: "get",
|
|
256
274
|
});
|
|
257
275
|
};
|
|
276
|
+
this.getParraAuthToken = function () {
|
|
277
|
+
return _this.http.execute("".concat(_this.options.baseUrl, "/v1/parra/auth/token"), {
|
|
278
|
+
method: "post",
|
|
279
|
+
});
|
|
280
|
+
};
|
|
258
281
|
}
|
|
259
282
|
return ParraAPI;
|
|
260
283
|
}());
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
8
12
|
}));
|
|
9
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
15
|
};
|
|
12
16
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parra/parra-js-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.45",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"author": "Parra",
|
|
19
19
|
"license": "ISC",
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"prettier": "^2.
|
|
22
|
-
"typescript": "^
|
|
21
|
+
"prettier": "^2.6.2",
|
|
22
|
+
"typescript": "^4.6.3"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@parra/http-client": "0.
|
|
25
|
+
"@parra/http-client": "0.2.0",
|
|
26
26
|
"isomorphic-fetch": "^3.0.0"
|
|
27
27
|
}
|
|
28
28
|
}
|