{"size": 672, "ext": "js", "max_stars_repo_path": "src/connectors/notificationConnector.js", "max_stars_repo_name": "martabacc/worker-notification", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/connectors/notificationConnector.js", "max_issues_repo_name": "martabacc/worker-notification", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/connectors/notificationConnector.js", "max_forks_repo_name": "martabacc/worker-notification", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.1724137931, "max_line_length": 75, "alphanum_fraction": 0.6413690476}
const { StatusCodes } = require('http-status-codes');

class NotificationConnector {
  constructor(opts) {
    Object.assign(this, opts);
  }

  async markAsComplete(notificationId) {
    this.logger.debug(`Notifying success for id: ${notificationId}`);

    const response = await this.httpRequest({
      method: 'PATCH',
      url: `/notification/${notificationId}`,
      headers: {
        ...this.headers,
      },
      body: { is_delivered: true },
    });

    if (response.statusCode !== StatusCodes.OK) {
      throw new Error(`Error notifying success for id: ${notificationId}`);
    }

    return response.body;
  }
}

module.exports = NotificationConnector;
