<commit_before>import errorHandler from '../helpers/errorHandler'

class Blog {

  constructor(api = null) {

    if (api === null) throw new Error('Request instance must be provided on constructor.')

    this.api = api
  }

  getAllBlogs(params) {

    return this.api.get('content/api/v2/blogs', { ...params })
      .then(response => response)
      .catch(error => errorHandler(error))
  }

  getPosts(params) {

    return this.api.get('content/api/v2/blog-posts', { ...params })
      .then(response => response)
      .catch(error => errorHandler(error))
  }

  getPostBySlug(slug) {

    return this.api.get('content/api/v2/blog-posts', { slug })
      .then(response => response)
      .catch(error => errorHandler(error))
  }

  getPostById(postId) {

    return this.api.get(`content/api/v2/blog-posts/${postId}`)
      .then(response => response)
      .catch(error => errorHandler(error))
  }

  getAllTopics(params) {

    return this.api.get('content/api/v2/blog-posts', { ...params })
      .then(response => response)
      .catch(error => errorHandler(error))
  }
}

module.exports = Blog<commit_msg>Closes #2 - Listing all blogs from a portal<commit_after>import errorHandler from '../helpers/errorHandler'

class Blog {

  constructor(api = null) {

    if (api === null) throw new Error('Request instance must be provided on constructor.')

    this.api = api
  }

  getAllBlogs(params) {

    return this.api.get('content/api/v2/blogs', { ...params })
      .then(response => response)
      .catch(error => errorHandler(error))
  }

  getPosts(params) {

    return this.api.get('content/api/v2/blog-posts', { ...params })
      .then(response => response)
      .catch(error => errorHandler(error))
  }

  getPostById(postId) {

    return this.api.get(`content/api/v2/blog-posts/${postId}`)
      .then(response => response)
      .catch(error => errorHandler(error))
  }
}

module.exports = Blog
{'fraction_non_alphanumeric': 0.1607700312174818, 'fraction_numerical': 0.004682622268470343, 'mean_word_length': 2.997920997920998, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7281676', 'n_tokens_mistral': 639, 'n_tokens_neox': 616, 'n_words': 116}