Skip to content

Add campaign reminder configuration support#623

Open
jamescarr wants to merge 1 commit into
OpsLevel:mainfrom
jamescarr:jamescarr/campaign-reminders
Open

Add campaign reminder configuration support#623
jamescarr wants to merge 1 commit into
OpsLevel:mainfrom
jamescarr:jamescarr/campaign-reminders

Conversation

@jamescarr

Copy link
Copy Markdown
Contributor

Summary

  • Adds CampaignReminderInput and wires a reminder field into CampaignCreateInput and CampaignUpdateInput, enabling recurring campaign reminders (Slack, email, Microsoft Teams) via the existing campaignCreate / campaignUpdate mutations.
  • CampaignUpdateInput.Reminder uses *Nullable[CampaignReminderInput] so a reminder can be explicitly cleared.
  • Changes Campaign.Reminder to *CampaignReminder so "no reminder" is distinguishable from a zero-value reminder, and adds the read-side DefaultMicrosoftTeamsChannel field.

Notes

  • daysOfWeek is only valid for a weekly cadence; callers should omit it otherwise (the API rejects it for daily/monthly). This matches the validation enforced in the terraform-provider-opslevel consumer.
  • The API normalizes defaultSlackChannel by prepending #.

Test plan

  • go build ./...
  • go vet ./...
  • go test ./... (added TestCreateCampaignWithReminder and TestUpdateCampaignClearReminder; updated mock templates for the new defaultMicrosoftTeamsChannel selection)
  • gofumpt clean

Made with Cursor

Add CampaignReminderInput and wire a reminder field into CampaignCreateInput
and CampaignUpdateInput so recurring campaign reminders (Slack, email, and
Microsoft Teams) can be managed via the campaignCreate/campaignUpdate
mutations. CampaignUpdateInput uses Nullable so a reminder can be explicitly
cleared.

Campaign.Reminder is now a pointer to distinguish a campaign with no reminder
from one with a zero-value reminder, and the read-side CampaignReminder gains
the DefaultMicrosoftTeamsChannel field.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jamescarr

Copy link
Copy Markdown
Contributor Author

Usage examples

Create a campaign with a weekly reminder

message := "Please complete your campaign checks."
slack := "platform-eng" // API stores this as "#platform-eng"

campaign, err := client.CreateCampaign(opslevel.CampaignCreateInput{
    Name:    "Upgrade to Rails 7",
    OwnerId: teamID,
    Reminder: &opslevel.CampaignReminderInput{
        Channels:            []opslevel.CampaignReminderChannelEnum{
            opslevel.CampaignReminderChannelEnumSlack,
            opslevel.CampaignReminderChannelEnumEmail,
        },
        Frequency:           1,
        FrequencyUnit:       opslevel.CampaignReminderFrequencyUnitEnumWeek,
        DaysOfWeek:          []opslevel.DayOfWeekEnum{opslevel.DayOfWeekEnumMonday, opslevel.DayOfWeekEnumThursday},
        TimeOfDay:           "09:30",
        Timezone:            "America/Chicago",
        Message:             &message,
        DefaultSlackChannel: &slack,
    },
})

DaysOfWeek must be omitted for day / month cadences (the API only accepts it for week).

Clear an existing reminder on update

_, err := client.UpdateCampaign(opslevel.CampaignUpdateInput{
    Id:       campaign.Id,
    Reminder: opslevel.NewNullOf[opslevel.CampaignReminderInput](), // marshals to `null`
})

Read it back

c, _ := client.GetCampaign(campaign.Id)
if c.Reminder != nil {
    fmt.Println(c.Reminder.FrequencyUnit, c.Reminder.NextOccurrence)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant