Source: lib/team.js

  1. /* jshint esversion: 8 */
  2. class Team {
  3. /**
  4. * A new team api object.
  5. * @param {object} self is `this` from index.js
  6. * @constructor
  7. */
  8. constructor (self) {
  9. this.parent = self.parent
  10. this._sendRequest = self._sendRequest
  11. this._doRequest = self._doRequest
  12. this._checkKey = self._checkKey
  13. }
  14. /**
  15. * returns info about a team
  16. * @param {string} id the team id to look up
  17. * @param {requestCallback} callback a function to call when data is returned
  18. */
  19. get (id, callback) {
  20. this._doRequest(`public/teams/${id}`).then((response) => {
  21. callback(response.data.data)
  22. })
  23. }
  24. /**
  25. * returns campaigns for a team
  26. * @param {string} id the team id to look up
  27. * @param {*} callback a function to call when data is returned
  28. */
  29. getCampaigns (id, callback) {
  30. this._sendRequest(`public/teams/${id}/team_campaigns`, callback)
  31. }
  32. /**
  33. * returns a info about a campaign attached to a team
  34. * @param {string} id the team id to look up
  35. * @param {string} callback a function to call when data is returned
  36. */
  37. getMembers (id, callback) {
  38. this._sendRequest(`public/teams/${id}/members`, callback)
  39. }
  40. }
  41. module.exports = Team