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.js CHANGED
@@ -373,12 +373,18 @@ var createBusinessApi = (apiConfig) => {
373
373
  );
374
374
  },
375
375
  async getBusinessMedia(params, options) {
376
+ const queryParams = {
377
+ limit: params.limit
378
+ };
379
+ if (params.cursor) queryParams.cursor = params.cursor;
380
+ if (params.ids && params.ids.length > 0) queryParams.ids = params.ids.join(",");
381
+ if (params.query) queryParams.query = params.query;
382
+ if (params.mimeType) queryParams.mimeType = params.mimeType;
383
+ if (params.sortField) queryParams.sortField = params.sortField;
384
+ if (params.sortDirection) queryParams.sortDirection = params.sortDirection;
376
385
  return apiConfig.httpClient.get(`/v1/businesses/${params.id}/media`, {
377
386
  ...options,
378
- params: {
379
- cursor: params.cursor,
380
- limit: params.limit || 20
381
- }
387
+ params: queryParams
382
388
  });
383
389
  },
384
390
  async processRefund(params, options) {
@@ -422,12 +428,22 @@ var createMediaApi = (apiConfig) => {
422
428
  );
423
429
  },
424
430
  async getBusinessMedia(params, options) {
425
- const { cursor = null, limit = 20 } = params;
431
+ const { cursor, limit, ids, query, mimeType, sortField, sortDirection } = params;
426
432
  const url = `${apiConfig.baseUrl}/v1/businesses/${apiConfig.businessId}/media`;
427
- const queryParams = { limit };
433
+ const queryParams = { limit: String(limit) };
428
434
  if (cursor) queryParams.cursor = cursor;
435
+ if (ids && ids.length > 0) queryParams.ids = ids.join(",");
436
+ if (query) queryParams.query = query;
437
+ if (mimeType) queryParams.mimeType = mimeType;
438
+ if (sortField) queryParams.sortField = sortField;
439
+ if (sortDirection) queryParams.sortDirection = sortDirection;
429
440
  const queryString = new URLSearchParams(queryParams).toString();
430
- const response = await fetch(`${url}?${queryString}`);
441
+ const tokens = await apiConfig.getToken();
442
+ const response = await fetch(`${url}?${queryString}`, {
443
+ headers: {
444
+ Authorization: `Bearer ${tokens.accessToken}`
445
+ }
446
+ });
431
447
  if (!response.ok) {
432
448
  const errorData = await response.json().catch(() => null);
433
449
  throw new Error(errorData?.message || "Failed to fetch media");