@slotchain/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.
- package/README.md +167 -0
- package/dist/index.cjs.js +1463 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.mts +1149 -0
- package/dist/index.d.ts +1149 -0
- package/dist/index.esm.js +1422 -0
- package/dist/index.esm.js.map +1 -0
- package/package.json +52 -0
- package/src/client.ts +161 -0
- package/src/clients/__tests__/tenant-client.spec.ts +236 -0
- package/src/clients/booking-client.ts +98 -0
- package/src/clients/customer-client.ts +165 -0
- package/src/clients/data-quality-client.ts +93 -0
- package/src/clients/flow-client.ts +107 -0
- package/src/clients/notification-client.ts +108 -0
- package/src/clients/register-client.ts +19 -0
- package/src/clients/service-client.ts +215 -0
- package/src/clients/service-item-client.ts +103 -0
- package/src/clients/slot-client.ts +140 -0
- package/src/clients/studio-client.ts +128 -0
- package/src/clients/tenant-client.ts +148 -0
- package/src/errors.ts +41 -0
- package/src/index.ts +296 -0
- package/src/interceptors.ts +81 -0
- package/src/middleware/validateSlotlyRequest.ts +337 -0
- package/src/mocks/mockAdapter.ts +32 -0
- package/src/retry.ts +82 -0
- package/src/types/api.ts +192 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { ApiResponse, Service, ServiceWithItems, Category } from '../types/api';
|
|
3
|
+
|
|
4
|
+
export class ServiceClient {
|
|
5
|
+
constructor(private client: AxiosInstance) {}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Get service by ID
|
|
9
|
+
* GET /api/v1/services/:id
|
|
10
|
+
*
|
|
11
|
+
* @param id - Service ID
|
|
12
|
+
* @param includeItems - Include nested service items (default: false)
|
|
13
|
+
* @returns Service details (with items if includeItems=true)
|
|
14
|
+
*/
|
|
15
|
+
async getById(id: string, includeItems: boolean = false): Promise<ApiResponse<Service | ServiceWithItems>> {
|
|
16
|
+
const response = await this.client.get<ApiResponse<Service | ServiceWithItems>>(
|
|
17
|
+
`/api/v1/services/${id}`,
|
|
18
|
+
includeItems ? { params: { includeItems: true } } : undefined
|
|
19
|
+
);
|
|
20
|
+
return response.data;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* List services by tenant slug
|
|
25
|
+
* GET /api/v1/services?tenantSlug=:slug
|
|
26
|
+
*
|
|
27
|
+
* @param slug - Tenant slug (or use tenant_id in list() method)
|
|
28
|
+
* @param params - Optional parameters (includeItems, page, limit, is_active)
|
|
29
|
+
* @returns List of services for the tenant
|
|
30
|
+
*/
|
|
31
|
+
async listServices(
|
|
32
|
+
slug: string,
|
|
33
|
+
params?: {
|
|
34
|
+
includeItems?: boolean;
|
|
35
|
+
page?: number;
|
|
36
|
+
limit?: number;
|
|
37
|
+
is_active?: boolean;
|
|
38
|
+
}
|
|
39
|
+
): Promise<ApiResponse<Service[] | ServiceWithItems[]>> {
|
|
40
|
+
const response = await this.client.get<ApiResponse<Service[] | ServiceWithItems[]>>(
|
|
41
|
+
'/api/v1/services',
|
|
42
|
+
{ params: { tenantSlug: slug, ...params } }
|
|
43
|
+
);
|
|
44
|
+
return response.data;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* List services with optional filters
|
|
49
|
+
* GET /api/v1/services
|
|
50
|
+
*
|
|
51
|
+
* @param params - Query parameters (tenant_id, tenantSlug, slot_id, page, limit, is_active, includeItems)
|
|
52
|
+
* @returns Paginated list of services
|
|
53
|
+
*/
|
|
54
|
+
async list(params?: {
|
|
55
|
+
tenant_id?: string;
|
|
56
|
+
tenantSlug?: string;
|
|
57
|
+
slot_id?: string;
|
|
58
|
+
page?: number;
|
|
59
|
+
limit?: number;
|
|
60
|
+
is_active?: boolean;
|
|
61
|
+
includeItems?: boolean;
|
|
62
|
+
}): Promise<ApiResponse<Service[] | ServiceWithItems[]>> {
|
|
63
|
+
const response = await this.client.get<ApiResponse<Service[] | ServiceWithItems[]>>(
|
|
64
|
+
'/api/v1/services',
|
|
65
|
+
{ params }
|
|
66
|
+
);
|
|
67
|
+
return response.data;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Create a new service
|
|
72
|
+
* POST /api/v1/services
|
|
73
|
+
*
|
|
74
|
+
* @param data - Service creation data (tenant_id, name required)
|
|
75
|
+
* @returns Created service
|
|
76
|
+
*/
|
|
77
|
+
async create(data: Partial<Service>): Promise<ApiResponse<Service>> {
|
|
78
|
+
const response = await this.client.post<ApiResponse<Service>>(
|
|
79
|
+
'/api/v1/services',
|
|
80
|
+
data
|
|
81
|
+
);
|
|
82
|
+
return response.data;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Update service by ID
|
|
87
|
+
* PUT /api/v1/services/:id
|
|
88
|
+
*
|
|
89
|
+
* @param id - Service ID
|
|
90
|
+
* @param data - Service update data
|
|
91
|
+
* @returns Updated service
|
|
92
|
+
*/
|
|
93
|
+
async update(id: string, data: Partial<Service>): Promise<ApiResponse<Service>> {
|
|
94
|
+
const response = await this.client.put<ApiResponse<Service>>(
|
|
95
|
+
`/api/v1/services/${id}`,
|
|
96
|
+
data
|
|
97
|
+
);
|
|
98
|
+
return response.data;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Delete service by ID
|
|
103
|
+
* DELETE /api/v1/services/:id
|
|
104
|
+
*
|
|
105
|
+
* @param id - Service ID
|
|
106
|
+
* @returns Empty response on success
|
|
107
|
+
*/
|
|
108
|
+
async delete(id: string): Promise<ApiResponse<void>> {
|
|
109
|
+
const response = await this.client.delete<ApiResponse<void>>(
|
|
110
|
+
`/api/v1/services/${id}`
|
|
111
|
+
);
|
|
112
|
+
return response.data;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Bulk create services
|
|
117
|
+
* POST /api/v1/services/bulk (if available)
|
|
118
|
+
*
|
|
119
|
+
* @param services - Array of services to create
|
|
120
|
+
* @returns Created services
|
|
121
|
+
*/
|
|
122
|
+
async bulkCreate(services: Partial<Service>[]): Promise<ApiResponse<Service[]>> {
|
|
123
|
+
// Note: Verify if bulk endpoint exists in API
|
|
124
|
+
const response = await this.client.post<ApiResponse<Service[]>>(
|
|
125
|
+
'/api/v1/services/bulk',
|
|
126
|
+
{ services }
|
|
127
|
+
);
|
|
128
|
+
return response.data;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Get service with its service items nested
|
|
133
|
+
* GET /api/v1/services/:id?includeItems=true
|
|
134
|
+
*
|
|
135
|
+
* @param id - Service ID
|
|
136
|
+
* @returns Service with nested service items
|
|
137
|
+
*/
|
|
138
|
+
async getWithItems(id: string): Promise<ApiResponse<ServiceWithItems>> {
|
|
139
|
+
const response = await this.client.get<ApiResponse<ServiceWithItems>>(
|
|
140
|
+
`/api/v1/services/${id}`,
|
|
141
|
+
{ params: { includeItems: true } }
|
|
142
|
+
);
|
|
143
|
+
return response.data;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* List services with their service items nested
|
|
148
|
+
* GET /api/v1/services?includeItems=true
|
|
149
|
+
*
|
|
150
|
+
* @param params - Query parameters (tenant_id, tenantSlug, slot_id, page, limit, is_active)
|
|
151
|
+
* @returns Paginated list of services with nested service items
|
|
152
|
+
*/
|
|
153
|
+
async listWithItems(params?: {
|
|
154
|
+
tenant_id?: string;
|
|
155
|
+
tenantSlug?: string;
|
|
156
|
+
slot_id?: string;
|
|
157
|
+
page?: number;
|
|
158
|
+
limit?: number;
|
|
159
|
+
is_active?: boolean;
|
|
160
|
+
}): Promise<ApiResponse<ServiceWithItems[]>> {
|
|
161
|
+
const response = await this.client.get<ApiResponse<ServiceWithItems[]>>(
|
|
162
|
+
'/api/v1/services',
|
|
163
|
+
{ params: { includeItems: true, ...params } }
|
|
164
|
+
);
|
|
165
|
+
return response.data;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* List all categories for a tenant (extracted from services)
|
|
170
|
+
* GET /api/v1/categories?tenantSlug=:slug
|
|
171
|
+
*
|
|
172
|
+
* @param tenantSlug - Tenant slug (or use tenant_id in params)
|
|
173
|
+
* @param params - Optional query parameters (tenant_id, includeServices)
|
|
174
|
+
* @returns List of categories for the tenant
|
|
175
|
+
*/
|
|
176
|
+
async listCategories(
|
|
177
|
+
tenantSlug?: string,
|
|
178
|
+
params?: {
|
|
179
|
+
tenant_id?: string;
|
|
180
|
+
includeServices?: boolean;
|
|
181
|
+
}
|
|
182
|
+
): Promise<ApiResponse<Category[]>> {
|
|
183
|
+
const response = await this.client.get<ApiResponse<Category[]>>(
|
|
184
|
+
'/api/v1/categories',
|
|
185
|
+
{ params: { tenantSlug, ...params } }
|
|
186
|
+
);
|
|
187
|
+
return response.data;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Get category by ID (category name, lowercase)
|
|
192
|
+
* GET /api/v1/categories/:id?tenantSlug=:slug
|
|
193
|
+
*
|
|
194
|
+
* @param categoryId - Category ID (lowercase category name, e.g., "consulting")
|
|
195
|
+
* @param tenantSlug - Tenant slug (or use tenant_id in params)
|
|
196
|
+
* @param params - Optional query parameters (tenant_id, includeServices, includeItems)
|
|
197
|
+
* @returns Category details
|
|
198
|
+
*/
|
|
199
|
+
async getCategory(
|
|
200
|
+
categoryId: string,
|
|
201
|
+
tenantSlug?: string,
|
|
202
|
+
params?: {
|
|
203
|
+
tenant_id?: string;
|
|
204
|
+
includeServices?: boolean;
|
|
205
|
+
includeItems?: boolean;
|
|
206
|
+
}
|
|
207
|
+
): Promise<ApiResponse<Category>> {
|
|
208
|
+
const response = await this.client.get<ApiResponse<Category>>(
|
|
209
|
+
`/api/v1/categories/${categoryId}`,
|
|
210
|
+
{ params: { tenantSlug, ...params } }
|
|
211
|
+
);
|
|
212
|
+
return response.data;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { ApiResponse, ServiceItem, ServiceItemWithService } from '../types/api';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ServiceItemClient provides methods for managing service items independently
|
|
6
|
+
* or in relation to their parent services.
|
|
7
|
+
*/
|
|
8
|
+
export class ServiceItemClient {
|
|
9
|
+
constructor(private client: AxiosInstance) {}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Get service item by ID
|
|
13
|
+
* GET /api/v1/service-items/:id
|
|
14
|
+
*
|
|
15
|
+
* @param id - Service item ID
|
|
16
|
+
* @returns Service item details
|
|
17
|
+
*/
|
|
18
|
+
async getById(id: string): Promise<ApiResponse<ServiceItem>> {
|
|
19
|
+
const response = await this.client.get<ApiResponse<ServiceItem>>(
|
|
20
|
+
`/api/v1/service-items/${id}`
|
|
21
|
+
);
|
|
22
|
+
return response.data;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* List all service items for a service
|
|
27
|
+
* GET /api/v1/services/:serviceId/items
|
|
28
|
+
*
|
|
29
|
+
* @param serviceId - Service ID
|
|
30
|
+
* @returns List of service items for the specified service
|
|
31
|
+
*/
|
|
32
|
+
async listByService(serviceId: string): Promise<ApiResponse<ServiceItem[]>> {
|
|
33
|
+
const response = await this.client.get<ApiResponse<ServiceItem[]>>(
|
|
34
|
+
`/api/v1/services/${serviceId}/items`
|
|
35
|
+
);
|
|
36
|
+
return response.data;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Create a new service item for a service
|
|
41
|
+
* POST /api/v1/services/:serviceId/items
|
|
42
|
+
*
|
|
43
|
+
* @param serviceId - Service ID
|
|
44
|
+
* @param data - Service item creation data
|
|
45
|
+
* @returns Created service item
|
|
46
|
+
*/
|
|
47
|
+
async createForService(
|
|
48
|
+
serviceId: string,
|
|
49
|
+
data: Partial<ServiceItem>
|
|
50
|
+
): Promise<ApiResponse<ServiceItem>> {
|
|
51
|
+
const response = await this.client.post<ApiResponse<ServiceItem>>(
|
|
52
|
+
`/api/v1/services/${serviceId}/items`,
|
|
53
|
+
{ ...data, service_id: serviceId }
|
|
54
|
+
);
|
|
55
|
+
return response.data;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Create a new service item
|
|
60
|
+
* POST /api/v1/service-items (alternative to createForService)
|
|
61
|
+
*
|
|
62
|
+
* @param data - Service item creation data (must include service_id)
|
|
63
|
+
* @returns Created service item
|
|
64
|
+
*/
|
|
65
|
+
async create(data: Partial<ServiceItem>): Promise<ApiResponse<ServiceItem>> {
|
|
66
|
+
const response = await this.client.post<ApiResponse<ServiceItem>>(
|
|
67
|
+
'/api/v1/service-items',
|
|
68
|
+
data
|
|
69
|
+
);
|
|
70
|
+
return response.data;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Update service item by ID
|
|
75
|
+
* PUT /api/v1/service-items/:id
|
|
76
|
+
*
|
|
77
|
+
* @param id - Service item ID
|
|
78
|
+
* @param data - Service item update data
|
|
79
|
+
* @returns Updated service item
|
|
80
|
+
*/
|
|
81
|
+
async update(id: string, data: Partial<ServiceItem>): Promise<ApiResponse<ServiceItem>> {
|
|
82
|
+
const response = await this.client.put<ApiResponse<ServiceItem>>(
|
|
83
|
+
`/api/v1/service-items/${id}`,
|
|
84
|
+
data
|
|
85
|
+
);
|
|
86
|
+
return response.data;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Delete service item by ID
|
|
91
|
+
* DELETE /api/v1/service-items/:id
|
|
92
|
+
*
|
|
93
|
+
* @param id - Service item ID
|
|
94
|
+
* @returns Empty response on success
|
|
95
|
+
*/
|
|
96
|
+
async delete(id: string): Promise<ApiResponse<void>> {
|
|
97
|
+
const response = await this.client.delete<ApiResponse<void>>(
|
|
98
|
+
`/api/v1/service-items/${id}`
|
|
99
|
+
);
|
|
100
|
+
return response.data;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { ApiResponse, Slot, ServiceWithItems, Tenant } from '../types/api';
|
|
3
|
+
|
|
4
|
+
export class SlotClient {
|
|
5
|
+
constructor(private client: AxiosInstance) {}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Get slot by ID
|
|
9
|
+
* GET /api/v1/slots/:id
|
|
10
|
+
*
|
|
11
|
+
* @param id - Slot ID
|
|
12
|
+
* @returns Slot details
|
|
13
|
+
*/
|
|
14
|
+
async getById(id: string): Promise<ApiResponse<Slot>> {
|
|
15
|
+
// TODO: Replace with actual endpoint when available
|
|
16
|
+
const response = await this.client.get<ApiResponse<Slot>>(
|
|
17
|
+
`/api/v1/slots/${id}`
|
|
18
|
+
);
|
|
19
|
+
return response.data;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* List available slots
|
|
24
|
+
* GET /api/v1/slots
|
|
25
|
+
*
|
|
26
|
+
* @param params - Query parameters (tenant_id required, status, is_active, page, limit)
|
|
27
|
+
* @returns Paginated list of slots
|
|
28
|
+
*/
|
|
29
|
+
async list(params: {
|
|
30
|
+
tenant_id: string;
|
|
31
|
+
status?: string;
|
|
32
|
+
is_active?: boolean;
|
|
33
|
+
page?: number;
|
|
34
|
+
limit?: number;
|
|
35
|
+
}): Promise<ApiResponse<Slot[]>> {
|
|
36
|
+
const response = await this.client.get<ApiResponse<Slot[]>>(
|
|
37
|
+
'/api/v1/slots',
|
|
38
|
+
{ params }
|
|
39
|
+
);
|
|
40
|
+
return response.data;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Create a new slot
|
|
45
|
+
* POST /api/v1/slots
|
|
46
|
+
*
|
|
47
|
+
* @param data - Slot creation data (tenant_id, name required)
|
|
48
|
+
* @returns Created slot
|
|
49
|
+
*/
|
|
50
|
+
async create(data: Partial<Slot>): Promise<ApiResponse<Slot>> {
|
|
51
|
+
const response = await this.client.post<ApiResponse<Slot>>(
|
|
52
|
+
'/api/v1/slots',
|
|
53
|
+
data
|
|
54
|
+
);
|
|
55
|
+
return response.data;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Update slot by ID
|
|
60
|
+
* PUT /api/v1/slots/:id
|
|
61
|
+
*
|
|
62
|
+
* @param id - Slot ID
|
|
63
|
+
* @param data - Slot update data
|
|
64
|
+
* @returns Updated slot
|
|
65
|
+
*/
|
|
66
|
+
async update(id: string, data: Partial<Slot>): Promise<ApiResponse<Slot>> {
|
|
67
|
+
const response = await this.client.put<ApiResponse<Slot>>(
|
|
68
|
+
`/api/v1/slots/${id}`,
|
|
69
|
+
data
|
|
70
|
+
);
|
|
71
|
+
return response.data;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Delete slot by ID
|
|
76
|
+
* DELETE /api/v1/slots/:id
|
|
77
|
+
*
|
|
78
|
+
* @param id - Slot ID
|
|
79
|
+
* @returns Empty response on success
|
|
80
|
+
*/
|
|
81
|
+
async delete(id: string): Promise<ApiResponse<void>> {
|
|
82
|
+
const response = await this.client.delete<ApiResponse<void>>(
|
|
83
|
+
`/api/v1/slots/${id}`
|
|
84
|
+
);
|
|
85
|
+
return response.data;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Bulk create slots
|
|
90
|
+
* POST /api/v1/slots/bulk (verify if available)
|
|
91
|
+
*
|
|
92
|
+
* @param slots - Array of slots to create
|
|
93
|
+
* @returns Created slots
|
|
94
|
+
*/
|
|
95
|
+
async bulkCreate(slots: Partial<Slot>[]): Promise<ApiResponse<Slot[]>> {
|
|
96
|
+
// Note: Verify if bulk endpoint exists in API
|
|
97
|
+
const response = await this.client.post<ApiResponse<Slot[]>>(
|
|
98
|
+
'/api/v1/slots/bulk',
|
|
99
|
+
{ slots }
|
|
100
|
+
);
|
|
101
|
+
return response.data;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Mark slot as available/unavailable
|
|
106
|
+
* Note: Use update() method with status or other fields
|
|
107
|
+
*/
|
|
108
|
+
async setAvailability(id: string, available: boolean): Promise<ApiResponse<Slot>> {
|
|
109
|
+
return this.update(id, { status: available ? 'active' : 'inactive' } as Partial<Slot>);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Get all active services for a slot with their items
|
|
114
|
+
* GET /api/v1/slots/:id/services
|
|
115
|
+
*
|
|
116
|
+
* @param id - Slot ID
|
|
117
|
+
* @returns Services with nested service items
|
|
118
|
+
*/
|
|
119
|
+
async getServices(id: string): Promise<ApiResponse<ServiceWithItems[]>> {
|
|
120
|
+
const response = await this.client.get<ApiResponse<ServiceWithItems[]>>(
|
|
121
|
+
`/api/v1/slots/${id}/services`
|
|
122
|
+
);
|
|
123
|
+
return response.data;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Get slot with tenant information
|
|
128
|
+
* GET /api/v1/slots/:id/tenant-info
|
|
129
|
+
*
|
|
130
|
+
* @param id - Slot ID
|
|
131
|
+
* @returns Slot with tenant data
|
|
132
|
+
*/
|
|
133
|
+
async getWithTenant(id: string): Promise<ApiResponse<Slot & { tenant: Tenant }>> {
|
|
134
|
+
const response = await this.client.get<ApiResponse<Slot & { tenant: Tenant }>>(
|
|
135
|
+
`/api/v1/slots/${id}/tenant-info`
|
|
136
|
+
);
|
|
137
|
+
return response.data;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { ApiResponse, Studio } from '../types/api';
|
|
3
|
+
|
|
4
|
+
export class StudioClient {
|
|
5
|
+
constructor(private client: AxiosInstance) {}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Get studio by ID
|
|
9
|
+
* GET /api/v1/studios/:id
|
|
10
|
+
*
|
|
11
|
+
* @param id - Studio ID
|
|
12
|
+
* @returns Studio details
|
|
13
|
+
*/
|
|
14
|
+
async getById(id: string): Promise<ApiResponse<Studio>> {
|
|
15
|
+
// TODO: Replace with actual endpoint when available
|
|
16
|
+
const response = await this.client.get<ApiResponse<Studio>>(
|
|
17
|
+
`/api/v1/studios/${id}`
|
|
18
|
+
);
|
|
19
|
+
return response.data;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Get studio by slug
|
|
24
|
+
* GET /api/v1/studios/slug/:slug
|
|
25
|
+
*
|
|
26
|
+
* @param slug - Studio slug
|
|
27
|
+
* @returns Studio details
|
|
28
|
+
*/
|
|
29
|
+
async getBySlug(slug: string): Promise<ApiResponse<Studio>> {
|
|
30
|
+
// TODO: Replace with actual endpoint when available
|
|
31
|
+
const response = await this.client.get<ApiResponse<Studio>>(
|
|
32
|
+
`/api/v1/studios/slug/${slug}`
|
|
33
|
+
);
|
|
34
|
+
return response.data;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* List studios with optional filters
|
|
39
|
+
* GET /api/v1/studios
|
|
40
|
+
*
|
|
41
|
+
* @param params - Query parameters (page, limit, search)
|
|
42
|
+
* @returns Paginated list of studios
|
|
43
|
+
*/
|
|
44
|
+
async list(params?: {
|
|
45
|
+
page?: number;
|
|
46
|
+
limit?: number;
|
|
47
|
+
search?: string;
|
|
48
|
+
}): Promise<ApiResponse<Studio[]>> {
|
|
49
|
+
// TODO: Replace with actual endpoint when available
|
|
50
|
+
const response = await this.client.get<ApiResponse<Studio[]>>(
|
|
51
|
+
'/api/v1/studios',
|
|
52
|
+
{ params }
|
|
53
|
+
);
|
|
54
|
+
return response.data;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Create a new studio
|
|
59
|
+
* POST /api/v1/studios
|
|
60
|
+
*
|
|
61
|
+
* @param data - Studio creation data
|
|
62
|
+
* @returns Created studio
|
|
63
|
+
*/
|
|
64
|
+
async create(data: Partial<Studio>): Promise<ApiResponse<Studio>> {
|
|
65
|
+
// TODO: Replace with actual endpoint when available
|
|
66
|
+
const response = await this.client.post<ApiResponse<Studio>>(
|
|
67
|
+
'/api/v1/studios',
|
|
68
|
+
data
|
|
69
|
+
);
|
|
70
|
+
return response.data;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Update studio by ID
|
|
75
|
+
* PATCH /api/v1/studios/:id
|
|
76
|
+
*
|
|
77
|
+
* @param id - Studio ID
|
|
78
|
+
* @param data - Studio update data
|
|
79
|
+
* @returns Updated studio
|
|
80
|
+
*/
|
|
81
|
+
async update(id: string, data: Partial<Studio>): Promise<ApiResponse<Studio>> {
|
|
82
|
+
// TODO: Replace with actual endpoint when available
|
|
83
|
+
const response = await this.client.patch<ApiResponse<Studio>>(
|
|
84
|
+
`/api/v1/studios/${id}`,
|
|
85
|
+
data
|
|
86
|
+
);
|
|
87
|
+
return response.data;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Delete studio by ID
|
|
92
|
+
* DELETE /api/v1/studios/:id
|
|
93
|
+
*
|
|
94
|
+
* @param id - Studio ID
|
|
95
|
+
* @returns Empty response on success
|
|
96
|
+
*/
|
|
97
|
+
async delete(id: string): Promise<ApiResponse<void>> {
|
|
98
|
+
// TODO: Replace with actual endpoint when available
|
|
99
|
+
const response = await this.client.delete<ApiResponse<void>>(
|
|
100
|
+
`/api/v1/studios/${id}`
|
|
101
|
+
);
|
|
102
|
+
return response.data;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Get data quality issues for a studio
|
|
107
|
+
* GET /api/v1/studios/:id/data-quality
|
|
108
|
+
*
|
|
109
|
+
* @param id - Studio ID
|
|
110
|
+
* @param params - Query parameters (resolved, severity)
|
|
111
|
+
* @returns List of data quality issues
|
|
112
|
+
*/
|
|
113
|
+
async getDataQualityIssues(
|
|
114
|
+
id: string,
|
|
115
|
+
params?: {
|
|
116
|
+
resolved?: boolean;
|
|
117
|
+
severity?: 'low' | 'medium' | 'high';
|
|
118
|
+
}
|
|
119
|
+
): Promise<ApiResponse<any[]>> {
|
|
120
|
+
// TODO: Replace with actual endpoint when available
|
|
121
|
+
const response = await this.client.get<ApiResponse<any[]>>(
|
|
122
|
+
`/api/v1/studios/${id}/data-quality`,
|
|
123
|
+
{ params }
|
|
124
|
+
);
|
|
125
|
+
return response.data;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|