MadKudu/node-hubspot

View on GitHub
lib/workflow.js

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
class Workflow {
  constructor(client) {
    this.client = client
  }

  get(workflowId) {
    return this.client.apiRequest({
      method: 'GET',
      path: `/automation/v3/workflows/${workflowId}`,
    })
  }

  getAll() {
    return this.client.apiRequest({
      method: 'GET',
      path: '/automation/v3/workflows',
    })
  }

  create(data) {
    return this.client.apiRequest({
      method: 'POST',
      path: '/automation/v3/workflows',
      body: data,
    })
  }

  delete(workflowId) {
    return this.client.apiRequest({
      method: 'DELETE',
      path: `/automation/v3/workflows/${workflowId}`,
    })
  }

  enroll(workflowId, email) {
    return this.client.apiRequest({
      method: 'POST',
      path: `/automation/v2/workflows/${workflowId}/enrollments/contacts/${email}`,
    })
  }

  unenroll(workflowId, email) {
    return this.client.apiRequest({
      method: 'DELETE',
      path: `/automation/v2/workflows/${workflowId}/enrollments/contacts/${email}`,
    })
  }

  current(contactId) {
    return this.client.apiRequest({
      method: 'GET',
      path: `/automation/v2/workflows/enrollments/contacts/${contactId}`,
    })
  }
}

module.exports = Workflow