rutter-ts 0.1.0 → 0.2.0
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 +188 -0
- package/dist/api.cjs +175 -0
- package/dist/api.d.cts +41 -0
- package/dist/api.d.ts +41 -0
- package/dist/api.js +168 -0
- package/dist/chunk-LLGYUOGX.js +36 -0
- package/dist/chunk-LPP3MIOV.cjs +39 -0
- package/dist/client-sPbSz2i_.d.cts +34 -0
- package/dist/client-sPbSz2i_.d.ts +34 -0
- package/dist/index.cjs +11 -209
- package/dist/index.d.cts +3 -72
- package/dist/index.d.ts +3 -72
- package/dist/index.js +3 -200
- package/package.json +11 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
interface RutterErrorMetadata {
|
|
2
|
+
source: 'rutter' | 'platform';
|
|
3
|
+
human_readable: string;
|
|
4
|
+
platform?: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
interface RutterErrorBody {
|
|
7
|
+
error_type: string;
|
|
8
|
+
error_code: string;
|
|
9
|
+
error_message: string;
|
|
10
|
+
error_metadata?: RutterErrorMetadata;
|
|
11
|
+
}
|
|
12
|
+
type RutterPaginationParams = {
|
|
13
|
+
cursor?: string;
|
|
14
|
+
};
|
|
15
|
+
type RutterQueryParams = Record<string, string | number | boolean | undefined>;
|
|
16
|
+
interface RutterRequestOptions {
|
|
17
|
+
idempotencyKey?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare class RutterClient {
|
|
21
|
+
readonly baseUrl: string;
|
|
22
|
+
private readonly clientId;
|
|
23
|
+
private readonly clientSecret;
|
|
24
|
+
constructor(baseUrl: string, clientId: string, clientSecret: string);
|
|
25
|
+
private get authHeader();
|
|
26
|
+
private request;
|
|
27
|
+
private buildPath;
|
|
28
|
+
get<T>(path: string, params?: RutterQueryParams): Promise<T>;
|
|
29
|
+
post<T>(path: string, body?: unknown, options?: RutterRequestOptions): Promise<T>;
|
|
30
|
+
patch<T>(path: string, body?: unknown, options?: RutterRequestOptions): Promise<T>;
|
|
31
|
+
delete<T>(path: string, params?: RutterQueryParams): Promise<T>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { type RutterErrorMetadata as R, type RutterErrorBody as a, RutterClient as b, type RutterPaginationParams as c, type RutterQueryParams as d, type RutterRequestOptions as e };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
interface RutterErrorMetadata {
|
|
2
|
+
source: 'rutter' | 'platform';
|
|
3
|
+
human_readable: string;
|
|
4
|
+
platform?: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
interface RutterErrorBody {
|
|
7
|
+
error_type: string;
|
|
8
|
+
error_code: string;
|
|
9
|
+
error_message: string;
|
|
10
|
+
error_metadata?: RutterErrorMetadata;
|
|
11
|
+
}
|
|
12
|
+
type RutterPaginationParams = {
|
|
13
|
+
cursor?: string;
|
|
14
|
+
};
|
|
15
|
+
type RutterQueryParams = Record<string, string | number | boolean | undefined>;
|
|
16
|
+
interface RutterRequestOptions {
|
|
17
|
+
idempotencyKey?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare class RutterClient {
|
|
21
|
+
readonly baseUrl: string;
|
|
22
|
+
private readonly clientId;
|
|
23
|
+
private readonly clientSecret;
|
|
24
|
+
constructor(baseUrl: string, clientId: string, clientSecret: string);
|
|
25
|
+
private get authHeader();
|
|
26
|
+
private request;
|
|
27
|
+
private buildPath;
|
|
28
|
+
get<T>(path: string, params?: RutterQueryParams): Promise<T>;
|
|
29
|
+
post<T>(path: string, body?: unknown, options?: RutterRequestOptions): Promise<T>;
|
|
30
|
+
patch<T>(path: string, body?: unknown, options?: RutterRequestOptions): Promise<T>;
|
|
31
|
+
delete<T>(path: string, params?: RutterQueryParams): Promise<T>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { type RutterErrorMetadata as R, type RutterErrorBody as a, RutterClient as b, type RutterPaginationParams as c, type RutterQueryParams as d, type RutterRequestOptions as e };
|
package/dist/index.cjs
CHANGED
|
@@ -1,52 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var z2 = require('zod');
|
|
5
|
-
|
|
6
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
-
|
|
8
|
-
var z2__default = /*#__PURE__*/_interopDefault(z2);
|
|
3
|
+
var chunkLPP3MIOV_cjs = require('./chunk-LPP3MIOV.cjs');
|
|
9
4
|
|
|
10
5
|
// src/constants.ts
|
|
11
6
|
var RUTTER_SANDBOX_BASE_URL = "https://sandbox.rutterapi.com/versioned";
|
|
12
7
|
var RUTTER_PRODUCTION_BASE_URL = "https://production.rutterapi.com/versioned";
|
|
13
8
|
var RUTTER_API_VERSION = "2024-08-31";
|
|
14
9
|
|
|
15
|
-
// src/errors.ts
|
|
16
|
-
var RutterError = class extends Error {
|
|
17
|
-
status;
|
|
18
|
-
errorType;
|
|
19
|
-
errorCode;
|
|
20
|
-
metadata;
|
|
21
|
-
constructor(body, status) {
|
|
22
|
-
super(body.error_message);
|
|
23
|
-
this.name = "RutterError";
|
|
24
|
-
this.status = status;
|
|
25
|
-
this.errorType = body.error_type;
|
|
26
|
-
this.errorCode = body.error_code;
|
|
27
|
-
this.metadata = body.error_metadata;
|
|
28
|
-
}
|
|
29
|
-
get isRateLimited() {
|
|
30
|
-
return this.status === 429 || this.status === 452;
|
|
31
|
-
}
|
|
32
|
-
get isUserActionable() {
|
|
33
|
-
return this.status === 400 || this.status === 409 || this.status === 410 || this.status === 450;
|
|
34
|
-
}
|
|
35
|
-
get humanReadableMessage() {
|
|
36
|
-
return this.metadata?.human_readable ?? this.message;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
var RutterSchemaMismatchError = class extends Error {
|
|
40
|
-
endpoint;
|
|
41
|
-
constructor(endpoint, issues) {
|
|
42
|
-
super(
|
|
43
|
-
`Rutter response from ${endpoint} failed schema validation: ${issues}`
|
|
44
|
-
);
|
|
45
|
-
this.name = "RutterSchemaMismatchError";
|
|
46
|
-
this.endpoint = endpoint;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
10
|
// src/client.ts
|
|
51
11
|
var RutterClient = class {
|
|
52
12
|
baseUrl;
|
|
@@ -86,7 +46,7 @@ var RutterClient = class {
|
|
|
86
46
|
try {
|
|
87
47
|
error = await response.json();
|
|
88
48
|
} catch {
|
|
89
|
-
throw new RutterError(
|
|
49
|
+
throw new chunkLPP3MIOV_cjs.RutterError(
|
|
90
50
|
{
|
|
91
51
|
error_type: "HTTP_ERROR",
|
|
92
52
|
error_code: "non_json_response",
|
|
@@ -95,7 +55,7 @@ var RutterClient = class {
|
|
|
95
55
|
response.status
|
|
96
56
|
);
|
|
97
57
|
}
|
|
98
|
-
throw new RutterError(error, response.status);
|
|
58
|
+
throw new chunkLPP3MIOV_cjs.RutterError(error, response.status);
|
|
99
59
|
}
|
|
100
60
|
return response.json();
|
|
101
61
|
}
|
|
@@ -121,174 +81,16 @@ var RutterClient = class {
|
|
|
121
81
|
return this.request("DELETE", this.buildPath(path, params));
|
|
122
82
|
}
|
|
123
83
|
};
|
|
124
|
-
var RutterConnectionsApi = class {
|
|
125
|
-
constructor(client) {
|
|
126
|
-
this.client = client;
|
|
127
|
-
}
|
|
128
|
-
async create(params) {
|
|
129
|
-
const endpoint = "/connections";
|
|
130
|
-
const response = await this.client.post(endpoint, params);
|
|
131
|
-
const result = chunkJCJXW7AE_cjs.zConnectionResponse.safeParse(response);
|
|
132
|
-
if (!result.success) {
|
|
133
|
-
throw new RutterSchemaMismatchError(
|
|
134
|
-
endpoint,
|
|
135
|
-
z2__default.default.prettifyError(result.error)
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
return result.data;
|
|
139
|
-
}
|
|
140
|
-
async list() {
|
|
141
|
-
const endpoint = "/connections";
|
|
142
|
-
const response = await this.client.get(endpoint);
|
|
143
|
-
const result = chunkJCJXW7AE_cjs.zListConnectionsResponse.safeParse(response);
|
|
144
|
-
if (!result.success) {
|
|
145
|
-
throw new RutterSchemaMismatchError(
|
|
146
|
-
endpoint,
|
|
147
|
-
z2__default.default.prettifyError(result.error)
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
return result.data;
|
|
151
|
-
}
|
|
152
|
-
async get(accessToken) {
|
|
153
|
-
const endpoint = "/connections";
|
|
154
|
-
const response = await this.client.get(endpoint, {
|
|
155
|
-
access_token: accessToken
|
|
156
|
-
});
|
|
157
|
-
const result = chunkJCJXW7AE_cjs.zGetAccessTokenConnectionResponse.safeParse(response);
|
|
158
|
-
if (!result.success) {
|
|
159
|
-
throw new RutterSchemaMismatchError(
|
|
160
|
-
endpoint,
|
|
161
|
-
z2__default.default.prettifyError(result.error)
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
return result.data;
|
|
165
|
-
}
|
|
166
|
-
async exchangeToken(params) {
|
|
167
|
-
const endpoint = "/item/public_token/exchange";
|
|
168
|
-
const response = await this.client.post(endpoint, params);
|
|
169
|
-
const result = chunkJCJXW7AE_cjs.zExchangeTokenResponse.safeParse(response);
|
|
170
|
-
if (!result.success) {
|
|
171
|
-
throw new RutterSchemaMismatchError(
|
|
172
|
-
endpoint,
|
|
173
|
-
z2__default.default.prettifyError(result.error)
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
return result.data;
|
|
177
|
-
}
|
|
178
|
-
async delete(accessToken) {
|
|
179
|
-
const endpoint = "/connections";
|
|
180
|
-
const response = await this.client.delete(endpoint, {
|
|
181
|
-
access_token: accessToken
|
|
182
|
-
});
|
|
183
|
-
const result = chunkJCJXW7AE_cjs.zDeleteConnectionResponse.safeParse(response);
|
|
184
|
-
if (!result.success) {
|
|
185
|
-
throw new RutterSchemaMismatchError(
|
|
186
|
-
endpoint,
|
|
187
|
-
z2__default.default.prettifyError(result.error)
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
return result.data;
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
var RutterAccountingApi = class {
|
|
194
|
-
constructor(client) {
|
|
195
|
-
this.client = client;
|
|
196
|
-
}
|
|
197
|
-
async getCompanyInfo(accessToken) {
|
|
198
|
-
const endpoint = "/accounting/company_info";
|
|
199
|
-
const response = await this.client.get(endpoint, {
|
|
200
|
-
access_token: accessToken
|
|
201
|
-
});
|
|
202
|
-
const result = chunkJCJXW7AE_cjs.zCompanyInfo20240430ResponseWithConnection.safeParse(response);
|
|
203
|
-
if (!result.success) {
|
|
204
|
-
throw new RutterSchemaMismatchError(
|
|
205
|
-
endpoint,
|
|
206
|
-
z2__default.default.prettifyError(result.error)
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
return result.data;
|
|
210
|
-
}
|
|
211
|
-
async listAccounts(accessToken, params) {
|
|
212
|
-
const endpoint = "/accounting/accounts";
|
|
213
|
-
const response = await this.client.get(endpoint, {
|
|
214
|
-
access_token: accessToken,
|
|
215
|
-
...params
|
|
216
|
-
});
|
|
217
|
-
const result = chunkJCJXW7AE_cjs.zListAccountResponseWithConnection.safeParse(response);
|
|
218
|
-
if (!result.success) {
|
|
219
|
-
throw new RutterSchemaMismatchError(
|
|
220
|
-
endpoint,
|
|
221
|
-
z2__default.default.prettifyError(result.error)
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
return result.data;
|
|
225
|
-
}
|
|
226
|
-
async getAccount(accessToken, id) {
|
|
227
|
-
const endpoint = `/accounting/accounts/${id}`;
|
|
228
|
-
const response = await this.client.get(endpoint, {
|
|
229
|
-
access_token: accessToken
|
|
230
|
-
});
|
|
231
|
-
const result = chunkJCJXW7AE_cjs.zAccountResponseWithConnection.safeParse(response);
|
|
232
|
-
if (!result.success) {
|
|
233
|
-
throw new RutterSchemaMismatchError(
|
|
234
|
-
endpoint,
|
|
235
|
-
z2__default.default.prettifyError(result.error)
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
return result.data;
|
|
239
|
-
}
|
|
240
|
-
async listInvoices(accessToken, params) {
|
|
241
|
-
const endpoint = "/accounting/invoices";
|
|
242
|
-
const response = await this.client.get(endpoint, {
|
|
243
|
-
access_token: accessToken,
|
|
244
|
-
...params
|
|
245
|
-
});
|
|
246
|
-
const result = chunkJCJXW7AE_cjs.zListInvoiceResponseWithConnection.safeParse(response);
|
|
247
|
-
if (!result.success) {
|
|
248
|
-
throw new RutterSchemaMismatchError(
|
|
249
|
-
endpoint,
|
|
250
|
-
z2__default.default.prettifyError(result.error)
|
|
251
|
-
);
|
|
252
|
-
}
|
|
253
|
-
return result.data;
|
|
254
|
-
}
|
|
255
|
-
async getInvoice(accessToken, id) {
|
|
256
|
-
const endpoint = `/accounting/invoices/${id}`;
|
|
257
|
-
const response = await this.client.get(endpoint, {
|
|
258
|
-
access_token: accessToken
|
|
259
|
-
});
|
|
260
|
-
const result = chunkJCJXW7AE_cjs.zInvoiceResponseWithConnection.safeParse(response);
|
|
261
|
-
if (!result.success) {
|
|
262
|
-
throw new RutterSchemaMismatchError(
|
|
263
|
-
endpoint,
|
|
264
|
-
z2__default.default.prettifyError(result.error)
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
return result.data;
|
|
268
|
-
}
|
|
269
|
-
async createInvoice(accessToken, params, idempotencyKey) {
|
|
270
|
-
const endpoint = "/accounting/invoices";
|
|
271
|
-
const response = await this.client.post(
|
|
272
|
-
`${endpoint}?access_token=${encodeURIComponent(accessToken)}`,
|
|
273
|
-
params,
|
|
274
|
-
idempotencyKey ? { idempotencyKey } : void 0
|
|
275
|
-
);
|
|
276
|
-
const result = chunkJCJXW7AE_cjs.zCreateInvoiceResponse.safeParse(response);
|
|
277
|
-
if (!result.success) {
|
|
278
|
-
throw new RutterSchemaMismatchError(
|
|
279
|
-
endpoint,
|
|
280
|
-
z2__default.default.prettifyError(result.error)
|
|
281
|
-
);
|
|
282
|
-
}
|
|
283
|
-
return result.data;
|
|
284
|
-
}
|
|
285
|
-
};
|
|
286
84
|
|
|
85
|
+
Object.defineProperty(exports, "RutterError", {
|
|
86
|
+
enumerable: true,
|
|
87
|
+
get: function () { return chunkLPP3MIOV_cjs.RutterError; }
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(exports, "RutterSchemaMismatchError", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function () { return chunkLPP3MIOV_cjs.RutterSchemaMismatchError; }
|
|
92
|
+
});
|
|
287
93
|
exports.RUTTER_API_VERSION = RUTTER_API_VERSION;
|
|
288
94
|
exports.RUTTER_PRODUCTION_BASE_URL = RUTTER_PRODUCTION_BASE_URL;
|
|
289
95
|
exports.RUTTER_SANDBOX_BASE_URL = RUTTER_SANDBOX_BASE_URL;
|
|
290
|
-
exports.RutterAccountingApi = RutterAccountingApi;
|
|
291
96
|
exports.RutterClient = RutterClient;
|
|
292
|
-
exports.RutterConnectionsApi = RutterConnectionsApi;
|
|
293
|
-
exports.RutterError = RutterError;
|
|
294
|
-
exports.RutterSchemaMismatchError = RutterSchemaMismatchError;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,38 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
interface RutterErrorMetadata {
|
|
5
|
-
source: 'rutter' | 'platform';
|
|
6
|
-
human_readable: string;
|
|
7
|
-
platform?: Record<string, unknown>;
|
|
8
|
-
}
|
|
9
|
-
interface RutterErrorBody {
|
|
10
|
-
error_type: string;
|
|
11
|
-
error_code: string;
|
|
12
|
-
error_message: string;
|
|
13
|
-
error_metadata?: RutterErrorMetadata;
|
|
14
|
-
}
|
|
15
|
-
type RutterPaginationParams = {
|
|
16
|
-
cursor?: string;
|
|
17
|
-
};
|
|
18
|
-
type RutterQueryParams = Record<string, string | number | boolean | undefined>;
|
|
19
|
-
interface RutterRequestOptions {
|
|
20
|
-
idempotencyKey?: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
declare class RutterClient {
|
|
24
|
-
readonly baseUrl: string;
|
|
25
|
-
private readonly clientId;
|
|
26
|
-
private readonly clientSecret;
|
|
27
|
-
constructor(baseUrl: string, clientId: string, clientSecret: string);
|
|
28
|
-
private get authHeader();
|
|
29
|
-
private request;
|
|
30
|
-
private buildPath;
|
|
31
|
-
get<T>(path: string, params?: RutterQueryParams): Promise<T>;
|
|
32
|
-
post<T>(path: string, body?: unknown, options?: RutterRequestOptions): Promise<T>;
|
|
33
|
-
patch<T>(path: string, body?: unknown, options?: RutterRequestOptions): Promise<T>;
|
|
34
|
-
delete<T>(path: string, params?: RutterQueryParams): Promise<T>;
|
|
35
|
-
}
|
|
1
|
+
import { R as RutterErrorMetadata, a as RutterErrorBody } from './client-sPbSz2i_.cjs';
|
|
2
|
+
export { b as RutterClient, c as RutterPaginationParams, d as RutterQueryParams, e as RutterRequestOptions } from './client-sPbSz2i_.cjs';
|
|
36
3
|
|
|
37
4
|
declare class RutterError extends Error {
|
|
38
5
|
readonly status: number;
|
|
@@ -49,44 +16,8 @@ declare class RutterSchemaMismatchError extends Error {
|
|
|
49
16
|
constructor(endpoint: string, issues: string);
|
|
50
17
|
}
|
|
51
18
|
|
|
52
|
-
type TConnectionResponse = z__default.infer<typeof zConnectionResponse>;
|
|
53
|
-
type TListConnectionsResponse = z__default.infer<typeof zListConnectionsResponse>;
|
|
54
|
-
type TExchangeTokenResponse = z__default.infer<typeof zExchangeTokenResponse>;
|
|
55
|
-
type TDeleteConnectionResponse = z__default.infer<typeof zDeleteConnectionResponse>;
|
|
56
|
-
type TGetAccessTokenConnectionResponse = z__default.infer<typeof zGetAccessTokenConnectionResponse>;
|
|
57
|
-
declare class RutterConnectionsApi {
|
|
58
|
-
private readonly client;
|
|
59
|
-
constructor(client: RutterClient);
|
|
60
|
-
create(params: {
|
|
61
|
-
platform: string;
|
|
62
|
-
}): Promise<TConnectionResponse>;
|
|
63
|
-
list(): Promise<TListConnectionsResponse>;
|
|
64
|
-
get(accessToken: string): Promise<TGetAccessTokenConnectionResponse>;
|
|
65
|
-
exchangeToken(params: {
|
|
66
|
-
public_token: string;
|
|
67
|
-
}): Promise<TExchangeTokenResponse>;
|
|
68
|
-
delete(accessToken: string): Promise<TDeleteConnectionResponse>;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
type TCompanyInfoResponse = z__default.infer<typeof zCompanyInfo20240430ResponseWithConnection>;
|
|
72
|
-
type TListAccountsResponse = z__default.infer<typeof zListAccountResponseWithConnection>;
|
|
73
|
-
type TAccountResponse = z__default.infer<typeof zAccountResponseWithConnection>;
|
|
74
|
-
type TListInvoicesResponse = z__default.infer<typeof zListInvoiceResponseWithConnection>;
|
|
75
|
-
type TInvoiceResponse = z__default.infer<typeof zInvoiceResponseWithConnection>;
|
|
76
|
-
type TCreateInvoiceResponse = z__default.infer<typeof zCreateInvoiceResponse>;
|
|
77
|
-
declare class RutterAccountingApi {
|
|
78
|
-
private readonly client;
|
|
79
|
-
constructor(client: RutterClient);
|
|
80
|
-
getCompanyInfo(accessToken: string): Promise<TCompanyInfoResponse>;
|
|
81
|
-
listAccounts(accessToken: string, params?: RutterPaginationParams & RutterQueryParams): Promise<TListAccountsResponse>;
|
|
82
|
-
getAccount(accessToken: string, id: string): Promise<TAccountResponse>;
|
|
83
|
-
listInvoices(accessToken: string, params?: RutterPaginationParams & RutterQueryParams): Promise<TListInvoicesResponse>;
|
|
84
|
-
getInvoice(accessToken: string, id: string): Promise<TInvoiceResponse>;
|
|
85
|
-
createInvoice(accessToken: string, params: CreateInvoice, idempotencyKey?: string): Promise<TCreateInvoiceResponse>;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
19
|
declare const RUTTER_SANDBOX_BASE_URL = "https://sandbox.rutterapi.com/versioned";
|
|
89
20
|
declare const RUTTER_PRODUCTION_BASE_URL = "https://production.rutterapi.com/versioned";
|
|
90
21
|
declare const RUTTER_API_VERSION = "2024-08-31";
|
|
91
22
|
|
|
92
|
-
export { RUTTER_API_VERSION, RUTTER_PRODUCTION_BASE_URL, RUTTER_SANDBOX_BASE_URL,
|
|
23
|
+
export { RUTTER_API_VERSION, RUTTER_PRODUCTION_BASE_URL, RUTTER_SANDBOX_BASE_URL, RutterError, RutterErrorBody, RutterErrorMetadata, RutterSchemaMismatchError };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,38 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
interface RutterErrorMetadata {
|
|
5
|
-
source: 'rutter' | 'platform';
|
|
6
|
-
human_readable: string;
|
|
7
|
-
platform?: Record<string, unknown>;
|
|
8
|
-
}
|
|
9
|
-
interface RutterErrorBody {
|
|
10
|
-
error_type: string;
|
|
11
|
-
error_code: string;
|
|
12
|
-
error_message: string;
|
|
13
|
-
error_metadata?: RutterErrorMetadata;
|
|
14
|
-
}
|
|
15
|
-
type RutterPaginationParams = {
|
|
16
|
-
cursor?: string;
|
|
17
|
-
};
|
|
18
|
-
type RutterQueryParams = Record<string, string | number | boolean | undefined>;
|
|
19
|
-
interface RutterRequestOptions {
|
|
20
|
-
idempotencyKey?: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
declare class RutterClient {
|
|
24
|
-
readonly baseUrl: string;
|
|
25
|
-
private readonly clientId;
|
|
26
|
-
private readonly clientSecret;
|
|
27
|
-
constructor(baseUrl: string, clientId: string, clientSecret: string);
|
|
28
|
-
private get authHeader();
|
|
29
|
-
private request;
|
|
30
|
-
private buildPath;
|
|
31
|
-
get<T>(path: string, params?: RutterQueryParams): Promise<T>;
|
|
32
|
-
post<T>(path: string, body?: unknown, options?: RutterRequestOptions): Promise<T>;
|
|
33
|
-
patch<T>(path: string, body?: unknown, options?: RutterRequestOptions): Promise<T>;
|
|
34
|
-
delete<T>(path: string, params?: RutterQueryParams): Promise<T>;
|
|
35
|
-
}
|
|
1
|
+
import { R as RutterErrorMetadata, a as RutterErrorBody } from './client-sPbSz2i_.js';
|
|
2
|
+
export { b as RutterClient, c as RutterPaginationParams, d as RutterQueryParams, e as RutterRequestOptions } from './client-sPbSz2i_.js';
|
|
36
3
|
|
|
37
4
|
declare class RutterError extends Error {
|
|
38
5
|
readonly status: number;
|
|
@@ -49,44 +16,8 @@ declare class RutterSchemaMismatchError extends Error {
|
|
|
49
16
|
constructor(endpoint: string, issues: string);
|
|
50
17
|
}
|
|
51
18
|
|
|
52
|
-
type TConnectionResponse = z__default.infer<typeof zConnectionResponse>;
|
|
53
|
-
type TListConnectionsResponse = z__default.infer<typeof zListConnectionsResponse>;
|
|
54
|
-
type TExchangeTokenResponse = z__default.infer<typeof zExchangeTokenResponse>;
|
|
55
|
-
type TDeleteConnectionResponse = z__default.infer<typeof zDeleteConnectionResponse>;
|
|
56
|
-
type TGetAccessTokenConnectionResponse = z__default.infer<typeof zGetAccessTokenConnectionResponse>;
|
|
57
|
-
declare class RutterConnectionsApi {
|
|
58
|
-
private readonly client;
|
|
59
|
-
constructor(client: RutterClient);
|
|
60
|
-
create(params: {
|
|
61
|
-
platform: string;
|
|
62
|
-
}): Promise<TConnectionResponse>;
|
|
63
|
-
list(): Promise<TListConnectionsResponse>;
|
|
64
|
-
get(accessToken: string): Promise<TGetAccessTokenConnectionResponse>;
|
|
65
|
-
exchangeToken(params: {
|
|
66
|
-
public_token: string;
|
|
67
|
-
}): Promise<TExchangeTokenResponse>;
|
|
68
|
-
delete(accessToken: string): Promise<TDeleteConnectionResponse>;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
type TCompanyInfoResponse = z__default.infer<typeof zCompanyInfo20240430ResponseWithConnection>;
|
|
72
|
-
type TListAccountsResponse = z__default.infer<typeof zListAccountResponseWithConnection>;
|
|
73
|
-
type TAccountResponse = z__default.infer<typeof zAccountResponseWithConnection>;
|
|
74
|
-
type TListInvoicesResponse = z__default.infer<typeof zListInvoiceResponseWithConnection>;
|
|
75
|
-
type TInvoiceResponse = z__default.infer<typeof zInvoiceResponseWithConnection>;
|
|
76
|
-
type TCreateInvoiceResponse = z__default.infer<typeof zCreateInvoiceResponse>;
|
|
77
|
-
declare class RutterAccountingApi {
|
|
78
|
-
private readonly client;
|
|
79
|
-
constructor(client: RutterClient);
|
|
80
|
-
getCompanyInfo(accessToken: string): Promise<TCompanyInfoResponse>;
|
|
81
|
-
listAccounts(accessToken: string, params?: RutterPaginationParams & RutterQueryParams): Promise<TListAccountsResponse>;
|
|
82
|
-
getAccount(accessToken: string, id: string): Promise<TAccountResponse>;
|
|
83
|
-
listInvoices(accessToken: string, params?: RutterPaginationParams & RutterQueryParams): Promise<TListInvoicesResponse>;
|
|
84
|
-
getInvoice(accessToken: string, id: string): Promise<TInvoiceResponse>;
|
|
85
|
-
createInvoice(accessToken: string, params: CreateInvoice, idempotencyKey?: string): Promise<TCreateInvoiceResponse>;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
19
|
declare const RUTTER_SANDBOX_BASE_URL = "https://sandbox.rutterapi.com/versioned";
|
|
89
20
|
declare const RUTTER_PRODUCTION_BASE_URL = "https://production.rutterapi.com/versioned";
|
|
90
21
|
declare const RUTTER_API_VERSION = "2024-08-31";
|
|
91
22
|
|
|
92
|
-
export { RUTTER_API_VERSION, RUTTER_PRODUCTION_BASE_URL, RUTTER_SANDBOX_BASE_URL,
|
|
23
|
+
export { RUTTER_API_VERSION, RUTTER_PRODUCTION_BASE_URL, RUTTER_SANDBOX_BASE_URL, RutterError, RutterErrorBody, RutterErrorMetadata, RutterSchemaMismatchError };
|