Skip to content

Conversation

@ufundo
Copy link
Contributor

@ufundo ufundo commented Jan 26, 2026

I was experimenting with adding api4 support to regex analyser.

The config structure is a bit different to the existing actions. I was trying to make it as flexible as possible, whilst avoiding string parsing.

One big advantage for me is moving from ids to names for custom field matching.

It is working nicely for me with a rule configured like:

       {
          "comment": "Look for previous contribution with matching bank name and amount",
          "action": "api4",
          "api4": {
            "entity": "Contribution",
            "action": "get",
            "params": {
              "limit": 1,
              "orderBy": {
                "receive_date": "DESC"
              },
              "where": [
                [
                  "Donor_Information.Bank_Name",
                  "=",
                  "@purpose"
                ],
                [
                  "total_amount",
                  "=",
                  "@btx.amount"
                ]
              ]
            },
            "result_map": {
              "previous_contribution_id": "id",
              "contact_id": "contact_id"
              "financial_type_id": "financial_type_id",
            }
          }
        },

Interested in what you think of something like this @jensschuppe @bjendres ? :)

@jensschuppe
Copy link
Collaborator

Since this is just adding functionality, no objections conceptually 👍
Let's add documentation for this new action, see the docs for the api action as a reference.

We might consider naming the attribute for the API params params (and make that a global rule), but that's just a quick thought. Naming the attribute the same as the respective action might also be fine, although we should avoid attribute name conflicts and this is the first time an action adds another attribute for extra params.

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.

2 participants