@aloma.io/integration-sdk 3.8.55 → 3.8.56

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.
@@ -0,0 +1,239 @@
1
+ // ProductsResource resource functions
2
+ // These functions will be bound to the controller instance and accessible as products.method()
3
+
4
+ // Generated TypeScript interfaces from OpenAPI schemas
5
+
6
+ export interface Product {
7
+ /** Unique product identifier */
8
+ id: string;
9
+ /** Product name */
10
+ name: string;
11
+ /** Product description */
12
+ description?: string;
13
+ /** Product price */
14
+ price: number;
15
+ /** Product category */
16
+ category?: string;
17
+ /** Whether product is in stock */
18
+ inStock?: boolean;
19
+ /** Product tags */
20
+ tags?: string[];
21
+ /** Creation timestamp */
22
+ createdAt?: string;
23
+ /** Last update timestamp */
24
+ updatedAt?: string;
25
+ }
26
+
27
+ export interface ProductList {
28
+ products?: Product[];
29
+ /** Total number of products */
30
+ total?: number;
31
+ /** Whether there are more products available */
32
+ hasMore?: boolean;
33
+ }
34
+
35
+ export interface CreateProductRequest {
36
+ /** Product name */
37
+ name: string;
38
+ /** Product description */
39
+ description?: string;
40
+ /** Product price */
41
+ price: number;
42
+ /** Product category */
43
+ category?: string;
44
+ /** Product tags */
45
+ tags?: string[];
46
+ }
47
+
48
+ export interface UpdateProductRequest {
49
+ /** Product name */
50
+ name?: string;
51
+ /** Product description */
52
+ description?: string;
53
+ /** Product price */
54
+ price?: number;
55
+ /** Product category */
56
+ category?: string;
57
+ /** Whether product is in stock */
58
+ inStock?: boolean;
59
+ /** Product tags */
60
+ tags?: string[];
61
+ }
62
+
63
+
64
+ /**
65
+ * List all products
66
+ *
67
+ * @param {Object} options - Request options
68
+ * @param {number} options.limit (optional) - Maximum number of products to return [query]
69
+ * @param {string} options.category (optional) - Filter by category [query]
70
+ * @param {boolean} options.archived (optional) - Include archived products [query]
71
+ *
72
+ * @returns {Promise<ProductList>} GET /products response
73
+ *
74
+ * response fields:
75
+ * - products?: Product[]
76
+ * - total?: number - Total number of products
77
+ * - hasMore?: boolean - Whether there are more products available
78
+ */
79
+ export function getProducts(this: any, options?: {limit?: number, category?: string, archived?: boolean}) {
80
+ options = options || {};
81
+
82
+ const url = '/products';
83
+
84
+ const fetchOptions: any = {
85
+ method: 'GET',
86
+ params: {},
87
+ headers: options.headers,
88
+ };
89
+
90
+ // Add query parameters
91
+ if (options.limit !== undefined) {
92
+ fetchOptions.params.limit = options.limit;
93
+ }
94
+ if (options.category !== undefined) {
95
+ fetchOptions.params.category = options.category;
96
+ }
97
+ if (options.archived !== undefined) {
98
+ fetchOptions.params.archived = options.archived;
99
+ }
100
+
101
+ return this.api.fetch(url, fetchOptions);
102
+ }
103
+
104
+ /**
105
+ * Create a new product
106
+ *
107
+ * @param {Object} options - Request options
108
+ * @param {string} options.name (required) - Product name [body property]
109
+ * @param {string} options.description (required) - Product description [body property]
110
+ * @param {number} options.price (required) - Product price [body property]
111
+ * @param {string} options.category (required) - Product category [body property]
112
+ * @param {string[]} options.tags (required) - Product tags [body property]
113
+ *
114
+ * @returns {Promise<Product>} POST /products response
115
+ *
116
+ * response fields:
117
+ * - id: string - Unique product identifier
118
+ * - name: string - Product name
119
+ * - description?: string - Product description
120
+ * - price: number - Product price
121
+ * - category?: string - Product category
122
+ * - inStock?: boolean - Whether product is in stock
123
+ * - tags?: string[] - Product tags
124
+ * - createdAt?: string - Creation timestamp
125
+ * - updatedAt?: string - Last update timestamp
126
+ */
127
+ export function createProduct(this: any, options: {name: string /** Product name */, description: string /** Product description */, price: number /** Product price */, category: string /** Product category */, tags: string[] /** Product tags */}) {
128
+ options = options || {};
129
+
130
+ const url = '/products';
131
+
132
+ const { headers, ...bodyData } = options;
133
+ const requestBody = Object.keys(bodyData).length > 0 ? bodyData : undefined;
134
+
135
+ const fetchOptions: any = {
136
+ method: 'POST',
137
+ body: requestBody,
138
+ headers: options.headers,
139
+ };
140
+
141
+ return this.api.fetch(url, fetchOptions);
142
+ }
143
+
144
+ /**
145
+ * Get a specific product
146
+ *
147
+ * @param {string} productId The product ID
148
+ * @param {Object} options (optional) - Request options
149
+ *
150
+ * @returns {Promise<Product>} GET /products/{productId} response
151
+ *
152
+ * response fields:
153
+ * - id: string - Unique product identifier
154
+ * - name: string - Product name
155
+ * - description?: string - Product description
156
+ * - price: number - Product price
157
+ * - category?: string - Product category
158
+ * - inStock?: boolean - Whether product is in stock
159
+ * - tags?: string[] - Product tags
160
+ * - createdAt?: string - Creation timestamp
161
+ * - updatedAt?: string - Last update timestamp
162
+ */
163
+ export function getProduct(this: any, productId: string) {
164
+ let url = '/products/{productId}';
165
+ if (productId) {
166
+ url = url.replace('{productId}', productId);
167
+ }
168
+
169
+ return this.api.fetch(url, {
170
+ method: 'GET',
171
+ });
172
+ return this.api.fetch(url, fetchOptions);
173
+ }
174
+
175
+ /**
176
+ * Update a product
177
+ *
178
+ * @param {string} productId The product ID
179
+ * @param {Object} options - Request options
180
+ * @param {string} options.name (required) - Product name [body property]
181
+ * @param {string} options.description (required) - Product description [body property]
182
+ * @param {number} options.price (required) - Product price [body property]
183
+ * @param {string} options.category (required) - Product category [body property]
184
+ * @param {boolean} options.inStock (required) - Whether product is in stock [body property]
185
+ * @param {string[]} options.tags (required) - Product tags [body property]
186
+ *
187
+ * @returns {Promise<Product>} PUT /products/{productId} response
188
+ *
189
+ * response fields:
190
+ * - id: string - Unique product identifier
191
+ * - name: string - Product name
192
+ * - description?: string - Product description
193
+ * - price: number - Product price
194
+ * - category?: string - Product category
195
+ * - inStock?: boolean - Whether product is in stock
196
+ * - tags?: string[] - Product tags
197
+ * - createdAt?: string - Creation timestamp
198
+ * - updatedAt?: string - Last update timestamp
199
+ */
200
+ export function updateProduct(this: any, productId: string, options: {name: string /** Product name */, description: string /** Product description */, price: number /** Product price */, category: string /** Product category */, inStock: boolean /** Whether product is in stock */, tags: string[] /** Product tags */}) {
201
+ options = options || {};
202
+
203
+ // Build URL with path parameters
204
+ let url = '/products/{productId}';
205
+ if (productId) {
206
+ url = url.replace('{productId}', productId);
207
+ }
208
+
209
+ const { headers, ...bodyData } = options;
210
+ const requestBody = Object.keys(bodyData).length > 0 ? bodyData : undefined;
211
+
212
+ const fetchOptions: any = {
213
+ method: 'PUT',
214
+ body: requestBody,
215
+ headers: options.headers,
216
+ };
217
+
218
+ return this.api.fetch(url, fetchOptions);
219
+ }
220
+
221
+ /**
222
+ * Delete a product
223
+ *
224
+ * @param {string} productId The product ID
225
+ * @param {Object} options (optional) - Request options
226
+ *
227
+ * @returns {Promise<any>} DELETE /products/{productId} response
228
+ */
229
+ export function deleteProduct(this: any, productId: string) {
230
+ let url = '/products/{productId}';
231
+ if (productId) {
232
+ url = url.replace('{productId}', productId);
233
+ }
234
+
235
+ return this.api.fetch(url, {
236
+ method: 'DELETE',
237
+ });
238
+ return this.api.fetch(url, fetchOptions);
239
+ }
@@ -0,0 +1,362 @@
1
+ {
2
+ "openapi": "3.0.0",
3
+ "info": {
4
+ "title": "Orders API",
5
+ "version": "1.0.0",
6
+ "description": "A simple orders management API"
7
+ },
8
+ "servers": [
9
+ {
10
+ "url": "https://api.testshop.com",
11
+ "description": "Production server"
12
+ }
13
+ ],
14
+ "paths": {
15
+ "/orders": {
16
+ "get": {
17
+ "operationId": "getOrders",
18
+ "summary": "List all orders",
19
+ "parameters": [
20
+ {
21
+ "name": "status",
22
+ "in": "query",
23
+ "schema": {
24
+ "type": "string",
25
+ "enum": ["pending", "confirmed", "shipped", "delivered", "cancelled"]
26
+ },
27
+ "description": "Filter by order status"
28
+ },
29
+ {
30
+ "name": "customerId",
31
+ "in": "query",
32
+ "schema": {
33
+ "type": "string"
34
+ },
35
+ "description": "Filter by customer ID"
36
+ },
37
+ {
38
+ "name": "limit",
39
+ "in": "query",
40
+ "schema": {
41
+ "type": "integer",
42
+ "minimum": 1,
43
+ "maximum": 50
44
+ },
45
+ "description": "Maximum number of orders to return"
46
+ }
47
+ ],
48
+ "responses": {
49
+ "200": {
50
+ "description": "List of orders",
51
+ "content": {
52
+ "application/json": {
53
+ "schema": {
54
+ "$ref": "#/components/schemas/OrderList"
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
60
+ },
61
+ "post": {
62
+ "operationId": "createOrder",
63
+ "summary": "Create a new order",
64
+ "requestBody": {
65
+ "required": true,
66
+ "content": {
67
+ "application/json": {
68
+ "schema": {
69
+ "$ref": "#/components/schemas/CreateOrderRequest"
70
+ }
71
+ }
72
+ }
73
+ },
74
+ "responses": {
75
+ "201": {
76
+ "description": "Order created",
77
+ "content": {
78
+ "application/json": {
79
+ "schema": {
80
+ "$ref": "#/components/schemas/Order"
81
+ }
82
+ }
83
+ }
84
+ }
85
+ }
86
+ }
87
+ },
88
+ "/orders/{orderId}": {
89
+ "get": {
90
+ "operationId": "getOrder",
91
+ "summary": "Get a specific order",
92
+ "parameters": [
93
+ {
94
+ "name": "orderId",
95
+ "in": "path",
96
+ "required": true,
97
+ "schema": {
98
+ "type": "string"
99
+ },
100
+ "description": "The order ID"
101
+ }
102
+ ],
103
+ "responses": {
104
+ "200": {
105
+ "description": "Order details",
106
+ "content": {
107
+ "application/json": {
108
+ "schema": {
109
+ "$ref": "#/components/schemas/Order"
110
+ }
111
+ }
112
+ }
113
+ }
114
+ }
115
+ },
116
+ "patch": {
117
+ "operationId": "updateOrderStatus",
118
+ "summary": "Update order status",
119
+ "parameters": [
120
+ {
121
+ "name": "orderId",
122
+ "in": "path",
123
+ "required": true,
124
+ "schema": {
125
+ "type": "string"
126
+ },
127
+ "description": "The order ID"
128
+ }
129
+ ],
130
+ "requestBody": {
131
+ "required": true,
132
+ "content": {
133
+ "application/json": {
134
+ "schema": {
135
+ "$ref": "#/components/schemas/UpdateOrderStatusRequest"
136
+ }
137
+ }
138
+ }
139
+ },
140
+ "responses": {
141
+ "200": {
142
+ "description": "Order status updated",
143
+ "content": {
144
+ "application/json": {
145
+ "schema": {
146
+ "$ref": "#/components/schemas/Order"
147
+ }
148
+ }
149
+ }
150
+ }
151
+ }
152
+ }
153
+ },
154
+ "/orders/{orderId}/cancel": {
155
+ "post": {
156
+ "operationId": "cancelOrder",
157
+ "summary": "Cancel an order",
158
+ "parameters": [
159
+ {
160
+ "name": "orderId",
161
+ "in": "path",
162
+ "required": true,
163
+ "schema": {
164
+ "type": "string"
165
+ },
166
+ "description": "The order ID"
167
+ }
168
+ ],
169
+ "responses": {
170
+ "200": {
171
+ "description": "Order cancelled",
172
+ "content": {
173
+ "application/json": {
174
+ "schema": {
175
+ "$ref": "#/components/schemas/Order"
176
+ }
177
+ }
178
+ }
179
+ }
180
+ }
181
+ }
182
+ }
183
+ },
184
+ "components": {
185
+ "schemas": {
186
+ "Order": {
187
+ "type": "object",
188
+ "required": ["id", "customerId", "items", "status", "totalAmount"],
189
+ "properties": {
190
+ "id": {
191
+ "type": "string",
192
+ "description": "Unique order identifier"
193
+ },
194
+ "customerId": {
195
+ "type": "string",
196
+ "description": "Customer who placed the order"
197
+ },
198
+ "items": {
199
+ "type": "array",
200
+ "items": {
201
+ "$ref": "#/components/schemas/OrderItem"
202
+ },
203
+ "description": "Items in the order"
204
+ },
205
+ "status": {
206
+ "type": "string",
207
+ "enum": ["pending", "confirmed", "shipped", "delivered", "cancelled"],
208
+ "description": "Current order status"
209
+ },
210
+ "totalAmount": {
211
+ "type": "number",
212
+ "minimum": 0,
213
+ "description": "Total order amount"
214
+ },
215
+ "shippingAddress": {
216
+ "$ref": "#/components/schemas/Address"
217
+ },
218
+ "billingAddress": {
219
+ "$ref": "#/components/schemas/Address"
220
+ },
221
+ "createdAt": {
222
+ "type": "string",
223
+ "format": "date-time",
224
+ "description": "Order creation timestamp"
225
+ },
226
+ "updatedAt": {
227
+ "type": "string",
228
+ "format": "date-time",
229
+ "description": "Last update timestamp"
230
+ }
231
+ }
232
+ },
233
+ "OrderItem": {
234
+ "type": "object",
235
+ "required": ["productId", "quantity", "unitPrice"],
236
+ "properties": {
237
+ "productId": {
238
+ "type": "string",
239
+ "description": "Product identifier"
240
+ },
241
+ "productName": {
242
+ "type": "string",
243
+ "description": "Product name"
244
+ },
245
+ "quantity": {
246
+ "type": "integer",
247
+ "minimum": 1,
248
+ "description": "Quantity ordered"
249
+ },
250
+ "unitPrice": {
251
+ "type": "number",
252
+ "minimum": 0,
253
+ "description": "Price per unit"
254
+ },
255
+ "totalPrice": {
256
+ "type": "number",
257
+ "minimum": 0,
258
+ "description": "Total price for this item"
259
+ }
260
+ }
261
+ },
262
+ "Address": {
263
+ "type": "object",
264
+ "required": ["street", "city", "zipCode", "country"],
265
+ "properties": {
266
+ "street": {
267
+ "type": "string",
268
+ "description": "Street address"
269
+ },
270
+ "city": {
271
+ "type": "string",
272
+ "description": "City"
273
+ },
274
+ "state": {
275
+ "type": "string",
276
+ "description": "State or province"
277
+ },
278
+ "zipCode": {
279
+ "type": "string",
280
+ "description": "ZIP or postal code"
281
+ },
282
+ "country": {
283
+ "type": "string",
284
+ "description": "Country"
285
+ }
286
+ }
287
+ },
288
+ "OrderList": {
289
+ "type": "object",
290
+ "properties": {
291
+ "orders": {
292
+ "type": "array",
293
+ "items": {
294
+ "$ref": "#/components/schemas/Order"
295
+ }
296
+ },
297
+ "total": {
298
+ "type": "integer",
299
+ "description": "Total number of orders"
300
+ },
301
+ "hasMore": {
302
+ "type": "boolean",
303
+ "description": "Whether there are more orders available"
304
+ }
305
+ }
306
+ },
307
+ "CreateOrderRequest": {
308
+ "type": "object",
309
+ "required": ["customerId", "items"],
310
+ "properties": {
311
+ "customerId": {
312
+ "type": "string",
313
+ "description": "Customer who is placing the order"
314
+ },
315
+ "items": {
316
+ "type": "array",
317
+ "items": {
318
+ "$ref": "#/components/schemas/OrderItemRequest"
319
+ },
320
+ "description": "Items to order"
321
+ },
322
+ "shippingAddress": {
323
+ "$ref": "#/components/schemas/Address"
324
+ },
325
+ "billingAddress": {
326
+ "$ref": "#/components/schemas/Address"
327
+ }
328
+ }
329
+ },
330
+ "OrderItemRequest": {
331
+ "type": "object",
332
+ "required": ["productId", "quantity"],
333
+ "properties": {
334
+ "productId": {
335
+ "type": "string",
336
+ "description": "Product to order"
337
+ },
338
+ "quantity": {
339
+ "type": "integer",
340
+ "minimum": 1,
341
+ "description": "Quantity to order"
342
+ }
343
+ }
344
+ },
345
+ "UpdateOrderStatusRequest": {
346
+ "type": "object",
347
+ "required": ["status"],
348
+ "properties": {
349
+ "status": {
350
+ "type": "string",
351
+ "enum": ["confirmed", "shipped", "delivered"],
352
+ "description": "New order status"
353
+ },
354
+ "trackingNumber": {
355
+ "type": "string",
356
+ "description": "Tracking number (for shipped status)"
357
+ }
358
+ }
359
+ }
360
+ }
361
+ }
362
+ }