API Namespace plugin: subdomain events V1 - restarone/violet_rails GitHub Wiki

What is a Violet Rails API plugin?

To understand what a plugin is, please see more on the API system

subdomain/events V1

Subdomain events version 1 is a service that uses the subdomain/event API Namespace to:

  1. Save events that happen on a subdomain (eg: email recieved, forum thread/post created etc)
  2. Trigger events based on the above events

installation

To install, simply create the API Namespace object as you see here. This can be done through the web console:

For your convenience the following one liner has been created:

Apartment::Tenant.switch('schema'){ ApiNamespace.create!(name: 'subdomain/event',slug: 'subdomain_events',version: 1,requires_authentication: true,namespace_type: 'create-read-update-delete',properties: {    model_definition: {record_id: {type: "integer",validations: {allow_blank: false,primary_key: true,unique: true}},record_type: {type: "string",validations: {allow_blank: false}}}}) }

examples

The action workflow

Screenshot from 2022-05-01 11-56-01

Hooking into the action lifecycle

Screenshot from 2022-07-03 17-23-15

Since the create action is fired on the subdomain/events namespace, we can use it to talk to external services and do a variety of things. See here for an on how to send a message to discord