Problem/Motivation
Sites using Amilia (Smart Rec) for membership management need a way to validate whether a given email address belongs to an active member. One application would be so that Virtual Y (yusaopeny_gated_content) can gate content to members only.
The Amilia API provides a "Persons in a network by email" endpoint that can perform this lookup in real time using the existing JWT Bearer token authentication already present in YmcaSmartRecAmiliaApiClient.
Steps to reproduce
N/A — this is a feature addition, not a bug fix.
Proposed resolution
- New constant in
YmcaSmartRecAmiliaApiClient:
SMART_REC_API_NETWORK_PERSONS_PATH = 'network/%s/persons' - New config setting
smart_rec_network_idadded to the module
settings form and config schema. - New method
getPersonsByEmail(string $email): array|false- Builds the endpoint URL:
GET /api/v3/{language}/network/{networkId}/persons?email={email} - Authenticates with the existing
smartRecAmiliaAuthorizeRequest()mechanism - Returns the decoded
Itemsarray on success, orFALSEif no
record is found or an error occurs - Logs a watchdog warning and returns
FALSEifsmart_rec_network_id
is not configured
- Builds the endpoint URL:
Remaining tasks
- Implement and review the changes above
- Add
smart_rec_network_idto the settings form and config schema - Manual testing against a real Amilia network
- Create companion issue in yusaopeny_gated_content for the
openy_gc_auth_smart_recauth provider that consumes this new method
User interface changes
New Network ID field on the Smart Rec settings form (/admin/config/ymca-settings/smart-rec).
API changes
New public method on YmcaSmartRecAmiliaApiClient (service openy_smart_rec.smart_rec_api_client):
public function getPersonsByEmail(string $email): array|false
Data model changes
New config key smart_rec_network_id added to
openy_smart_rec.settings.
Issue fork openy_smart_rec-3589797
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
froboyComment #4
froboyComment #5
podaroktnx