rubengomex/js-spotify-api

View on GitHub
src/album/index.js

Summary

Maintainability
A
0 mins
Test Coverage
import SpotifyRequest from '../request'

/**
 * @class Album
 * @extends SpotifyRequest
 * @private
 */
export default class Album extends SpotifyRequest {
  constructor({ token }) {
    super({ token })
    this.url = '/albums'
  }

  find({ ids }) {
    return this.request({ method: 'get', url: this.url, query: { ids } }).then(
      ({ albums }) => albums
    )
  }

  findOne({ id }) {
    return this.request({ method: 'get', url: `${this.url}/${id}` })
  }

  getTracks({ id, skip, limit }) {
    return this.request({
      method: 'get',
      url: `${this.url}/${id}/tracks`,
      query: { skip, limit }
    }).then(({ items }) => items)
  }
}