notificationapi

package module
v0.0.0-...-e462b58 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2025 License: ISC Imports: 10 Imported by: 0

README

NotificationAPI Go Server SDK

Go Version License

The official Go server SDK for NotificationAPI. This library allows you to send notifications, manage users, and interact with the NotificationAPI platform from your Go applications.

Features

  • Send notifications across multiple channels (Email, SMS, Push, In-App, etc.)
  • User management and identification
  • Notification preferences management
  • Scheduled notifications
  • Sub-notifications
  • Comprehensive logging and querying
  • Regional API endpoint support
  • Full type safety with Go structs

Installation

go get github.com/ableinc/go-notificationsapi

Quick Start

package main

import (
    "fmt"
    "log"
    
    "github.com/ableinc/go-notificationsapi"
)

func main() {
    // Initialize the client
    client, err := notificationapi.NewClient("your-client-id", "your-client-secret", nil)
    if err != nil {
        log.Fatal(err)
    }

    // Send a notification
    req := notificationapi.SendRequest{
        Type: stringPtr("welcome_email"),
        To: &notificationapi.User{
            ID:    "user123",
            Email: stringPtr("user@example.com"),
        },
        Parameters: map[string]interface{}{
            "firstName": "John",
            "lastName":  "Doe",
        },
    }

    resp, err := client.Send(req)
    if err != nil {
        log.Fatal(err)
    }
    
    fmt.Printf("Notification sent successfully: %d\n", resp.StatusCode)
}

// Helper function to create string pointers
func stringPtr(s string) *string {
    return &s
}

Configuration

Regional Endpoints

You can configure the SDK to use different regional endpoints:

// US Region (default)
client, err := notificationapi.NewClient(clientID, clientSecret, &notificationapi.InitConfiguration{
    BaseURL: string(notificationapi.USRegion),
})

// EU Region
client, err := notificationapi.NewClient(clientID, clientSecret, &notificationapi.InitConfiguration{
    BaseURL: string(notificationapi.EURegion),
})

// CA Region
client, err := notificationapi.NewClient(clientID, clientSecret, &notificationapi.InitConfiguration{
    BaseURL: string(notificationapi.CARegion),
})

// Custom endpoint
client, err := notificationapi.NewClient(clientID, clientSecret, &notificationapi.InitConfiguration{
    BaseURL: "https://your-custom-endpoint.com",
})

Usage Examples

Sending Notifications
Basic Notification
req := notificationapi.SendRequest{
    Type: stringPtr("user_welcome"),
    To: &notificationapi.User{
        ID:    "user123",
        Email: stringPtr("user@example.com"),
    },
    Parameters: map[string]interface{}{
        "name": "John Doe",
        "company": "Acme Corp",
    },
}

resp, err := client.Send(req)
Notification with Channel-Specific Content
req := notificationapi.SendRequest{
    Type: stringPtr("order_confirmation"),
    To: &notificationapi.User{
        ID:     "user123",
        Email:  stringPtr("user@example.com"),
        Number: stringPtr("+1234567890"),
    },
    Email: &notificationapi.ChannelEmail{
        Subject: "Order Confirmation #12345",
        HTML:    "<h1>Thank you for your order!</h1><p>Order #12345 has been confirmed.</p>",
    },
    SMS: &notificationapi.ChannelSMS{
        Message: "Your order #12345 has been confirmed. Thank you!",
    },
}

resp, err := client.Send(req)
Scheduled Notification
req := notificationapi.SendRequest{
    Type: stringPtr("reminder"),
    To: &notificationapi.User{
        ID:    "user123",
        Email: stringPtr("user@example.com"),
    },
    Schedule: stringPtr("2024-12-25T10:00:00Z"), // ISO 8601 format
    Parameters: map[string]interface{}{
        "eventName": "Holiday Sale",
    },
}

resp, err := client.Send(req)
Force Specific Channels
req := notificationapi.SendRequest{
    Type: stringPtr("urgent_alert"),
    To: &notificationapi.User{
        ID:     "user123",
        Email:  stringPtr("user@example.com"),
        Number: stringPtr("+1234567890"),
    },
    ForceChannels: []notificationapi.Channels{
        notificationapi.EMAIL,
        notificationapi.SMS,
    },
}

resp, err := client.Send(req)
User Management
Identify User
user := notificationapi.User{
    ID:       "user123",
    Email:    stringPtr("user@example.com"),
    Number:   stringPtr("+1234567890"),
    Timezone: stringPtr("America/New_York"),
    PushTokens: []notificationapi.PushToken{
        {
            Type:  notificationapi.FCM,
            Token: "fcm-token-here",
            Device: notificationapi.Device{
                DeviceID: "device123",
                Platform: stringPtr("android"),
            },
        },
    },
}

resp, err := client.IdentifyUser(user)
User Preferences
Set User Preferences
preferences := []notificationapi.SetUserPreferencesRequest{
    {
        NotificationID: "order_updates",
        Channel:        stringPtr(string(notificationapi.EMAIL)),
        Delivery:       stringPtr("daily"),
    },
    {
        NotificationID: "marketing",
        Delivery:       stringPtr("off"),
    },
}

resp, err := client.SetUserPreferences("user123", preferences)
Delete User Preferences
// Delete all preferences for a notification
resp, err := client.DeleteUserPreferences("user123", "marketing", nil)

// Delete preferences for a specific sub-notification
subNotificationID := "special_offers"
resp, err := client.DeleteUserPreferences("user123", "marketing", &subNotificationID)
Sub-Notifications
Create Sub-Notification
req := notificationapi.CreateSubNotificationRequest{
    NotificationID:    "order_updates",
    Title:             "Express Shipping Updates",
    SubNotificationID: "express_shipping",
}

resp, err := client.CreateSubNotification(req)
Delete Sub-Notification
req := notificationapi.DeleteSubNotificationRequest{
    NotificationID:    "order_updates",
    SubNotificationID: "express_shipping",
}

resp, err := client.DeleteSubNotification(req)
In-App Notifications
Update In-App Notification Status
req := notificationapi.InAppNotificationPatchRequest{
    TrackingIDs: []string{"tracking-id-1", "tracking-id-2"},
    Opened:      stringPtr("2024-01-01T12:00:00Z"),
    Clicked:     stringPtr("2024-01-01T12:05:00Z"),
    Reply: &notificationapi.ReplyInfo{
        Date:    "2024-01-01T12:10:00Z",
        Message: "Thank you for the update!",
    },
}

resp, err := client.UpdateInAppNotification("user123", req)
Scheduled Notifications
Update Scheduled Notification
updateReq := notificationapi.SendRequest{
    Schedule: stringPtr("2024-12-26T10:00:00Z"), // New schedule
    Parameters: map[string]interface{}{
        "newParam": "updated value",
    },
}

resp, err := client.UpdateSchedule("tracking-id", updateReq)
Delete Scheduled Notification
resp, err := client.DeleteSchedule("tracking-id")
Retract Notifications
req := notificationapi.RetractRequest{
    NotificationID: "order_confirmation",
    UserID:         "user123",
}

resp, err := client.Retract(req)
Query Logs
Basic Log Query
params := notificationapi.QueryLogsPostBody{
    DateRangeFilter: &notificationapi.DateRangeFilter{
        StartTime: int64Ptr(1640995200), // Unix timestamp
        EndTime:   int64Ptr(1641081600),
    },
    NotificationFilter: []string{"order_confirmation", "welcome_email"},
    ChannelFilter:      []notificationapi.Channels{notificationapi.EMAIL, notificationapi.SMS},
    UserFilter:         []string{"user123", "user456"},
    StatusFilter:       []string{"sent", "delivered"},
}

resp, err := client.QueryLogs(params)
Custom Log Query
params := notificationapi.QueryLogsPostBody{
    CustomFilter: stringPtr("fields @message | filter @logStream like /ERROR/ | sort @timestamp desc"),
}

resp, err := client.QueryLogs(params)

Error Handling

The SDK automatically handles HTTP errors and provides detailed error messages:

resp, err := client.Send(req)
if err != nil {
    // Handle error
    fmt.Printf("Error sending notification: %v\n", err)
    return
}

// Check for warning responses (HTTP 202)
if resp.StatusCode == 202 {
    // Warning logged automatically, but you can handle it here
    fmt.Println("Notification sent with warnings")
}

Email Options

Email Attachments
req := notificationapi.SendRequest{
    Type: stringPtr("invoice"),
    To: &notificationapi.User{
        ID:    "user123",
        Email: stringPtr("user@example.com"),
    },
    Options: &notificationapi.NotificationOptions{
        Email: &notificationapi.EmailOptions{
            FromName:         stringPtr("Acme Corp"),
            FromAddress:      stringPtr("noreply@acme.com"),
            ReplyToAddresses: []string{"support@acme.com"},
            CCAddresses:      []string{"accounting@acme.com"},
            Attachments: []notificationapi.EmailAttachment{
                {
                    Filename: "invoice-12345.pdf",
                    URL:      "https://secure.acme.com/invoices/12345.pdf",
                },
            },
        },
    },
}

resp, err := client.Send(req)

Push Notifications

Mobile Push Notifications
// First, identify user with push tokens
user := notificationapi.User{
    ID: "user123",
    PushTokens: []notificationapi.PushToken{
        {
            Type:  notificationapi.FCM,
            Token: "fcm-device-token",
            Device: notificationapi.Device{
                DeviceID: "device123",
                Platform: stringPtr("android"),
                AppID:    stringPtr("com.acme.app"),
            },
        },
        {
            Type:  notificationapi.APN,
            Token: "apn-device-token",
            Device: notificationapi.Device{
                DeviceID: "device456",
                Platform: stringPtr("ios"),
                AppID:    stringPtr("com.acme.app"),
            },
        },
    },
}

_, err := client.IdentifyUser(user)
if err != nil {
    log.Fatal(err)
}

// Send push notification
req := notificationapi.SendRequest{
    Type: stringPtr("new_message"),
    To: &notificationapi.User{
        ID: "user123",
    },
    MobilePush: &notificationapi.ChannelMobilePush{
        Title:   "New Message",
        Message: "You have a new message from John",
    },
    Options: &notificationapi.NotificationOptions{
        APN: &notificationapi.APNOptions{
            Badge:  intPtr(1),
            Sound:  stringPtr("default"),
            ThreadID: stringPtr("messages"),
        },
        FCM: &notificationapi.FCMOptions{
            Android: &notificationapi.AndroidFCMOptions{
                Priority: stringPtr("high"),
                TTL:      intPtr(3600),
            },
        },
    },
}

resp, err := client.Send(req)
Web Push Notifications
// First, identify user with web push tokens
user := notificationapi.User{
    ID: "user123",
    WebPushTokens: []notificationapi.WebPushToken{
        {
            Sub: notificationapi.PushSubscription{
                Endpoint: "https://fcm.googleapis.com/fcm/send/...",
                Keys: struct {
                    P256dh string `json:"p256dh"`
                    Auth   string `json:"auth"`
                }{
                    P256dh: "p256dh-key-here",
                    Auth:   "auth-key-here",
                },
            },
        },
    },
}

_, err := client.IdentifyUser(user)
if err != nil {
    log.Fatal(err)
}

// Send web push notification
req := notificationapi.SendRequest{
    Type: stringPtr("breaking_news"),
    To: &notificationapi.User{
        ID: "user123",
    },
    WebPush: &notificationapi.ChannelWebPush{
        Title:   "Breaking News",
        Message: "Important update from our team",
        Icon:    stringPtr("https://example.com/icon.png"),
        URL:     stringPtr("https://example.com/news/123"),
    },
}

resp, err := client.Send(req)

API Reference

Types
Channels
  • EMAIL - Email notifications
  • INAPP_WEB - In-app web notifications
  • SMS - SMS notifications
  • CALL - Call notifications
  • PUSH - Mobile push notifications
  • WEB_PUSH - Web push notifications
Regions
  • USRegion - United States (default)
  • EURegion - European Union
  • CARegion - Canada
Push Providers
  • FCM - Firebase Cloud Messaging
  • APN - Apple Push Notification service
Helper Functions

Since Go doesn't have optional parameters, you'll often need to create pointers to basic types:

// Helper functions you might want to add to your code
func stringPtr(s string) *string {
    return &s
}

func intPtr(i int) *int {
    return &i
}

func int64Ptr(i int64) *int64 {
    return &i
}

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Testing

Run the test suite:

go test -v

Run tests with coverage:

go test -v -cover

License

This project is licensed under the ISC License - see the LICENSE file for details.

Support

Changelog

v1.0.0
  • Initial release
  • Full feature parity with Node.js SDK
  • Support for all NotificationAPI features
  • Comprehensive test coverage
  • Go 1.24+ support

Documentation

Overview

Package notificationapi provides a Go SDK for the NotificationAPI service.

NotificationAPI is a comprehensive notification platform that allows you to send notifications across multiple channels including Email, SMS, Push notifications, In-App notifications, and more.

Quick Start

To get started, you need to create a client with your NotificationAPI credentials:

client, err := notificationapi.NewClient("your-client-id", "your-client-secret", nil)
if err != nil {
    log.Fatal(err)
}

Sending Notifications

Once you have a client, you can send notifications:

req := notificationapi.SendRequest{
    Type: stringPtr("welcome_email"),
    To: &notificationapi.User{
        ID:    "user123",
        Email: stringPtr("user@example.com"),
    },
    Parameters: map[string]interface{}{
        "firstName": "John",
        "lastName":  "Doe",
    },
}

resp, err := client.Send(req)
if err != nil {
    log.Fatal(err)
}

User Management

You can identify and manage users:

user := notificationapi.User{
    ID:       "user123",
    Email:    stringPtr("user@example.com"),
    Number:   stringPtr("+1234567890"),
    Timezone: stringPtr("America/New_York"),
}

resp, err := client.IdentifyUser(user)

Regional Endpoints

The SDK supports multiple regional endpoints:

// EU Region
client, err := notificationapi.NewClient(clientID, clientSecret, &notificationapi.InitConfiguration{
    BaseURL: string(notificationapi.EURegion),
})

Error Handling

The SDK provides detailed error information for failed requests:

resp, err := client.Send(req)
if err != nil {
    fmt.Printf("Error: %v\n", err)
    return
}

if resp.StatusCode >= 400 {
    // Handle error response
}

For more examples and detailed documentation, see the README.md file or visit https://docs.notificationapi.com

Package notificationapi provides a Go SDK for the NotificationAPI service. It allows you to send notifications, manage users, and interact with the NotificationAPI platform.

Package notificationapi provides types and structures for the NotificationAPI Go SDK

Index

Constants

View Source
const (
	DefaultBaseURL = "https://api.notificationapi.com"
	UserAgent      = "notificationapi-go-server-sdk"
	Version        = "1.0.0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APNOptions

type APNOptions struct {
	Expiry           *int    `json:"expiry,omitempty"`
	Priority         *int    `json:"priority,omitempty"`
	CollapseID       *string `json:"collapseId,omitempty"`
	ThreadID         *string `json:"threadId,omitempty"`
	Badge            *int    `json:"badge,omitempty"`
	Sound            *string `json:"sound,omitempty"`
	ContentAvailable *bool   `json:"contentAvailable,omitempty"`
}

APNOptions contains Apple Push Notification options

type AndroidFCMOptions

type AndroidFCMOptions struct {
	CollapseKey           *string `json:"collapseKey,omitempty"`
	Priority              *string `json:"priority,omitempty"` // "high" or "normal"
	TTL                   *int    `json:"ttl,omitempty"`
	RestrictedPackageName *string `json:"restrictedPackageName,omitempty"`
}

AndroidFCMOptions contains Android-specific FCM options

type ChannelCall

type ChannelCall struct {
	Message string `json:"message"`
}

type ChannelEmail

type ChannelEmail struct {
	Subject     string  `json:"subject"`
	HTML        string  `json:"html"`
	PreviewText *string `json:"previewText,omitempty"`
	SenderName  *string `json:"senderName,omitempty"`
	SenderEmail *string `json:"senderEmail,omitempty"`
}

ChannelSpecificContent contains channel-specific content

type ChannelInApp

type ChannelInApp struct {
	Title string  `json:"title"`
	URL   *string `json:"url,omitempty"`
	Image *string `json:"image,omitempty"`
}

type ChannelMobilePush

type ChannelMobilePush struct {
	Title   string `json:"title"`
	Message string `json:"message"`
}

type ChannelSMS

type ChannelSMS struct {
	Message string `json:"message"`
}

type ChannelSlack

type ChannelSlack struct {
	Text   string       `json:"text"`
	Blocks []SlackBlock `json:"blocks,omitempty"`
}

type ChannelWebPush

type ChannelWebPush struct {
	Title   string  `json:"title"`
	Message string  `json:"message"`
	Icon    *string `json:"icon,omitempty"`
	URL     *string `json:"url,omitempty"`
}

type Channels

type Channels string

Channels represents supported notification channels

const (
	// EMAIL represents email notifications
	EMAIL Channels = "EMAIL"
	// INAPP_WEB represents in-app web notifications
	INAPP_WEB Channels = "INAPP_WEB"
	// SMS represents SMS notifications
	SMS Channels = "SMS"
	// CALL represents call notifications
	CALL Channels = "CALL"
	// PUSH represents push notifications
	PUSH Channels = "PUSH"
	// WEB_PUSH represents web push notifications
	WEB_PUSH Channels = "WEB_PUSH"
)

type Client

type Client struct {
	ClientID     string
	ClientSecret string
	BaseURL      string
	HTTPClient   *http.Client
}

Client represents the NotificationAPI client

func NewClient

func NewClient(clientID, clientSecret string, config *InitConfiguration) (*Client, error)

NewClient creates a new NotificationAPI client

func (*Client) CreateSubNotification

func (c *Client) CreateSubNotification(params CreateSubNotificationRequest) (*http.Response, error)

CreateSubNotification creates a sub-notification

func (*Client) DeleteSchedule

func (c *Client) DeleteSchedule(trackingID string) (*http.Response, error)

DeleteSchedule deletes a scheduled notification

func (*Client) DeleteSubNotification

func (c *Client) DeleteSubNotification(params DeleteSubNotificationRequest) (*http.Response, error)

DeleteSubNotification deletes a sub-notification

func (*Client) DeleteUserPreferences

func (c *Client) DeleteUserPreferences(userID, notificationID string, subNotificationID *string) (*http.Response, error)

DeleteUserPreferences deletes user preferences

func (*Client) IdentifyUser

func (c *Client) IdentifyUser(user User) (*http.Response, error)

IdentifyUser identifies a user in the NotificationAPI system

func (*Client) QueryLogs

func (c *Client) QueryLogs(params QueryLogsPostBody) (*http.Response, error)

QueryLogs queries notification logs

func (*Client) Retract

func (c *Client) Retract(req RetractRequest) (*http.Response, error)

Retract retracts/deletes a notification

func (*Client) Send

func (c *Client) Send(req SendRequest) (*http.Response, error)

Send sends a notification

func (*Client) SetUserPreferences

func (c *Client) SetUserPreferences(userID string, preferences []SetUserPreferencesRequest) (*http.Response, error)

SetUserPreferences sets user notification preferences

func (*Client) UpdateInAppNotification

func (c *Client) UpdateInAppNotification(userID string, params InAppNotificationPatchRequest) (*http.Response, error)

UpdateInAppNotification updates in-app notification status

func (*Client) UpdateSchedule

func (c *Client) UpdateSchedule(trackingID string, req SendRequest) (*http.Response, error)

UpdateSchedule updates a scheduled notification

type CreateSubNotificationRequest

type CreateSubNotificationRequest struct {
	// NotificationID is the ID of the notification in NotificationAPI (required)
	NotificationID string `json:"notificationId"`
	// Title is the title of the sub-notification (required)
	Title string `json:"title"`
	// SubNotificationID specifies the sub-notification ID (required)
	SubNotificationID string `json:"subNotificationId"`
}

CreateSubNotificationRequest represents a request to create a sub-notification

type DateRangeFilter

type DateRangeFilter struct {
	// StartTime as Unix timestamp (cannot be less than log retention period)
	StartTime *int64 `json:"startTime,omitempty"`
	// EndTime as Unix timestamp
	EndTime *int64 `json:"endTime,omitempty"`
}

DateRangeFilter represents a date range filter for log queries

type DeleteSubNotificationRequest

type DeleteSubNotificationRequest struct {
	// NotificationID is the ID of the notification in NotificationAPI (required)
	NotificationID string `json:"notificationId"`
	// SubNotificationID specifies the sub-notification ID to delete (required)
	SubNotificationID string `json:"subNotificationId"`
}

DeleteSubNotificationRequest represents a request to delete a sub-notification

type Device

type Device struct {
	// AppID is the ID of the application the token is used for
	AppID *string `json:"app_id,omitempty"`
	// AdID is the advertising identifier
	AdID *string `json:"ad_id,omitempty"`
	// DeviceID is the ID of the device the token is associated with
	DeviceID string `json:"device_id"`
	// Platform is the device platform (e.g., android, ios)
	Platform *string `json:"platform,omitempty"`
	// Manufacturer is the device manufacturer
	Manufacturer *string `json:"manufacturer,omitempty"`
	// Model is the device model
	Model *string `json:"model,omitempty"`
}

Device contains information about a device for push notifications

type EmailAttachment

type EmailAttachment struct {
	// Filename with file extension for proper display
	Filename string `json:"filename"`
	// URL pointing to the file (must be valid for a few minutes)
	URL string `json:"url"`
}

EmailAttachment represents an email attachment

type EmailOptions

type EmailOptions struct {
	// ReplyToAddresses for the reply-to field
	ReplyToAddresses []string `json:"replyToAddresses,omitempty"`
	// CCAddresses to be CC'ed on the email
	CCAddresses []string `json:"ccAddresses,omitempty"`
	// BCCAddresses to be BCC'ed on the email
	BCCAddresses []string `json:"bccAddresses,omitempty"`
	// FromName displayed as the "from" field
	FromName *string `json:"fromName,omitempty"`
	// FromAddress displayed as the "from" field
	FromAddress *string `json:"fromAddress,omitempty"`
	// Attachments to include in the email
	Attachments []EmailAttachment `json:"attachments,omitempty"`
}

EmailOptions contains email-specific options

type FCMOptions

type FCMOptions struct {
	Android *AndroidFCMOptions `json:"android,omitempty"`
}

FCMOptions contains Firebase Cloud Messaging options

type InAppNotificationPatchRequest

type InAppNotificationPatchRequest struct {
	// TrackingIDs to update
	TrackingIDs []string `json:"trackingIds"`
	// Opened timestamp
	Opened *string `json:"opened,omitempty"`
	// Clicked timestamp
	Clicked *string `json:"clicked,omitempty"`
	// Archived timestamp
	Archived *string `json:"archived,omitempty"`
	// Actioned1 timestamp
	Actioned1 *string `json:"actioned1,omitempty"`
	// Actioned2 timestamp
	Actioned2 *string `json:"actioned2,omitempty"`
	// Reply information
	Reply *ReplyInfo `json:"reply,omitempty"`
}

InAppNotificationPatchRequest represents a request to update in-app notifications

type InitConfiguration

type InitConfiguration struct {
	// BaseURL allows overriding the base URL. Can be a region constant or custom URL string
	BaseURL string `json:"baseURL,omitempty"`
}

InitConfiguration contains configuration options for initializing the SDK

type NotificationOptions

type NotificationOptions struct {
	// Email-specific options
	Email *EmailOptions `json:"email,omitempty"`
	// APN-specific options
	APN *APNOptions `json:"apn,omitempty"`
	// FCM-specific options
	FCM *FCMOptions `json:"fcm,omitempty"`
}

NotificationOptions contains various notification options

type PushProviders

type PushProviders string

PushProviders represents push notification providers

const (
	// FCM represents Firebase Cloud Messaging
	FCM PushProviders = "FCM"
	// APN represents Apple Push Notification service
	APN PushProviders = "APN"
)

type PushSubscription

type PushSubscription struct {
	// Endpoint is the endpoint associated with the push subscription
	Endpoint string `json:"endpoint"`
	// Keys contains the subscription keys
	Keys struct {
		// P256dh is the P-256 ECDH public key
		P256dh string `json:"p256dh"`
		// Auth is the authentication secret
		Auth string `json:"auth"`
	} `json:"keys"`
}

PushSubscription represents a web push subscription

type PushToken

type PushToken struct {
	// Type indicates the provider token (APN or FCM)
	Type PushProviders `json:"type"`
	// Token is the full token string
	Token string `json:"token"`
	// Device contains information about the device
	Device Device `json:"device"`
}

PushToken represents a push notification token

type QueryLogsPostBody

type QueryLogsPostBody struct {
	// DateRangeFilter filters logs by date range
	DateRangeFilter *DateRangeFilter `json:"dateRangeFilter,omitempty"`
	// NotificationFilter filters by specific notification IDs
	NotificationFilter []string `json:"notificationFilter,omitempty"`
	// ChannelFilter filters by specific channels
	ChannelFilter []Channels `json:"channelFilter,omitempty"`
	// UserFilter filters by specific user IDs
	UserFilter []string `json:"userFilter,omitempty"`
	// StatusFilter filters by specific statuses
	StatusFilter []string `json:"statusFilter,omitempty"`
	// TrackingIDs filters by specific tracking IDs
	TrackingIDs []string `json:"trackingIds,omitempty"`
	// RequestFilter filters by specific body request of send request
	RequestFilter []string `json:"requestFilter,omitempty"`
	// EnvIDFilter filters by specific environment IDs
	EnvIDFilter []string `json:"envIdFilter,omitempty"`
	// CustomFilter allows advanced querying (overwrites all other filters)
	CustomFilter *string `json:"customFilter,omitempty"`
}

QueryLogsPostBody represents the body for querying logs

type Region

type Region string

Region represents different geographical API endpoints

const (
	// USRegion represents the United States region endpoint
	USRegion Region = "https://api.notificationapi.com"
	// EURegion represents the European Union region endpoint
	EURegion Region = "https://api.eu.notificationapi.com"
	// CARegion represents the Canada region endpoint
	CARegion Region = "https://api.ca.notificationapi.com"
)

type ReplyInfo

type ReplyInfo struct {
	Date    string `json:"date"`
	Message string `json:"message"`
}

ReplyInfo represents reply information for in-app notifications

type RetractRequest

type RetractRequest struct {
	// NotificationID is the ID of the notification in NotificationAPI (required)
	NotificationID string `json:"notificationId"`
	// UserID is the ID of the user in your system (required)
	UserID string `json:"userId"`
	// SecondaryID will be deprecated soon
	SecondaryID *string `json:"secondaryId,omitempty"`
	// SubNotificationID specifies subcategories within a notification
	SubNotificationID *string `json:"subNotificationId,omitempty"`
}

RetractRequest represents a request to retract a notification

type SendRequest

type SendRequest struct {
	// Deprecated: Use Type instead
	NotificationID *string `json:"notificationId,omitempty"`
	// Deprecated: Use To instead
	User *User `json:"user,omitempty"`
	// Deprecated: Use Parameters instead
	MergeTags map[string]interface{} `json:"mergeTags,omitempty"`
	// Deprecated
	Replace map[string]string `json:"replace,omitempty"`

	// Type is the notification type (previously NotificationID)
	Type *string `json:"type,omitempty"`
	// To is the recipient of the notification
	To *User `json:"to,omitempty"`
	// ForceChannels overrides the default channels for the notification
	ForceChannels []Channels `json:"forceChannels,omitempty"`
	// Parameters to be used in the notification template
	Parameters map[string]interface{} `json:"parameters,omitempty"`
	// Deprecated: Use SubNotificationID instead
	SecondaryID *string `json:"secondaryId,omitempty"`
	// TemplateID forces using a specific template
	TemplateID *string `json:"templateId,omitempty"`
	// SubNotificationID specifies subcategories within a notification
	SubNotificationID *string `json:"subNotificationId,omitempty"`
	// Options for modifying notification behavior
	Options *NotificationOptions `json:"options,omitempty"`
	// Schedule is an ISO 8601 datetime string to schedule the notification
	Schedule *string `json:"schedule,omitempty"`

	// Channel-specific options
	Email      *ChannelEmail      `json:"email,omitempty"`
	InApp      *ChannelInApp      `json:"inapp,omitempty"`
	SMS        *ChannelSMS        `json:"sms,omitempty"`
	Call       *ChannelCall       `json:"call,omitempty"`
	WebPush    *ChannelWebPush    `json:"web_push,omitempty"`
	MobilePush *ChannelMobilePush `json:"mobile_push,omitempty"`
	Slack      *ChannelSlack      `json:"slack,omitempty"`
}

SendRequest represents a request to send a notification

type SetUserPreferencesRequest

type SetUserPreferencesRequest struct {
	// NotificationID is the ID of the notification in NotificationAPI (required)
	NotificationID string `json:"notificationId"`
	// Channel related to the user preferences (optional)
	Channel *string `json:"channel,omitempty"`
	// Delivery method for the notification (optional)
	Delivery *string `json:"delivery,omitempty"` // "off", "instant", "hourly", "daily", "weekly", "monthly"
	// SubNotificationID specifies subcategories within a notification (optional)
	SubNotificationID *string `json:"subNotificationId,omitempty"`
}

SetUserPreferencesRequest represents user notification preferences

type SlackBlock

type SlackBlock interface{}

SlackBlock represents a Slack block (simplified version)

type SlackToken

type SlackToken struct {
	AccessToken *string `json:"access_token,omitempty"`
	AppID       *string `json:"app_id,omitempty"`
	AuthedUser  *struct {
		AccessToken  *string `json:"access_token,omitempty"`
		ExpiresIn    *int    `json:"expires_in,omitempty"`
		ID           *string `json:"id,omitempty"`
		RefreshToken *string `json:"refresh_token,omitempty"`
		Scope        *string `json:"scope,omitempty"`
		TokenType    *string `json:"token_type,omitempty"`
	} `json:"authed_user,omitempty"`
	BotUserID  *string `json:"bot_user_id,omitempty"`
	Enterprise *struct {
		ID   *string `json:"id,omitempty"`
		Name *string `json:"name,omitempty"`
	} `json:"enterprise,omitempty"`
	Error           *string `json:"error,omitempty"`
	ExpiresIn       *int    `json:"expires_in,omitempty"`
	IncomingWebhook *struct {
		Channel          *string `json:"channel,omitempty"`
		ChannelID        *string `json:"channel_id,omitempty"`
		ConfigurationURL *string `json:"configuration_url,omitempty"`
		URL              *string `json:"url,omitempty"`
	} `json:"incoming_webhook,omitempty"`
	IsEnterpriseInstall *bool   `json:"is_enterprise_install,omitempty"`
	Needed              *string `json:"needed,omitempty"`
	OK                  *bool   `json:"ok,omitempty"`
	Provided            *string `json:"provided,omitempty"`
	RefreshToken        *string `json:"refresh_token,omitempty"`
	Scope               *string `json:"scope,omitempty"`
	Team                *struct {
		ID   *string `json:"id,omitempty"`
		Name *string `json:"name,omitempty"`
	} `json:"team,omitempty"`
	TokenType *string `json:"token_type,omitempty"`
	Warning   *string `json:"warning,omitempty"`
}

SlackToken represents Slack OAuth token information

type User

type User struct {
	// ID is the user ID in your system (required)
	ID string `json:"id"`
	// Email is required for email notifications, otherwise optional
	Email *string `json:"email,omitempty"`
	// Number is required for SMS/CALL notifications, otherwise optional
	// Valid format: +15005550006. Unformatted US/Canada numbers are also accepted
	Number *string `json:"number,omitempty"`
	// PushTokens are required for mobile push notifications
	PushTokens []PushToken `json:"pushTokens,omitempty"`
	// WebPushTokens are required for web push notifications
	WebPushTokens []WebPushToken `json:"webPushTokens,omitempty"`
	// Timezone is the user's timezone (optional)
	Timezone *string `json:"timezone,omitempty"`
	// LastSeenTime is when the user was last seen (optional)
	LastSeenTime *string `json:"lastSeenTime,omitempty"`
	// SlackChannelName is the user's Slack channel name (optional)
	SlackChannelName *string `json:"slackChannelName,omitempty"`
	// SlackToken is the user's Slack OAuth token (optional)
	SlackToken *SlackToken `json:"slackToken,omitempty"`
	// UpdatedAt is when the user was last updated (optional)
	UpdatedAt *string `json:"updatedAt,omitempty"`
	// CreatedAt is when the user was created (optional)
	CreatedAt *string `json:"createdAt,omitempty"`
}

User represents a user in the NotificationAPI system

type WebPushToken

type WebPushToken struct {
	// Sub is the push subscription
	Sub PushSubscription `json:"sub"`
}

WebPushToken represents a web push token

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL