arky-sdk 0.3.128 → 0.3.129

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -375,12 +375,18 @@ var createBusinessApi = (apiConfig) => {
375
375
  );
376
376
  },
377
377
  async getBusinessMedia(params, options) {
378
+ const queryParams = {
379
+ limit: params.limit
380
+ };
381
+ if (params.cursor) queryParams.cursor = params.cursor;
382
+ if (params.ids && params.ids.length > 0) queryParams.ids = params.ids.join(",");
383
+ if (params.query) queryParams.query = params.query;
384
+ if (params.mimeType) queryParams.mimeType = params.mimeType;
385
+ if (params.sortField) queryParams.sortField = params.sortField;
386
+ if (params.sortDirection) queryParams.sortDirection = params.sortDirection;
378
387
  return apiConfig.httpClient.get(`/v1/businesses/${params.id}/media`, {
379
388
  ...options,
380
- params: {
381
- cursor: params.cursor,
382
- limit: params.limit || 20
383
- }
389
+ params: queryParams
384
390
  });
385
391
  },
386
392
  async processRefund(params, options) {
@@ -424,12 +430,22 @@ var createMediaApi = (apiConfig) => {
424
430
  );
425
431
  },
426
432
  async getBusinessMedia(params, options) {
427
- const { cursor = null, limit = 20 } = params;
433
+ const { cursor, limit, ids, query, mimeType, sortField, sortDirection } = params;
428
434
  const url = `${apiConfig.baseUrl}/v1/businesses/${apiConfig.businessId}/media`;
429
- const queryParams = { limit };
435
+ const queryParams = { limit: String(limit) };
430
436
  if (cursor) queryParams.cursor = cursor;
437
+ if (ids && ids.length > 0) queryParams.ids = ids.join(",");
438
+ if (query) queryParams.query = query;
439
+ if (mimeType) queryParams.mimeType = mimeType;
440
+ if (sortField) queryParams.sortField = sortField;
441
+ if (sortDirection) queryParams.sortDirection = sortDirection;
431
442
  const queryString = new URLSearchParams(queryParams).toString();
432
- const response = await fetch(`${url}?${queryString}`);
443
+ const tokens = await apiConfig.getToken();
444
+ const response = await fetch(`${url}?${queryString}`, {
445
+ headers: {
446
+ Authorization: `Bearer ${tokens.accessToken}`
447
+ }
448
+ });
433
449
  if (!response.ok) {
434
450
  const errorData = await response.json().catch(() => null);
435
451
  throw new Error(errorData?.message || "Failed to fetch media");