AppMage

BillableFeatureRpc

This endpoint group provides JSON-RPC methods for creating, updating, archiving, retrieving, and listing billable features. It also exposes a field-value lookup helper intended for reference fields in DataForm.

Endpoints

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

This method creates a new billable feature template.

  • Request Body:

    {
      "method": "BillableFeatureRpc.create",
      "params": {
        // fields defined by `BillableFeatureSchema` except `_id`, `createdAt`, and `updatedAt`
      }
    }
  • Parameters:

    Name Type Required Description
    params Object Yes Request payload validated against BillableFeatureSchema with _id, createdAt, and updatedAt omitted. The exact field structure is defined by the imported schema and was not inspected here.
  • Response:

    {
      "success": true,
      "data": {
        // return value from `BillableFeatureService.createFeature(data)`
      }
    }
  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "BillableFeatureRpc.create",
        "params": {
          "...": "..."
        }
      }'

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

This method updates an existing billable feature.

  • Request Body:

    {
      "method": "BillableFeatureRpc.update",
      "params": {
        "_id": "string",
        // any additional fields allowed by `BillableFeatureSchema.partial()`
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes Identifier of the billable feature to update.
    params Object Yes Partial billable feature data merged into the update payload and validated by BillableFeatureSchema.partial().extend({ _id: z.string() }). The remaining editable fields were not inspected from the imported schema.
  • Response:

    {
      "success": true,
      "data": {
        // return value from `BillableFeatureService.updateFeature(_id, updates)`
      }
    }
  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "BillableFeatureRpc.update",
        "params": {
          "_id": "FEATURE_ID",
          "...": "..."
        }
      }'

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

This method archives a billable feature and returns a confirmation message.

  • Request Body:

    {
      "method": "BillableFeatureRpc.delete",
      "params": {
        "_id": "string"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes Identifier of the billable feature to archive.
  • Response:

    {
      "success": true,
      "data": {
        "success": true,
        "message": "Feature archived."
      }
    }
  • Example (cURL):

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

POST /api/rpc (Method: BillableFeatureRpc.findById)

This method retrieves a single billable feature by its ID.

  • Request Body:

    {
      "method": "BillableFeatureRpc.findById",
      "params": {
        "_id": "string"
      }
    }
  • Parameters:

    Name Type Required Description
    _id String Yes Identifier of the billable feature to retrieve.
  • Response:

    {
      "success": true,
      "data": {
        // return value from `BillableFeatureService.getFeatureById(_id)`
      }
    }
  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "BillableFeatureRpc.findById",
        "params": {
          "_id": "FEATURE_ID"
        }
      }'

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

This method lists active billable features with pagination and sorting options.

  • Request Body:

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

    Name Type Required Description
    filter Any Yes Filter object passed through to BillableFeatureService.listFeatures(...). The accepted shape was not inspected.
    sort Any Yes Sort configuration passed through to BillableFeatureService.listFeatures(...). The accepted shape was not inspected.
    page Number Yes Page number. Used to calculate the skip value as (page - 1) * pageSize.
    pageSize Number Yes Number of records per page. Used as the limit value.
  • Response:

    {
      "success": true,
      "data": {
        // return value from `BillableFeatureService.listFeatures(filter, options)`
      }
    }
  • Example (cURL):

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

POST /api/rpc (Method: BillableFeatureRpc.getFieldValues)

This method provides a list of billable features formatted for reference fields in DataForm.

  • Request Body:

    {
      "method": "BillableFeatureRpc.getFieldValues",
      "params": {
        "fieldName": "string",
        "reference": {
          "valueField": "string",
          "displayField": "string",
          "filter": {}
        }
      }
    }
  • Parameters:

    Name Type Required Description
    fieldName String Yes Name of the field requesting reference values. The method accepts it but does not use it in the shown implementation.
    reference Object Yes Reference configuration used to map feature records into { value, label } pairs.
    reference.valueField String Yes Property name used as the returned value.
    reference.displayField String Yes Property name used as the returned label.
    reference.filter Object No Optional filter passed to BillableFeatureService.listFeatures(...). If omitted, an empty object is used.
  • Response:

    {
      "success": true,
      "data": [
        {
          "value": "string",
          "label": "string"
        }
      ]
    }
  • Example (cURL):

    curl -X POST "${APP_BASE_URL}/api/rpc" \
      -H "Content-Type: application/json" \
      -d '{
        "method": "BillableFeatureRpc.getFieldValues",
        "params": {
          "fieldName": "featureId",
          "reference": {
            "valueField": "_id",
            "displayField": "name",
            "filter": {}
          }
        }
      }'

Request Flow

graph TD A[Client sends POST /api/rpc] --> B{method} B --> C[BillableFeatureRpc.create] B --> D[BillableFeatureRpc.update] B --> E[BillableFeatureRpc.delete] B --> F[BillableFeatureRpc.findById] B --> G[BillableFeatureRpc.getData] B --> H[BillableFeatureRpc.getFieldValues] C --> I[BillableFeatureService.createFeature] D --> J[BillableFeatureService.updateFeature] E --> K[BillableFeatureService.archiveFeature] F --> L[BillableFeatureService.getFeatureById] G --> M[BillableFeatureService.listFeatures] H --> M