@astrada.co/ts-astrada-sdk 1.0.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.
Files changed (200) hide show
  1. package/.editorconfig +10 -0
  2. package/.github/workflows/on-push.yml +65 -0
  3. package/.releaserc +21 -0
  4. package/CHANGELOG.md +13 -0
  5. package/README.md +1 -0
  6. package/dist/astrada.co-ts-astrada-sdk-1.0.0.tgz +0 -0
  7. package/lib/apis/CardApi.d.ts +57 -0
  8. package/lib/apis/CardApi.js +109 -0
  9. package/lib/apis/CardSubscriptionApi.d.ts +61 -0
  10. package/lib/apis/CardSubscriptionApi.js +133 -0
  11. package/lib/apis/CardholderApi.d.ts +31 -0
  12. package/lib/apis/CardholderApi.js +56 -0
  13. package/lib/apis/EnrollmentMethodsApi.d.ts +31 -0
  14. package/lib/apis/EnrollmentMethodsApi.js +57 -0
  15. package/lib/apis/NetworkBulkFeedsApi.d.ts +60 -0
  16. package/lib/apis/NetworkBulkFeedsApi.js +129 -0
  17. package/lib/apis/SubaccountsApi.d.ts +72 -0
  18. package/lib/apis/SubaccountsApi.js +157 -0
  19. package/lib/apis/TransactionMessagesApi.d.ts +31 -0
  20. package/lib/apis/TransactionMessagesApi.js +56 -0
  21. package/lib/apis/TransactionsApi.d.ts +56 -0
  22. package/lib/apis/TransactionsApi.js +106 -0
  23. package/lib/apis/WebhooksApi.d.ts +86 -0
  24. package/lib/apis/WebhooksApi.js +194 -0
  25. package/lib/apis/index.d.ts +9 -0
  26. package/lib/apis/index.js +27 -0
  27. package/lib/index.d.ts +3 -0
  28. package/lib/index.js +21 -0
  29. package/lib/models/Card.d.ts +112 -0
  30. package/lib/models/Card.js +109 -0
  31. package/lib/models/CardLinks.d.ts +39 -0
  32. package/lib/models/CardLinks.js +53 -0
  33. package/lib/models/CardSubscription.d.ts +118 -0
  34. package/lib/models/CardSubscription.js +109 -0
  35. package/lib/models/CardSubscriptionLinks.d.ts +45 -0
  36. package/lib/models/CardSubscriptionLinks.js +57 -0
  37. package/lib/models/Cardholder.d.ts +64 -0
  38. package/lib/models/Cardholder.js +68 -0
  39. package/lib/models/CardholderCorporate.d.ts +38 -0
  40. package/lib/models/CardholderCorporate.js +50 -0
  41. package/lib/models/CardholderLinks.d.ts +33 -0
  42. package/lib/models/CardholderLinks.js +51 -0
  43. package/lib/models/Conflict.d.ts +57 -0
  44. package/lib/models/Conflict.js +67 -0
  45. package/lib/models/CreateNetworkBulkFeedRequest.d.ts +52 -0
  46. package/lib/models/CreateNetworkBulkFeedRequest.js +66 -0
  47. package/lib/models/CreateSubaccountRequest.d.ts +39 -0
  48. package/lib/models/CreateSubaccountRequest.js +55 -0
  49. package/lib/models/CreateWebhook201Response.d.ts +98 -0
  50. package/lib/models/CreateWebhook201Response.js +96 -0
  51. package/lib/models/CreateWebhookRequest.d.ts +67 -0
  52. package/lib/models/CreateWebhookRequest.js +73 -0
  53. package/lib/models/EnrollmentMethods200Response.d.ts +40 -0
  54. package/lib/models/EnrollmentMethods200Response.js +58 -0
  55. package/lib/models/EnrollmentMethodsRequest.d.ts +32 -0
  56. package/lib/models/EnrollmentMethodsRequest.js +50 -0
  57. package/lib/models/GetSubaccounts200Response.d.ts +40 -0
  58. package/lib/models/GetSubaccounts200Response.js +56 -0
  59. package/lib/models/GetSubaccounts200ResponseEmbedded.d.ts +33 -0
  60. package/lib/models/GetSubaccounts200ResponseEmbedded.js +51 -0
  61. package/lib/models/GetSubaccounts200ResponseLinks.d.ts +39 -0
  62. package/lib/models/GetSubaccounts200ResponseLinks.js +53 -0
  63. package/lib/models/GetTransactions200Response.d.ts +40 -0
  64. package/lib/models/GetTransactions200Response.js +56 -0
  65. package/lib/models/GetTransactions200ResponseEmbedded.d.ts +33 -0
  66. package/lib/models/GetTransactions200ResponseEmbedded.js +51 -0
  67. package/lib/models/InlineObject.d.ts +52 -0
  68. package/lib/models/InlineObject.js +64 -0
  69. package/lib/models/InlineObject1.d.ts +45 -0
  70. package/lib/models/InlineObject1.js +61 -0
  71. package/lib/models/InlineObject2.d.ts +45 -0
  72. package/lib/models/InlineObject2.js +61 -0
  73. package/lib/models/InlineObject3.d.ts +45 -0
  74. package/lib/models/InlineObject3.js +61 -0
  75. package/lib/models/InlineObject4.d.ts +57 -0
  76. package/lib/models/InlineObject4.js +65 -0
  77. package/lib/models/InlineObject5.d.ts +45 -0
  78. package/lib/models/InlineObject5.js +61 -0
  79. package/lib/models/InlineObjectErrorsInner.d.ts +38 -0
  80. package/lib/models/InlineObjectErrorsInner.js +54 -0
  81. package/lib/models/Link.d.ts +74 -0
  82. package/lib/models/Link.js +64 -0
  83. package/lib/models/ListCardSubscriptions200Response.d.ts +46 -0
  84. package/lib/models/ListCardSubscriptions200Response.js +60 -0
  85. package/lib/models/ListCardSubscriptions200ResponseEmbedded.d.ts +33 -0
  86. package/lib/models/ListCardSubscriptions200ResponseEmbedded.js +51 -0
  87. package/lib/models/ListCardSubscriptions200ResponseLinks.d.ts +57 -0
  88. package/lib/models/ListCardSubscriptions200ResponseLinks.js +59 -0
  89. package/lib/models/ListCards200Response.d.ts +46 -0
  90. package/lib/models/ListCards200Response.js +60 -0
  91. package/lib/models/ListCards200ResponseEmbedded.d.ts +33 -0
  92. package/lib/models/ListCards200ResponseEmbedded.js +51 -0
  93. package/lib/models/ListNetworkBulkFeeds200Response.d.ts +46 -0
  94. package/lib/models/ListNetworkBulkFeeds200Response.js +60 -0
  95. package/lib/models/ListNetworkBulkFeeds200ResponseEmbedded.d.ts +33 -0
  96. package/lib/models/ListNetworkBulkFeeds200ResponseEmbedded.js +51 -0
  97. package/lib/models/ListWebhooks200Response.d.ts +40 -0
  98. package/lib/models/ListWebhooks200Response.js +56 -0
  99. package/lib/models/ListWebhooks200ResponseEmbedded.d.ts +33 -0
  100. package/lib/models/ListWebhooks200ResponseEmbedded.js +49 -0
  101. package/lib/models/ListWebhooks200ResponseLinks.d.ts +39 -0
  102. package/lib/models/ListWebhooks200ResponseLinks.js +51 -0
  103. package/lib/models/NetworkBulkFeeds.d.ts +81 -0
  104. package/lib/models/NetworkBulkFeeds.js +83 -0
  105. package/lib/models/Subaccount.d.ts +70 -0
  106. package/lib/models/Subaccount.js +76 -0
  107. package/lib/models/SubaccountConfiguration.d.ts +39 -0
  108. package/lib/models/SubaccountConfiguration.js +51 -0
  109. package/lib/models/SubaccountConfigurationVISA.d.ts +43 -0
  110. package/lib/models/SubaccountConfigurationVISA.js +61 -0
  111. package/lib/models/Transaction.d.ts +140 -0
  112. package/lib/models/Transaction.js +126 -0
  113. package/lib/models/TransactionAcceptor.d.ts +50 -0
  114. package/lib/models/TransactionAcceptor.js +62 -0
  115. package/lib/models/TransactionLinks.d.ts +51 -0
  116. package/lib/models/TransactionLinks.js +57 -0
  117. package/lib/models/TransactionMessage.d.ts +184 -0
  118. package/lib/models/TransactionMessage.js +159 -0
  119. package/lib/models/TransactionMessageAcceptor.d.ts +68 -0
  120. package/lib/models/TransactionMessageAcceptor.js +72 -0
  121. package/lib/models/UnprocessableEntity.d.ts +45 -0
  122. package/lib/models/UnprocessableEntity.js +61 -0
  123. package/lib/models/UpdateCardSubscriptionRequest.d.ts +39 -0
  124. package/lib/models/UpdateCardSubscriptionRequest.js +55 -0
  125. package/lib/models/UpdateSubaccountRequest.d.ts +39 -0
  126. package/lib/models/UpdateSubaccountRequest.js +51 -0
  127. package/lib/models/UpdateWebhookRequest.d.ts +61 -0
  128. package/lib/models/UpdateWebhookRequest.js +65 -0
  129. package/lib/models/Webhook.d.ts +92 -0
  130. package/lib/models/Webhook.js +92 -0
  131. package/lib/models/index.d.ts +51 -0
  132. package/lib/models/index.js +69 -0
  133. package/lib/runtime.d.ts +215 -0
  134. package/lib/runtime.js +394 -0
  135. package/package.json +21 -0
  136. package/src/apis/CardApi.ts +174 -0
  137. package/src/apis/CardSubscriptionApi.ts +223 -0
  138. package/src/apis/CardholderApi.ts +93 -0
  139. package/src/apis/EnrollmentMethodsApi.ts +98 -0
  140. package/src/apis/NetworkBulkFeedsApi.ts +211 -0
  141. package/src/apis/SubaccountsApi.ts +253 -0
  142. package/src/apis/TransactionMessagesApi.ts +93 -0
  143. package/src/apis/TransactionsApi.ts +169 -0
  144. package/src/apis/WebhooksApi.ts +315 -0
  145. package/src/apis/index.ts +11 -0
  146. package/src/index.ts +5 -0
  147. package/src/models/Card.ts +187 -0
  148. package/src/models/CardLinks.ts +82 -0
  149. package/src/models/CardSubscription.ts +194 -0
  150. package/src/models/CardSubscriptionLinks.ts +91 -0
  151. package/src/models/Cardholder.ts +124 -0
  152. package/src/models/CardholderCorporate.ts +73 -0
  153. package/src/models/CardholderLinks.ts +74 -0
  154. package/src/models/Conflict.ts +102 -0
  155. package/src/models/CreateNetworkBulkFeedRequest.ts +95 -0
  156. package/src/models/CreateSubaccountRequest.ts +83 -0
  157. package/src/models/CreateWebhook201Response.ts +168 -0
  158. package/src/models/CreateWebhookRequest.ts +114 -0
  159. package/src/models/EnrollmentMethods200Response.ts +77 -0
  160. package/src/models/EnrollmentMethodsRequest.ts +66 -0
  161. package/src/models/GetSubaccounts200Response.ts +90 -0
  162. package/src/models/GetSubaccounts200ResponseEmbedded.ts +74 -0
  163. package/src/models/GetSubaccounts200ResponseLinks.ts +82 -0
  164. package/src/models/GetTransactions200Response.ts +90 -0
  165. package/src/models/GetTransactions200ResponseEmbedded.ts +74 -0
  166. package/src/models/InlineObject.ts +101 -0
  167. package/src/models/InlineObject1.ts +85 -0
  168. package/src/models/InlineObject2.ts +85 -0
  169. package/src/models/InlineObject3.ts +85 -0
  170. package/src/models/InlineObject4.ts +101 -0
  171. package/src/models/InlineObject5.ts +85 -0
  172. package/src/models/InlineObjectErrorsInner.ts +75 -0
  173. package/src/models/Link.ts +122 -0
  174. package/src/models/ListCardSubscriptions200Response.ts +99 -0
  175. package/src/models/ListCardSubscriptions200ResponseEmbedded.ts +74 -0
  176. package/src/models/ListCardSubscriptions200ResponseLinks.ts +106 -0
  177. package/src/models/ListCards200Response.ts +99 -0
  178. package/src/models/ListCards200ResponseEmbedded.ts +74 -0
  179. package/src/models/ListNetworkBulkFeeds200Response.ts +99 -0
  180. package/src/models/ListNetworkBulkFeeds200ResponseEmbedded.ts +74 -0
  181. package/src/models/ListWebhooks200Response.ts +90 -0
  182. package/src/models/ListWebhooks200ResponseEmbedded.ts +73 -0
  183. package/src/models/ListWebhooks200ResponseLinks.ts +81 -0
  184. package/src/models/NetworkBulkFeeds.ts +143 -0
  185. package/src/models/Subaccount.ts +135 -0
  186. package/src/models/SubaccountConfiguration.ts +81 -0
  187. package/src/models/SubaccountConfigurationVISA.ts +80 -0
  188. package/src/models/Transaction.ts +238 -0
  189. package/src/models/TransactionAcceptor.ts +93 -0
  190. package/src/models/TransactionLinks.ts +98 -0
  191. package/src/models/TransactionMessage.ts +289 -0
  192. package/src/models/TransactionMessageAcceptor.ts +119 -0
  193. package/src/models/UnprocessableEntity.ts +85 -0
  194. package/src/models/UpdateCardSubscriptionRequest.ts +75 -0
  195. package/src/models/UpdateSubaccountRequest.ts +81 -0
  196. package/src/models/UpdateWebhookRequest.ts +103 -0
  197. package/src/models/Webhook.ts +159 -0
  198. package/src/models/index.ts +53 -0
  199. package/src/runtime.ts +524 -0
  200. package/tsconfig.json +13 -0
