override def write()

in membership-common/src/main/scala/com/gu/zuora/soap/writers/Command.scala [280:324]


    override def write(t: Contribute): Writer[Map[String, String], Elem] = {

      val now = DateTime.now
      val paymentNode = t.paymentMethod.fold[NodeSeq](NodeSeq.Empty)(h => XmlWriter.write(h).value)

      Writer(
        Map(
          "Salesforce ID" -> t.account.contactId.salesforceContactId,
          "Rate plan ID" -> t.ratePlans.head.productRatePlanId,
          "Current time" -> s"$now in sunny ${now.getZone.getID}",
          "Customer acceptance" -> t.contractAcceptance.toString,
          "Contract effective" -> t.contractEffective.toString,
        ),
        <ns1:subscribe>
          <ns1:subscribes>
            {XmlWriter.write(t.account).value}{paymentNode}
            <ns1:BillToContact xsi:type="ns2:Contact">
              <ns2:FirstName>{t.name.first}</ns2:FirstName>
              <ns2:LastName>{t.name.last}</ns2:LastName>
              <ns2:Country>{t.country}</ns2:Country>
              <ns2:WorkEmail>{t.email}</ns2:WorkEmail>
            </ns1:BillToContact>
            <ns1:PreviewOptions>
              <ns1:EnablePreviewMode>false</ns1:EnablePreviewMode>
              <ns1:NumberOfPeriods>1</ns1:NumberOfPeriods>
            </ns1:PreviewOptions>
            <ns1:SubscribeOptions>
              <ns1:GenerateInvoice>true</ns1:GenerateInvoice>
              <ns1:ProcessPayments>true</ns1:ProcessPayments>
            </ns1:SubscribeOptions>
            <ns1:SubscriptionData>
              <ns1:Subscription xsi:type="ns2:Subscription">
                <ns2:AutoRenew>true</ns2:AutoRenew>
                <ns2:ContractEffectiveDate>{t.contractEffective}</ns2:ContractEffectiveDate>
                <ns2:ContractAcceptanceDate>{t.contractAcceptance}</ns2:ContractAcceptanceDate>
                <ns2:InitialTerm>12</ns2:InitialTerm>
                <ns2:RenewalTerm>12</ns2:RenewalTerm>
                <ns2:TermStartDate>{t.contractEffective}</ns2:TermStartDate>
                <ns2:TermType>TERMED</ns2:TermType>
              </ns1:Subscription>{t.ratePlans.list.toList.map(ratePlan => XmlWriter.write(ratePlan).value)}
            </ns1:SubscriptionData>
          </ns1:subscribes>
        </ns1:subscribe>,
      )
    }