Omnix

AudienceRpc

This RPC group provides audience list management operations for the Omnix application. It exposes methods for retrieving audience records, creating new audiences, updating existing audiences, and deleting audiences. The implementation delegates persistence and filtering to AudienceService, and all operations are scoped by subscriptionId in the underlying service.

Endpoints

POST /api/rpc (Method: AudienceRpc.getData)

  • Description: Returns a paginated audience list by passing the provided filter and sorting options to the underlying audience service.

  • Request Body:

    {
      "method": "AudienceRpc.getData",
      "params": {
        "filter": {},
        "sort": {},
        "page": 1,
        "pageSize": 20
      }
    }
  • Parameters:

    Name Type Required Description
    filter Any No Optional filter object forwarded to the service layer.
    sort Any No Optional sort definition forwarded to the service layer.
    page Number No Optional page number used for pagination.
    pageSize Number No Optional page size used for pagination.
  • Response:

    {
      "success": true,
      "data": {
        "data": [],
        "totalCount": 0
      }
    }

    The returned payload is the direct result of AudienceService.getAudiences(...), which returns an object containing a data array and a totalCount value.

  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "AudienceRpc.getData",
        "params": {
          "filter": {},
          "sort": {},
          "page": 1,
          "pageSize": 20
        }
      }'

POST /api/rpc (Method: AudienceRpc.create)

  • Description: Creates a new audience record.

  • Request Body:

    {
      "method": "AudienceRpc.create",
      "params": {
        "...": "Audience fields defined by the schema"
      }
    }
  • Parameters:

    Name Type Required Description
    data Object Yes Audience data validated against OmniAudienceSchema with _id and subscriptionId omitted. Exact required and optional fields are defined by OmniAudienceSchema.
  • Response:

    {
      "success": true,
      "data": {
        "...": "Created audience record"
      }
    }

    The method returns the value produced by AudienceService.createAudience(...). That service stores the audience with the current subscriptionId, createdAt, and updatedAt fields, and returns the created record with _id as a string.

  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "AudienceRpc.create",
        "params": {
          "...": "Audience fields defined by the schema"
        }
      }'

POST /api/rpc (Method: AudienceRpc.update)

  • Description: Updates an existing audience record.

  • Request Body:

    {
      "method": "AudienceRpc.update",
      "params": {
        "_id": "audience-id",
        "...": "Audience fields to update"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes Audience identifier to update.
    data Object Yes Audience fields validated against OmniAudienceSchema.partial() with _id required as a string. The schema allows partial updates, but exact field constraints come from OmniAudienceSchema.
  • Response:

    {
      "success": true,
      "data": {
        "...": "Updated audience record"
      }
    }

    The method returns the updated audience document fetched after the database update is applied.

  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "AudienceRpc.update",
        "params": {
          "_id": "audience-id",
          "...": "Audience fields to update"
        }
      }'

POST /api/rpc (Method: AudienceRpc.delete)

  • Description: Deletes an audience record by identifier.

  • Request Body:

    {
      "method": "AudienceRpc.delete",
      "params": {
        "_id": "audience-id"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes Audience identifier to delete.
  • Response:

    {
      "success": true,
      "data": {
        "success": true
      }
    }

    The method returns an object with a boolean success flag indicating whether a record was deleted.

  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "AudienceRpc.delete",
        "params": {
          "_id": "audience-id"
        }
      }'