Skip to content

Instantly share code, notes, and snippets.

@dragoonis
Created February 4, 2019 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dragoonis/2168d2079f2e684f0306360d364c6d4e to your computer and use it in GitHub Desktop.
Save dragoonis/2168d2079f2e684f0306360d364c6d4e to your computer and use it in GitHub Desktop.
exec(
http("ALL DOCUMENTS FOR A CLIENT")
// .get("/api/v1/persons/${siriusRandomAssignedClientId}/documents?limit=999&sort=createdDate:desc,id:desc&filter=draft:0")
.get("/api/v1/persons/${siriusAssignedClientId}/documents?limit=999&sort=createdDate:desc,id:desc&filter=draft:0")
.headers(apiHeaders)
.check(status.is(200))
.check(jsonPath("$.documents")
.ofType[Map[String, Any]]
.findAll
.saveAs("siriusAssignedDocuments")
)
)
.exitHereIfFailed
// https://gist.github.com/ivanursul/78404db87c2d2334db55
// Here we loop all the found documents and request them
.doIf(session => session("siriusAssignedDocuments").as[Map[String, Any]].size > 0) {
// We verify now that we have found documents for this client, and as such the "asLongAs" loop won't iterater to a new client.
exec( session => {
session.set("foundDocuments", "true")
})
// Iterate all of the client's documents
.foreach("${siriusAssignedDocuments}", "assignedDocument") {
// We need to pluck out the documentId from the next item in the foreach(), which is stored in the session
exec( session => {
// as[Map[String, String]]
val assignedDocument = session("assignedDocument").as[Map[String, Any]]
println("assignedDocument from the session:" + assignedDocument);
session.set("assignedDocumentId", assignedDocument("id"))
session
})
.exec(
http("GET DOCUMENT")
.get("/api/document/${assignedDocumentId}/file")
.headers(pdfHeaders)
.check(status.is(200))
)
.exitHereIfFailed
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment