senter-optout-service
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -1,11 +0,9 @@ | ||
class OptoutService | ||
{ | ||
constructor(optoutRepository) | ||
{ | ||
class OptoutService { | ||
constructor(optoutRepository) { | ||
this.optoutRepository = optoutRepository | ||
} | ||
async getOptouts(userId) { | ||
console.log(`Getting optout numbers for user '${userId}'`) | ||
let optoutRecord = await this.optoutRepository.getById(userId, userId) | ||
async getOptouts(organisationId) { | ||
console.log(`Getting optout numbers for organisation '${organisationId}'`) | ||
let optoutRecord = await this.optoutRepository.getById(organisationId, organisationId) | ||
if (optoutRecord && optoutRecord.numbers && optoutRecord.numbers.length > 0) { | ||
@@ -17,10 +15,10 @@ return optoutRecord.numbers.map(x => x.number) | ||
async getOptoutRecord(userId) { | ||
console.log(`Getting optout record for user '${userId}'`) | ||
return await this.optoutRepository.getById(userId, userId) | ||
async getOptoutRecord(organisationId) { | ||
console.log(`Getting optout record for organisation '${organisationId}'`) | ||
return await this.optoutRepository.getById(organisationId, organisationId) | ||
} | ||
async optoutNumber(userId, number, details) { | ||
console.log(`Optout number '${number.code}${number.number}' from user '${userId}'`) | ||
let optoutRecord = await this.optoutRepository.getById(userId, userId) | ||
async optoutNumber(organisationId, number, details) { | ||
console.log(`Optout number '${number.code}${number.number}' from organisation '${organisationId}'`) | ||
let optoutRecord = await this.optoutRepository.getById(organisationId, organisationId) | ||
const optoutNumber = { | ||
@@ -30,12 +28,12 @@ number: number, | ||
} | ||
console.log('optoutRecord', optoutRecord) | ||
if (optoutRecord == null) { | ||
optoutRecord = { | ||
id: userId, | ||
id: organisationId, | ||
numbers: [optoutNumber] | ||
} | ||
console.log(`Creating new optout record`, optoutRecord) | ||
optoutRecord.id = userId | ||
await this.optoutRepository.create(userId, optoutRecord) | ||
optoutRecord.id = organisationId | ||
await this.optoutRepository.create(organisationId, optoutRecord) | ||
return optoutRecord | ||
@@ -50,4 +48,4 @@ } | ||
} | ||
await this.optoutRepository.update(userId, userId, optoutRecord) | ||
await this.optoutRepository.update(organisationId, organisationId, optoutRecord) | ||
console.log(`Added number '${number.code}${number.number}' into existing optout record`, optoutRecord) | ||
@@ -54,0 +52,0 @@ return optoutRecord |
{ | ||
"name": "senter-optout-service", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Contain methods to work with otpouts", | ||
@@ -5,0 +5,0 @@ "main": "optoutService.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2425
45