Skip to content

Instantly share code, notes, and snippets.

@hanishi
Created October 6, 2020 22:28
Show Gist options
  • Save hanishi/bb8e8848d04b6c4772ac94cf4bc1cec8 to your computer and use it in GitHub Desktop.
Save hanishi/bb8e8848d04b6c4772ac94cf4bc1cec8 to your computer and use it in GitHub Desktop.
def updateCriteria(
id: String,
adAccount: AdAccount,
criteria: Option[Criteria],
activate: Boolean
): Future[
(
AdAccount,
Criteria,
Seq[(Campaign, Criteria, Seq[(AdSet, Criteria)])]
)
] =
for {
(id, active) <-
userManager
.askWithStatus(ref =>
UserManager.UpdateCriteria(id, adAccount, criteria, activate, ref)
)
.map {
case (AdAccount(id, _), _, active, _) => (id, active)
}
result <-
if (active)
systemUser.askWithStatus(ref =>
SystemUser
.Enable(AdAccount(id), ref)
)
else
systemUser.askWithStatus(ref =>
SystemUser.Disable(AdAccount(id), ref)
)
} yield result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment