@meltwater/conversations-api-services 1.1.7 → 1.1.8

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.
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getInsights = getInsights;
7
+ exports.getMediaFromId = getMediaFromId;
7
8
  exports.getProfile = getProfile;
8
9
  exports.manageReply = manageReply;
9
10
  exports.quote = quote;
@@ -234,6 +235,26 @@ async function manageReply(token, externalId) {
234
235
  return response.body;
235
236
  }
236
237
 
238
+ /**
239
+ * Retrieves media information from Threads.
240
+ * @param {string} token - The access token for authentication.
241
+ * @param {string} externalId - The external ID of the media.
242
+ * @param {string} fields - The fields to retrieve from the media.
243
+ * @param {Object} logger - Logger instance for logging.
244
+ * @returns {Promise<Object>} The API response containing the media information.
245
+ */
246
+ async function getMediaFromId(token, externalId, fields, logger) {
247
+ const mediaId = (0, _externalIdHelpers.removePrefix)(externalId);
248
+ let response = await sendRequest(`${THREADS_URL}/${mediaId}`, {
249
+ access_token: token,
250
+ fields
251
+ }, logger);
252
+ (0, _loggerHelpers.loggerInfo)(logger, `Native Threads API getMediaFromId Response`, {
253
+ responseBody: JSON.stringify(response.body)
254
+ });
255
+ return response.body;
256
+ }
257
+
237
258
  /**
238
259
  * Constructs the query parameters for replying to a post.
239
260
  * @param {string} accessToken - The access token for authentication.
@@ -222,6 +222,26 @@ export async function manageReply(token, externalId) {
222
222
  return response.body;
223
223
  }
224
224
 
225
+ /**
226
+ * Retrieves media information from Threads.
227
+ * @param {string} token - The access token for authentication.
228
+ * @param {string} externalId - The external ID of the media.
229
+ * @param {string} fields - The fields to retrieve from the media.
230
+ * @param {Object} logger - Logger instance for logging.
231
+ * @returns {Promise<Object>} The API response containing the media information.
232
+ */
233
+ export async function getMediaFromId(token, externalId, fields, logger) {
234
+ const mediaId = removePrefix(externalId);
235
+ let response = await sendRequest(`${THREADS_URL}/${mediaId}`, {
236
+ access_token: token,
237
+ fields
238
+ }, logger);
239
+ loggerInfo(logger, `Native Threads API getMediaFromId Response`, {
240
+ responseBody: JSON.stringify(response.body)
241
+ });
242
+ return response.body;
243
+ }
244
+
225
245
  /**
226
246
  * Constructs the query parameters for replying to a post.
227
247
  * @param {string} accessToken - The access token for authentication.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meltwater/conversations-api-services",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "description": "Repository to contain all conversations api services shared across our services",
5
5
  "main": "dist/cjs/data-access/index.js",
6
6
  "module": "dist/esm/data-access/index.js",
@@ -294,6 +294,28 @@ export async function manageReply(token, externalId, hide = false, logger) {
294
294
  return response.body;
295
295
  }
296
296
 
297
+ /**
298
+ * Retrieves media information from Threads.
299
+ * @param {string} token - The access token for authentication.
300
+ * @param {string} externalId - The external ID of the media.
301
+ * @param {string} fields - The fields to retrieve from the media.
302
+ * @param {Object} logger - Logger instance for logging.
303
+ * @returns {Promise<Object>} The API response containing the media information.
304
+ */
305
+ export async function getMediaFromId(token, externalId, fields, logger) {
306
+ const mediaId = removePrefix(externalId);
307
+ let response = await sendRequest(
308
+ `${THREADS_URL}/${mediaId}`,
309
+ { access_token: token, fields },
310
+ logger
311
+ );
312
+
313
+ loggerInfo(logger, `Native Threads API getMediaFromId Response`, {
314
+ responseBody: JSON.stringify(response.body),
315
+ });
316
+ return response.body;
317
+ }
318
+
297
319
  /**
298
320
  * Constructs the query parameters for replying to a post.
299
321
  * @param {string} accessToken - The access token for authentication.