Example: Changing e-mail settings

Frequency of useCommon
Actors
  • An authenticated user (user)
Communication Flow: Kotlin
MailDescriptions.retrieveEmailSettings.call(
    RetrieveEmailSettingsRequest(
        username = null, 
    ),
    user
).orThrow()

/*
RetrieveEmailSettingsResponse(
    settings = EmailSettings(
        applicationStatusChange = true, 
        applicationTransfer = true, 
        grantApplicationApproved = true, 
        grantApplicationRejected = true, 
        grantApplicationUpdated = true, 
        grantApplicationWithdrawn = true, 
        grantAutoApprove = true, 
        lowFunds = true, 
        newCommentOnApplication = true, 
        newGrantApplication = true, 
        projectUserInvite = true, 
        projectUserRemoved = true, 
        userLeft = true, 
        userRoleChange = true, 
        verificationReminder = true, 
    ), 
)
*/
MailDescriptions.toggleEmailSettings.call(
    bulkRequestOf(EmailSettingsItem(
        settings = EmailSettings(
            applicationStatusChange = true, 
            applicationTransfer = true, 
            grantApplicationApproved = true, 
            grantApplicationRejected = true, 
            grantApplicationUpdated = true, 
            grantApplicationWithdrawn = true, 
            grantAutoApprove = true, 
            lowFunds = true, 
            newCommentOnApplication = true, 
            newGrantApplication = true, 
            projectUserInvite = true, 
            projectUserRemoved = true, 
            userLeft = true, 
            userRoleChange = true, 
            verificationReminder = false, 
        ), 
        username = null, 
    )),
    user
).orThrow()

/*
Unit
*/
MailDescriptions.retrieveEmailSettings.call(
    RetrieveEmailSettingsRequest(
        username = null, 
    ),
    user
).orThrow()

/*
RetrieveEmailSettingsResponse(
    settings = EmailSettings(
        applicationStatusChange = true, 
        applicationTransfer = true, 
        grantApplicationApproved = true, 
        grantApplicationRejected = true, 
        grantApplicationUpdated = true, 
        grantApplicationWithdrawn = true, 
        grantAutoApprove = true, 
        lowFunds = true, 
        newCommentOnApplication = true, 
        newGrantApplication = true, 
        projectUserInvite = true, 
        projectUserRemoved = true, 
        userLeft = true, 
        userRoleChange = true, 
        verificationReminder = false, 
    ), 
)
*/
Communication Flow: TypeScript
// Authenticated as user
await callAPI(MailApi.retrieveEmailSettings(
    {
        "username": null
    }
);

/*
{
    "settings": {
        "newGrantApplication": true,
        "grantAutoApprove": true,
        "grantApplicationUpdated": true,
        "grantApplicationApproved": true,
        "grantApplicationRejected": true,
        "grantApplicationWithdrawn": true,
        "newCommentOnApplication": true,
        "applicationTransfer": true,
        "applicationStatusChange": true,
        "projectUserInvite": true,
        "projectUserRemoved": true,
        "verificationReminder": true,
        "userRoleChange": true,
        "userLeft": true,
        "lowFunds": true
    }
}
*/
await callAPI(MailApi.toggleEmailSettings(
    {
        "items": [
            {
                "username": null,
                "settings": {
                    "newGrantApplication": true,
                    "grantAutoApprove": true,
                    "grantApplicationUpdated": true,
                    "grantApplicationApproved": true,
                    "grantApplicationRejected": true,
                    "grantApplicationWithdrawn": true,
                    "newCommentOnApplication": true,
                    "applicationTransfer": true,
                    "applicationStatusChange": true,
                    "projectUserInvite": true,
                    "projectUserRemoved": true,
                    "verificationReminder": false,
                    "userRoleChange": true,
                    "userLeft": true,
                    "lowFunds": true
                }
            }
        ]
    }
);

/*
{
}
*/
await callAPI(MailApi.retrieveEmailSettings(
    {
        "username": null
    }
);

/*
{
    "settings": {
        "newGrantApplication": true,
        "grantAutoApprove": true,
        "grantApplicationUpdated": true,
        "grantApplicationApproved": true,
        "grantApplicationRejected": true,
        "grantApplicationWithdrawn": true,
        "newCommentOnApplication": true,
        "applicationTransfer": true,
        "applicationStatusChange": true,
        "projectUserInvite": true,
        "projectUserRemoved": true,
        "verificationReminder": false,
        "userRoleChange": true,
        "userLeft": true,
        "lowFunds": true
    }
}
*/
Communication Flow: Curl
# ------------------------------------------------------------------------------------------------------
# $host is the UCloud instance to contact. Example: 'http://localhost:8080' or 'https://cloud.sdu.dk'
# $accessToken is a valid access-token issued by UCloud
# ------------------------------------------------------------------------------------------------------

# Authenticated as user
curl -XGET -H "Authorization: Bearer $accessToken" "$host/api/mail/retrieveEmailSettings?" 

# {
#     "settings": {
#         "newGrantApplication": true,
#         "grantAutoApprove": true,
#         "grantApplicationUpdated": true,
#         "grantApplicationApproved": true,
#         "grantApplicationRejected": true,
#         "grantApplicationWithdrawn": true,
#         "newCommentOnApplication": true,
#         "applicationTransfer": true,
#         "applicationStatusChange": true,
#         "projectUserInvite": true,
#         "projectUserRemoved": true,
#         "verificationReminder": true,
#         "userRoleChange": true,
#         "userLeft": true,
#         "lowFunds": true
#     }
# }

curl -XPOST -H "Authorization: Bearer $accessToken" -H "Content-Type: content-type: application/json; charset=utf-8" "$host/api/mail/toggleEmailSettings" -d '{
    "items": [
        {
            "username": null,
            "settings": {
                "newGrantApplication": true,
                "grantAutoApprove": true,
                "grantApplicationUpdated": true,
                "grantApplicationApproved": true,
                "grantApplicationRejected": true,
                "grantApplicationWithdrawn": true,
                "newCommentOnApplication": true,
                "applicationTransfer": true,
                "applicationStatusChange": true,
                "projectUserInvite": true,
                "projectUserRemoved": true,
                "verificationReminder": false,
                "userRoleChange": true,
                "userLeft": true,
                "lowFunds": true
            }
        }
    ]
}'


# {
# }

curl -XGET -H "Authorization: Bearer $accessToken" "$host/api/mail/retrieveEmailSettings?" 

# {
#     "settings": {
#         "newGrantApplication": true,
#         "grantAutoApprove": true,
#         "grantApplicationUpdated": true,
#         "grantApplicationApproved": true,
#         "grantApplicationRejected": true,
#         "grantApplicationWithdrawn": true,
#         "newCommentOnApplication": true,
#         "applicationTransfer": true,
#         "applicationStatusChange": true,
#         "projectUserInvite": true,
#         "projectUserRemoved": true,
#         "verificationReminder": false,
#         "userRoleChange": true,
#         "userLeft": true,
#         "lowFunds": true
#     }
# }
Communication Flow: Visual