From ce6973573e67214340fda451ee84171ea98f9a7c Mon Sep 17 00:00:00 2001 From: vlad Date: Sat, 1 Jul 2017 00:57:35 -0700 Subject: Simplifying SendGridMailService + not generate scaladoc --- .../formats/json/export/ApiExportPatientLabel.scala | 2 +- .../formats/json/export/ApiExportPatientLabelEvidence.scala | 2 +- .../json/export/ApiExportPatientLabelEvidenceDocument.scala | 3 +-- .../formats/json/export/ApiExportPatientWithLabels.scala | 2 +- .../pdsuidomain/formats/json/export/ApiExportTrial.scala | 2 +- .../pdsuidomain/formats/json/export/ApiExportTrialArm.scala | 2 +- .../formats/json/export/ApiExportTrialLabelCriterion.scala | 10 ++++++---- .../formats/json/export/ApiExportTrialWithLabels.scala | 2 +- .../pdsuidomain/services/rest/SendGridMailService.scala | 13 +++---------- 9 files changed, 16 insertions(+), 22 deletions(-) (limited to 'src/main/scala') diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabel.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabel.scala index 78a73a6..3deccbf 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabel.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabel.scala @@ -12,7 +12,7 @@ object ApiExportPatientLabel { (JsPath \ "labelId").format[String] and (JsPath \ "labelName").format[String] and (JsPath \ "evidence").format[List[ApiExportPatientLabelEvidence]] - ) (ApiExportPatientLabel.apply, unlift(ApiExportPatientLabel.unapply)) + )(ApiExportPatientLabel.apply, unlift(ApiExportPatientLabel.unapply)) def fromDomain(label: ExportPatientLabel) = ApiExportPatientLabel( id = label.id.toString, diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidence.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidence.scala index b38c2a0..9ce281e 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidence.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidence.scala @@ -17,7 +17,7 @@ object ApiExportPatientLabelEvidence { (JsPath \ "labelValue").format[String](Writes[String](x => JsString(x.toUpperCase))) and (JsPath \ "evidenceText").format[String] and (JsPath \ "document").format[ApiExportPatientLabelEvidenceDocument] - ) (ApiExportPatientLabelEvidence.apply, unlift(ApiExportPatientLabelEvidence.unapply)) + )(ApiExportPatientLabelEvidence.apply, unlift(ApiExportPatientLabelEvidence.unapply)) def fromDomain(evidence: ExportPatientLabelEvidence) = ApiExportPatientLabelEvidence( evidenceId = evidence.id.toString, diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidenceDocument.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidenceDocument.scala index d094014..99bb2cf 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidenceDocument.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientLabelEvidenceDocument.scala @@ -12,7 +12,6 @@ final case class ApiExportPatientLabelEvidenceDocument(documentId: String, providerType: String, date: LocalDate) - object ApiExportPatientLabelEvidenceDocument { implicit val format: Format[ApiExportPatientLabelEvidenceDocument] = ( @@ -21,7 +20,7 @@ object ApiExportPatientLabelEvidenceDocument { (JsPath \ "documentType").format[String] and (JsPath \ "providerType").format[String] and (JsPath \ "date").format[LocalDate] - ) (ApiExportPatientLabelEvidenceDocument.apply, unlift(ApiExportPatientLabelEvidenceDocument.unapply)) + )(ApiExportPatientLabelEvidenceDocument.apply, unlift(ApiExportPatientLabelEvidenceDocument.unapply)) def fromDomain(document: ExportPatientLabelEvidenceDocument) = ApiExportPatientLabelEvidenceDocument( diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientWithLabels.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientWithLabels.scala index d5b9eb3..8ce970b 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientWithLabels.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportPatientWithLabels.scala @@ -12,7 +12,7 @@ object ApiExportPatientWithLabels { (JsPath \ "patientId").format[String] and (JsPath \ "labelVersion").format[Long] and (JsPath \ "labels").format[List[ApiExportPatientLabel]] - ) (ApiExportPatientWithLabels.apply, unlift(ApiExportPatientWithLabels.unapply)) + )(ApiExportPatientWithLabels.apply, unlift(ApiExportPatientWithLabels.unapply)) def fromDomain(patient: ExportPatientWithLabels) = ApiExportPatientWithLabels( patientId = patient.patientId.toString, diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrial.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrial.scala index b12cb93..0c9cb71 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrial.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrial.scala @@ -15,7 +15,7 @@ object ApiExportTrial { (JsPath \ "trialId").format[String] and (JsPath \ "disease").format[String] and (JsPath \ "lastReviewed").format[Long] - ) (ApiExportTrial.apply, unlift(ApiExportTrial.unapply)) + )(ApiExportTrial.apply, unlift(ApiExportTrial.unapply)) def fromDomain(trial: ExportTrial): ApiExportTrial = ApiExportTrial( nctId = trial.nctId.id, diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialArm.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialArm.scala index 0b77832..b2b02eb 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialArm.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialArm.scala @@ -11,7 +11,7 @@ object ApiExportTrialArm { implicit val format: Format[ApiExportTrialArm] = ( (JsPath \ "armId").format[String] and (JsPath \ "armName").format[String] - ) (ApiExportTrialArm.apply, unlift(ApiExportTrialArm.unapply)) + )(ApiExportTrialArm.apply, unlift(ApiExportTrialArm.unapply)) def fromDomain(arm: ExportTrialArm) = ApiExportTrialArm( armId = arm.armId.toString, diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialLabelCriterion.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialLabelCriterion.scala index 09935c0..2564efe 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialLabelCriterion.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialLabelCriterion.scala @@ -23,12 +23,14 @@ object ApiExportTrialLabelCriterion { (JsPath \ "armIds").format[List[String]] and (JsPath \ "isCompound").format[Boolean] and (JsPath \ "isDefining").format[Boolean] - ) (ApiExportTrialLabelCriterion.apply, unlift(ApiExportTrialLabelCriterion.unapply)) + )(ApiExportTrialLabelCriterion.apply, unlift(ApiExportTrialLabelCriterion.unapply)) def fromDomain(x: ExportTrialLabelCriterion) = ApiExportTrialLabelCriterion( - value = x.value.map { x => - FuzzyValue.valueToString(FuzzyValue.fromBoolean(x)) - }.getOrElse("Unknown"), + value = x.value + .map { x => + FuzzyValue.valueToString(FuzzyValue.fromBoolean(x)) + } + .getOrElse("Unknown"), labelId = x.labelId.toString, criterionId = x.criterionId.toString, criterionText = x.criteria, diff --git a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialWithLabels.scala b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialWithLabels.scala index dd855f7..de76ac0 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialWithLabels.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/formats/json/export/ApiExportTrialWithLabels.scala @@ -24,7 +24,7 @@ object ApiExportTrialWithLabels { (JsPath \ "labelVersion").format[Long] and (JsPath \ "arms").format[List[ApiExportTrialArm]] and (JsPath \ "criteria").format[List[ApiExportTrialLabelCriterion]] - ) (ApiExportTrialWithLabels.apply, unlift(ApiExportTrialWithLabels.unapply)) + )(ApiExportTrialWithLabels.apply, unlift(ApiExportTrialWithLabels.unapply)) def fromDomain(x: ExportTrialWithLabels) = ApiExportTrialWithLabels( nctId = x.nctId.id, diff --git a/src/main/scala/xyz/driver/pdsuidomain/services/rest/SendGridMailService.scala b/src/main/scala/xyz/driver/pdsuidomain/services/rest/SendGridMailService.scala index e308fe6..bb3228e 100644 --- a/src/main/scala/xyz/driver/pdsuidomain/services/rest/SendGridMailService.scala +++ b/src/main/scala/xyz/driver/pdsuidomain/services/rest/SendGridMailService.scala @@ -4,26 +4,19 @@ import com.sendgrid._ import xyz.driver.pdsuicommon.logging._ import xyz.driver.pdsuidomain.services.MailService import xyz.driver.pdsuidomain.services.MailService.Template -import xyz.driver.pdsuidomain.services.rest.SendGridMailService._ import scala.util.control.NonFatal -object SendGridMailService { - +class SendGridMailService(apiKey: String, from: String) extends MailService with PhiLogging { private val ExpectedHttpCode = 202 - case class Settings(provider: String, frontEndUrl: String, apiKey: String, from: String) -} - -class SendGridMailService(settings: Settings) extends MailService with PhiLogging { - def sendTo(email: String, template: Template): Boolean = { val to = new Email(email) val content = new Content(template.contentType, template.content) - val mail = new Mail(new Email(settings.from), template.subject, to, content) + val mail = new Mail(new Email(from), template.subject, to, content) val request = new Request() - val sendGrid = new SendGrid(settings.apiKey) + val sendGrid = new SendGrid(apiKey) try { request.method = Method.POST -- cgit v1.2.3