private def processRecord()

in src/main/scala/payment_failure_comms/models/brazeTrackEvents.scala [88:125]


  private def processRecord(
      zuoraAppId: String
  )(record: PaymentFailureRecordWithBrazeId): Either[Failure, CustomEventWithAttributes] =
    for {
      eventName <- eventNameMapping
        .get(record.record.PF_Comms_Status__c).toRight(
          SalesforceResponseFailure(
            s"Unexpected PF_Comms_Status__c value '${record.record.PF_Comms_Status__c}' in PF record '${record.record.Id}'"
          )
        )
      eventTime <- EventTime(record.record)
    } yield {
      import record.record.{Invoice_Created_Date__c, Recovery_Date__c, SF_Subscription__r}

      CustomEventWithAttributes(
        Seq(
          PaymentFailureTypeAttr(record.brazeId, record.record.Payment_Failure_Type__c),
          ResponseCodeAttr(record.brazeId, record.record.STG_Initial_Gateway_Response_Code__c),
          ResponseMessageAttr(record.brazeId, record.record.STG_Initial_Gateway_Response__c),
          RecoveryDateAttr(record.brazeId, Recovery_Date__c),
          SubscriptionIdAttr(record.brazeId, SF_Subscription__r.Zuora_Subscription_Name__c),
          ProductNameAttr(record.brazeId, SF_Subscription__r.Product_Name__c.getOrElse("")),
          InvoiceCreatedDateAttr(record.brazeId, Invoice_Created_Date__c),
          BillToCountryAttr(record.brazeId, record.record.Billing_Account__r.Zuora__BillToCountry__c)
        ),
        CustomEvent(
          external_id = record.brazeId,
          app_id = zuoraAppId,
          name = eventName,
          time = eventTime,
          properties = EventProperties(
            product = SF_Subscription__r.Product_Name__c.getOrElse(""),
            currency = record.record.Currency__c,
            amount = record.record.Invoice_Total_Amount__c
          )
        )
      )
    }