Reference Source Test

src/video/resources/playbackIds.js

  1. /*!
  2. * Mux Assets
  3. * Copyright(c) 2018 Mux Inc.
  4. */
  5. const Base = require('../../base');
  6.  
  7. /**
  8. * @private Base playback ID path for the Mux API
  9. * */
  10. const PATH = '/video/v1/playback-ids';
  11.  
  12. /**
  13. * @private
  14. * Build the base playback ID path for the Mux API
  15. * */
  16. const buildBasePath = playbackId => `${PATH}/${playbackId}`;
  17.  
  18. /**
  19. * PlaybackIds Class - Provides access to the Mux Playback ID API
  20. *
  21. * @example
  22. * const { Video } = new Mux(accessToken, secret);
  23. *
  24. * // Retrieve an Asset or Live Stream identifier associated with a Playback ID
  25. * Video.PlaybackIds.get(playbackId);
  26. */
  27. class PlaybackIds extends Base {
  28. /**
  29. * Retrieve an Asset or Live Stream identifier associated with a Playback ID
  30. * @param {string} playbackId - The ID for playback
  31. * @returns {Promise} - Returns a resolved Promise with a response from the Mux API
  32. *
  33. * @example
  34. * const { Video } = new Mux(accessToken, secret);
  35. *
  36. * // Retrieve an Asset or Live Stream identifier associated with a Playback ID
  37. * Video.PlaybackIds.get(playbackId);
  38. *
  39. * @see https://docs.mux.com/api-reference/video#operation/get-asset-or-livestream-id
  40. */
  41. get(playbackId) {
  42. if (!playbackId) {
  43. return Promise.reject(
  44. new Error(
  45. 'An playback ID is required to get an asset or live stream identifier'
  46. )
  47. );
  48. }
  49. return this.http.get(buildBasePath(playbackId));
  50. }
  51. }
  52.  
  53. module.exports = PlaybackIds;