private def stripZoqlMargins()

in src/main/scala/com/gu/invoicing/invoice/Impl.scala [12:33]


  private def stripZoqlMargins(str: String): String =
    str.stripMargin.linesIterator.map(_.trim).mkString(" ").trim

  def getAccountIds(identityId: String) = {
    Http(s"$zuoraApiHost/v1/action/query")
      .header("Authorization", s"Bearer ${accessToken}")
      .header("Content-Type", "application/json")
      .postData(
        s"""{
           |  "queryString":
           |    "select Id
           |    from Account
           |    where IdentityId__c = '$identityId'"
           |}""".pipe(stripZoqlMargins),
      )
      .method("POST")
      .asString
      .body
      .pipe(read[Accounts](_))
      .records
      .map(_.Id)
  }