def getRunningDeployments()

in src/main/scala/com/gu/githubapi/GitHubApi.scala [45:59]


  def getRunningDeployments(gitHubConfig: GitHubConfig): Try[List[RunningLiveAppDeployment]] = {
    val query =
      """
    |{
    |	"query": "query { repository(owner:\"guardian\", name:\"ios-live\") { deployments(last: 10) { edges { node { databaseId, createdAt, environment, state, latestStatus { createdAt, description  } } } } } }"
    |}
    |""".stripMargin
    for {
      httpResponse <- Try(SharedClient.client.newCall(gitHubPostRequest(graphQlApiUrl, query, gitHubConfig)).execute)
      bodyAsString <- SharedClient.getResponseBodyIfSuccessful("GitHub API", httpResponse)
      deployments <- extractDeployments(bodyAsString).toTry
    } yield {
      runningLiveAppDeployments(deployments)
    }
  }