package/lib/runtime.js ADDED
@@ -0,0 +1,394 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * Astrada API
6
+ * Welcome to our API Reference. 👋
7
+ *
8
+ * The version of the OpenAPI document: 2024-02-28
9
+ * Contact: developer@astrada.co
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.TextApiResponse = exports.BlobApiResponse = exports.VoidApiResponse = exports.JSONApiResponse = exports.COLLECTION_FORMATS = exports.RequiredError = exports.FetchError = exports.ResponseError = exports.BaseAPI = exports.AuthenticationClient = exports.Configuration = exports.BASE_PATH = void 0;
17
+ exports.querystring = querystring;
18
+ exports.exists = exists;
19
+ exports.mapValues = mapValues;
20
+ exports.canConsumeForm = canConsumeForm;
21
+ exports.BASE_PATH = "https://api.astrada.co".replace(/\/+$/, "");
22
+ class Configuration {
23
+ constructor(configuration) {
24
+ this.configuration = configuration;
25
+ this.authClient = new AuthenticationClient({
26
+ basePath: this.basePath,
27
+ clientId: this.clientId,
28
+ clientSecret: this.clientSecret,
29
+ accountId: this.accountId,
30
+ fetchApi: this.fetchApi
31
+ });
32
+ }
33
+ set config(configuration) {
34
+ this.configuration = configuration;
35
+ }
36
+ get accessToken() {
37
+ return this.authClient.getAccessToken.bind(this.authClient);
38
+ }
39
+ get accountId() {
40
+ return this.configuration.accountId;
41
+ }
42
+ get clientId() {
43
+ return this.configuration.clientId;
44
+ }
45
+ get clientSecret() {
46
+ return this.configuration.clientSecret;
47
+ }
48
+ get basePath() {
49
+ return this.configuration.basePath != null ? this.configuration.basePath : exports.BASE_PATH;
50
+ }
51
+ get fetchApi() {
52
+ return this.configuration.fetchApi;
53
+ }
54
+ get middleware() {
55
+ return this.configuration.middleware || [];
56
+ }
57
+ get queryParamsStringify() {
58
+ return this.configuration.queryParamsStringify || querystring;
59
+ }
60
+ get headers() {
61
+ return this.configuration.headers;
62
+ }
63
+ get credentials() {
64
+ return this.configuration.credentials;
65
+ }
66
+ }
67
+ exports.Configuration = Configuration;
68
+ class AuthenticationClient {
69
+ constructor(authConfig) {
70
+ this.authConfig = authConfig;
71
+ this.cachedToken = null;
72
+ this.tokenExpiry = 0;
73
+ }
74
+ async getAccessToken(name, scopes) {
75
+ if (this.isTokenValid()) {
76
+ return 'Bearer ' + this.cachedToken.access_token;
77
+ }
78
+ const tokenResponse = await this.requestNewToken();
79
+ this.cacheToken(tokenResponse);
80
+ return 'Bearer ' + tokenResponse.access_token;
81
+ }
82
+ async requestNewToken() {
83
+ const params = new URLSearchParams({
84
+ client_id: this.authConfig.clientId,
85
+ client_secret: this.authConfig.clientSecret,
86
+ grant_type: "client_credentials",
87
+ });
88
+ const url = `${this.authConfig.basePath}/auth/realms/${this.authConfig.accountId}/protocol/openid-connect/token`;
89
+ const response = await (this.authConfig.fetchApi || fetch)(url, {
90
+ method: 'POST',
91
+ headers: {
92
+ 'Content-Type': 'application/x-www-form-urlencoded',
93
+ },
94
+ body: params
95
+ });
96
+ const data = await response.json();
97
+ if (response && (response.status >= 200 && response.status < 300)) {
98
+ return data;
99
+ }
100
+ if (data) {
101
+ const astradaError = {
102
+ error: data.error || "authentication_failed",
103
+ error_description: data.error_description ||
104
+ "Failed to authenticate with Astrada API",
105
+ status: response.status,
106
+ };
107
+ throw new ResponseError(response, `Authentication failed: ${astradaError.error_description}`);
108
+ }
109
+ throw new ResponseError(response, 'Response returned an error code');
110
+ }
111
+ cacheToken(token) {
112
+ this.cachedToken = token;
113
+ this.tokenExpiry = Date.now() + token.expires_in * 1000 - 30000; // 30s buffer
114
+ }
115
+ isTokenValid() {
116
+ return this.cachedToken !== null && Date.now() < this.tokenExpiry;
117
+ }
118
+ clearCache() {
119
+ this.cachedToken = null;
120
+ this.tokenExpiry = 0;
121
+ }
122
+ }
123
+ exports.AuthenticationClient = AuthenticationClient;
124
+ /**
125
+ * This is the base class for all generated API classes.
126
+ */
127
+ class BaseAPI {
128
+ constructor(configuration) {
129
+ this.configuration = configuration;
130
+ this.cachedToken = null;
131
+ this.tokenExpiry = 0;
132
+ this.fetchApi = async (url, init) => {
133
+ let fetchParams = { url, init };
134
+ for (const middleware of this.middleware) {
135
+ if (middleware.pre) {
136
+ fetchParams = await middleware.pre({
137
+ fetch: this.fetchApi,
138
+ ...fetchParams,
139
+ }) || fetchParams;
140
+ }
141
+ }
142
+ let response = undefined;
143
+ try {
144
+ response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
145
+ }
146
+ catch (e) {
147
+ for (const middleware of this.middleware) {
148
+ if (middleware.onError) {
149
+ response = await middleware.onError({
150
+ fetch: this.fetchApi,
151
+ url: fetchParams.url,
152
+ init: fetchParams.init,
153
+ error: e,
154
+ response: response ? response.clone() : undefined,
155
+ }) || response;
156
+ }
157
+ }
158
+ if (response === undefined) {
159
+ if (e instanceof Error) {
160
+ throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response');
161
+ }
162
+ else {
163
+ throw e;
164
+ }
165
+ }
166
+ }
167
+ for (const middleware of this.middleware) {
168
+ if (middleware.post) {
169
+ response = await middleware.post({
170
+ fetch: this.fetchApi,
171
+ url: fetchParams.url,
172
+ init: fetchParams.init,
173
+ response: response.clone(),
174
+ }) || response;
175
+ }
176
+ }
177
+ return response;
178
+ };
179
+ this.middleware = configuration.middleware;
180
+ }
181
+ withMiddleware(...middlewares) {
182
+ const next = this.clone();
183
+ next.middleware = next.middleware.concat(...middlewares);
184
+ return next;
185
+ }
186
+ withPreMiddleware(...preMiddlewares) {
187
+ const middlewares = preMiddlewares.map((pre) => ({ pre }));
188
+ return this.withMiddleware(...middlewares);
189
+ }
190
+ withPostMiddleware(...postMiddlewares) {
191
+ const middlewares = postMiddlewares.map((post) => ({ post }));
192
+ return this.withMiddleware(...middlewares);
193
+ }
194
+ /**
195
+ * Check if the given MIME is a JSON MIME.
196
+ * JSON MIME examples:
197
+ * application/json
198
+ * application/json; charset=UTF8
199
+ * APPLICATION/JSON
200
+ * application/vnd.company+json
201
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
202
+ * @return True if the given MIME is JSON, false otherwise.
203
+ */
204
+ isJsonMime(mime) {
205
+ if (!mime) {
206
+ return false;
207
+ }
208
+ return BaseAPI.jsonRegex.test(mime);
209
+ }
210
+ async request(context, initOverrides) {
211
+ const { url, init } = await this.createFetchParams(context, initOverrides);
212
+ const response = await this.fetchApi(url, init);
213
+ if (response && (response.status >= 200 && response.status < 300)) {
214
+ return response;
215
+ }
216
+ throw new ResponseError(response, 'Response returned an error code');
217
+ }
218
+ async createFetchParams(context, initOverrides) {
219
+ let url = this.configuration.basePath + context.path;
220
+ if (context.query !== undefined && Object.keys(context.query).length !== 0) {
221
+ // only add the querystring to the URL if there are query parameters.
222
+ // this is done to avoid urls ending with a "?" character which buggy webservers
223
+ // do not handle correctly sometimes.
224
+ url += '?' + this.configuration.queryParamsStringify(context.query);
225
+ }
226
+ const headers = Object.assign({}, this.configuration.headers, context.headers);
227
+ Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {});
228
+ const initOverrideFn = typeof initOverrides === "function"
229
+ ? initOverrides
230
+ : async () => initOverrides;
231
+ const initParams = {
232
+ method: context.method,
233
+ headers,
234
+ body: context.body,
235
+ credentials: this.configuration.credentials,
236
+ };
237
+ const overriddenInit = {
238
+ ...initParams,
239
+ ...(await initOverrideFn({
240
+ init: initParams,
241
+ context,
242
+ }))
243
+ };
244
+ let body;
245
+ if (isFormData(overriddenInit.body)
246
+ || (overriddenInit.body instanceof URLSearchParams)
247
+ || isBlob(overriddenInit.body)) {
248
+ body = overriddenInit.body;
249
+ }
250
+ else if (this.isJsonMime(headers['Content-Type'])) {
251
+ body = JSON.stringify(overriddenInit.body);
252
+ }
253
+ else {
254
+ body = overriddenInit.body;
255
+ }
256
+ const init = {
257
+ ...overriddenInit,
258
+ body
259
+ };
260
+ return { url, init };
261
+ }
262
+ /**
263
+ * Create a shallow clone of `this` by constructing a new instance
264
+ * and then shallow cloning data members.
265
+ */
266
+ clone() {
267
+ const constructor = this.constructor;
268
+ const next = new constructor(this.configuration);
269
+ next.middleware = this.middleware.slice();
270
+ return next;
271
+ }
272
+ }
273
+ exports.BaseAPI = BaseAPI;
274
+ BaseAPI.jsonRegex = new RegExp('^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i');
275
+ ;
276
+ function isBlob(value) {
277
+ return typeof Blob !== 'undefined' && value instanceof Blob;
278
+ }
279
+ function isFormData(value) {
280
+ return typeof FormData !== "undefined" && value instanceof FormData;
281
+ }
282
+ class ResponseError extends Error {
283
+ constructor(response, msg) {
284
+ super(msg);
285
+ this.response = response;
286
+ this.name = "ResponseError";
287
+ }
288
+ }
289
+ exports.ResponseError = ResponseError;
290
+ class FetchError extends Error {
291
+ constructor(cause, msg) {
292
+ super(msg);
293
+ this.cause = cause;
294
+ this.name = "FetchError";
295
+ }
296
+ }
297
+ exports.FetchError = FetchError;
298
+ class RequiredError extends Error {
299
+ constructor(field, msg) {
300
+ super(msg);
301
+ this.field = field;
302
+ this.name = "RequiredError";
303
+ }
304
+ }
305
+ exports.RequiredError = RequiredError;
306
+ exports.COLLECTION_FORMATS = {
307
+ csv: ",",
308
+ ssv: " ",
309
+ tsv: "\t",
310
+ pipes: "|",
311
+ };
312
+ function querystring(params, prefix = '') {
313
+ return Object.keys(params)
314
+ .map(key => querystringSingleKey(key, params[key], prefix))
315
+ .filter(part => part.length > 0)
316
+ .join('&');
317
+ }
318
+ function querystringSingleKey(key, value, keyPrefix = '') {
319
+ const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
320
+ if (value instanceof Array) {
321
+ const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue)))
322
+ .join(`&${encodeURIComponent(fullKey)}=`);
323
+ return `${encodeURIComponent(fullKey)}=${multiValue}`;
324
+ }
325
+ if (value instanceof Set) {
326
+ const valueAsArray = Array.from(value);
327
+ return querystringSingleKey(key, valueAsArray, keyPrefix);
328
+ }
329
+ if (value instanceof Date) {
330
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
331
+ }
332
+ if (value instanceof Object) {
333
+ return querystring(value, fullKey);
334
+ }
335
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
336
+ }
337
+ function exists(json, key) {
338
+ const value = json[key];
339
+ return value !== null && value !== undefined;
340
+ }
341
+ function mapValues(data, fn) {
342
+ const result = {};
343
+ for (const key of Object.keys(data)) {
344
+ result[key] = fn(data[key]);
345
+ }
346
+ return result;
347
+ }
348
+ function canConsumeForm(consumes) {
349
+ for (const consume of consumes) {
350
+ if ('multipart/form-data' === consume.contentType) {
351
+ return true;
352
+ }
353
+ }
354
+ return false;
355
+ }
356
+ class JSONApiResponse {
357
+ constructor(raw, transformer = (jsonValue) => jsonValue) {
358
+ this.raw = raw;
359
+ this.transformer = transformer;
360
+ }
361
+ async value() {
362
+ return this.transformer(await this.raw.json());
363
+ }
364
+ }
365
+ exports.JSONApiResponse = JSONApiResponse;
366
+ class VoidApiResponse {
367
+ constructor(raw) {
368
+ this.raw = raw;
369
+ }
370
+ async value() {
371
+ return undefined;
372
+ }
373
+ }
374
+ exports.VoidApiResponse = VoidApiResponse;
375
+ class BlobApiResponse {
376
+ constructor(raw) {
377
+ this.raw = raw;
378
+ }
379
+ async value() {
380
+ return await this.raw.blob();
381
+ }
382
+ ;
383
+ }
384
+ exports.BlobApiResponse = BlobApiResponse;
385
+ class TextApiResponse {
386
+ constructor(raw) {
387
+ this.raw = raw;
388
+ }
389
+ async value() {
390
+ return await this.raw.text();
391
+ }
392
+ ;
393
+ }
394
+ exports.TextApiResponse = TextApiResponse;
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@astrada.co/ts-astrada-sdk",
3
+ "version": "1.0.0",
4
+ "description": "",
5
+ "author": "FidelLimited",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/FidelLimited/ts-astrada-sdk.git"
10
+ },
11
+ "homepage": "https://github.com/FidelLimited/ts-astrada-sdk#readme",
12
+ "main": "lib/index.js",
13
+ "scripts": {
14
+ "prebuild": "rm -rf lib",
15
+ "build": "tsc"
16
+ },
17
+ "devDependencies": {
18
+ "@types/node": "^24.7.0",
19
+ "typescript": "^5.9.3"
20
+ }
21
+ }
@@ -0,0 +1,174 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Astrada API
5
+ * Welcome to our API Reference. 👋
6
+ *
7
+ * The version of the OpenAPI document: 2024-02-28
8
+ * Contact: developer@astrada.co
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+ import * as runtime from '../runtime';
17
+ import type {
18
+ Card,
19
+ InlineObject,
20
+ InlineObject1,
21
+ InlineObject2,
22
+ InlineObject3,
23
+ InlineObject4,
24
+ ListCards200Response,
25
+ } from '../models/index';
26
+ import {
27
+ CardFromJSON,
28
+ CardToJSON,
29
+ InlineObjectFromJSON,
30
+ InlineObjectToJSON,
31
+ InlineObject1FromJSON,
32
+ InlineObject1ToJSON,
33
+ InlineObject2FromJSON,
34
+ InlineObject2ToJSON,
35
+ InlineObject3FromJSON,
36
+ InlineObject3ToJSON,
37
+ InlineObject4FromJSON,
38
+ InlineObject4ToJSON,
39
+ ListCards200ResponseFromJSON,
40
+ ListCards200ResponseToJSON,
41
+ } from '../models/index';
42
+
43
+ export interface GetCardRequest {
44
+ cardId: string;
45
+ }
46
+
47
+ export interface ListCardsRequest {
48
+ country?: ListCardsCountryEnum;
49
+ expiryMonth?: number;
50
+ expiryYear?: number;
51
+ subaccountId?: string;
52
+ limit?: number;
53
+ offset?: number;
54
+ }
55
+
56
+ /**
57
+ *
58
+ */
59
+ export class CardApi extends runtime.BaseAPI {
60
+
61
+ /**
62
+ * Returns detailed information about a specific card by its identifier.
63
+ * Retrieve card
64
+ */
65
+ async getCardRaw(requestParameters: GetCardRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Card>> {
66
+ if (requestParameters['cardId'] == null) {
67
+ throw new runtime.RequiredError(
68
+ 'cardId',
69
+ 'Required parameter "cardId" was null or undefined when calling getCard().'
70
+ );
71
+ }
72
+
73
+ const queryParameters: any = {};
74
+
75
+ const headerParameters: runtime.HTTPHeaders = {};
76
+
77
+ if (this.configuration && this.configuration.accessToken) {
78
+ // oauth required
79
+ headerParameters["Authorization"] = await this.configuration.accessToken("main-auth", ["cards:read"]);
80
+ }
81
+
82
+
83
+ let urlPath = `/cards/{cardId}`;
84
+ urlPath = urlPath.replace(`{${"cardId"}}`, encodeURIComponent(String(requestParameters['cardId'])));
85
+
86
+ const response = await this.request({
87
+ path: urlPath,
88
+ method: 'GET',
89
+ headers: headerParameters,
90
+ query: queryParameters,
91
+ }, initOverrides);
92
+
93
+ return new runtime.JSONApiResponse(response, (jsonValue) => CardFromJSON(jsonValue));
94
+ }
95
+
96
+ /**
97
+ * Returns detailed information about a specific card by its identifier.
98
+ * Retrieve card
99
+ */
100
+ async getCard(requestParameters: GetCardRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Card> {
101
+ const response = await this.getCardRaw(requestParameters, initOverrides);
102
+ return await response.value();
103
+ }
104
+
105
+ /**
106
+ * Returns a list of all cards linked to the account. By default, `GET /cards` returns cards ordered by the latest updatedAt. You can combine the different filters as documented. This endpoint supports [offset-based pagination](https://docs.astrada.co/reference/pagination).
107
+ * List cards
108
+ */
109
+ async listCardsRaw(requestParameters: ListCardsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ListCards200Response>> {
110
+ const queryParameters: any = {};
111
+
112
+ if (requestParameters['country'] != null) {
113
+ queryParameters['country'] = requestParameters['country'];
114
+ }
115
+
116
+ if (requestParameters['expiryMonth'] != null) {
117
+ queryParameters['expiryMonth'] = requestParameters['expiryMonth'];
118
+ }
119
+
120
+ if (requestParameters['expiryYear'] != null) {
121
+ queryParameters['expiryYear'] = requestParameters['expiryYear'];
122
+ }
123
+
124
+ if (requestParameters['subaccountId'] != null) {
125
+ queryParameters['subaccountId'] = requestParameters['subaccountId'];
126
+ }
127
+
128
+ if (requestParameters['limit'] != null) {
129
+ queryParameters['limit'] = requestParameters['limit'];
130
+ }
131
+
132
+ if (requestParameters['offset'] != null) {
133
+ queryParameters['offset'] = requestParameters['offset'];
134
+ }
135
+
136
+ const headerParameters: runtime.HTTPHeaders = {};
137
+
138
+ if (this.configuration && this.configuration.accessToken) {
139
+ // oauth required
140
+ headerParameters["Authorization"] = await this.configuration.accessToken("main-auth", ["cards:read"]);
141
+ }
142
+
143
+
144
+ let urlPath = `/cards`;
145
+
146
+ const response = await this.request({
147
+ path: urlPath,
148
+ method: 'GET',
149
+ headers: headerParameters,
150
+ query: queryParameters,
151
+ }, initOverrides);
152
+
153
+ return new runtime.JSONApiResponse(response, (jsonValue) => ListCards200ResponseFromJSON(jsonValue));
154
+ }
155
+
156
+ /**
157
+ * Returns a list of all cards linked to the account. By default, `GET /cards` returns cards ordered by the latest updatedAt. You can combine the different filters as documented. This endpoint supports [offset-based pagination](https://docs.astrada.co/reference/pagination).
158
+ * List cards
159
+ */
160
+ async listCards(requestParameters: ListCardsRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ListCards200Response> {
161
+ const response = await this.listCardsRaw(requestParameters, initOverrides);
162
+ return await response.value();
163
+ }
164
+
165
+ }
166
+
167
+ /**
168
+ * @export
169
+ */
170
+ export const ListCardsCountryEnum = {
171
+ Usa: 'USA',
172
+ Can: 'CAN'
173
+ } as const;
174
+ export type ListCardsCountryEnum = typeof ListCardsCountryEnum[keyof typeof ListCardsCountryEnum];