Cegid UR scripts
Reference of the Cegid UR customer mapper and connection interceptor scripts: registration without a slot, handlers and an authentication example.
Two scripts adjust the Cegid UR connector. The mapper maps customer data between Cegid UR and the wallet account. The connection interceptor sees every SOAP call the connector makes and can add the authentication header, because the connector configuration holds no credential. This page is the reference for extensions.cegid.ur.mapper and extensions.cegid.ur.connectionInterceptor. The connector is described on the Cegid UR connector page; the rules shared by every connector script are in Connector scripts. Cegid UR is a different connector from Cegid Y2, with different member names.
Registration
Key
Methods (required in bold)
extensions.cegid.ur.mapper
MapFromUR, MapToUR
extensions.cegid.ur.connectionInterceptor
OnBeforeRequest, OnAfterRequest
Cegid UR has no script slot and no slot API. The scripts are ordinary files under server/scripts/, with any name, edited in the advanced configuration. When no script is registered for a key, the default behavior applies.
When it runs
MapFromUR
At the end of the customer read (the ur.customer customer provider), after the standard mapping has written firstName, lastName, email, loyaltyId, loyaltyPoints and debug.ur.customer
MapToUR
In the urCustomer registration step, before a customer is created or updated. The customer is then read back, so MapFromUR runs too
Interceptor
On every SOAP call to Cegid UR, so anything slow in it slows the whole connector
Handlers
MapFromUR
data, account
nothing
Optional
Synchronous
MapToUR
account, data
nothing
Optional
Synchronous
OnBeforeRequest
url, headers, content
a promise of { Url, Headers, Content }
Required
Asynchronous: declare it async
OnAfterRequest
soapAction, content
a promise of the response body, as a string
Required
Asynchronous: declare it async
Mapper.
datais the Cegid UR customer (CustomerType). Its members are camelCase and come from the vendor contract:data.person.firstName, unlike the PascalCase members of Cegid Y2. The raw customer read from Cegid UR is visible underdebug.ur.customer. InMapToUR,datais a new customer built from the account (id,firstName,lastName,email), not the record stored in Cegid UR. Either method may be omitted, so a script that customizes one direction registers only that one. Both change their arguments in place, and anasyncmapper is not awaited.Interceptor.
OnBeforeRequestreturns{ Url, Headers, Content }and the connector replaces the URL and all headers with what it returns: copy the received headers, add what is needed, and keepSOAPAction. Only the first value of each request header is passed in.OnAfterRequestreceives every response body of the Cegid UR HTTP client, whatever its content, and returns it as a string. Both methods are required.
Errors and edge cases
An interceptor method is missing: the call fails with
method <Name> missingon the first Cegid UR call.The interceptor returns headers without
SOAPAction: the request is sent without it and the call then fails with an error, because the response step reads that header.A script throws: the error is not caught and fails the Cegid UR call, and with it the customer read or the registration step.
The secret is missing:
getSecretreturnsnulland the header would carry no key. Check the value and fail with a clear message.
Example
The interceptor reads the key from the secret store and adds it to every call. The header name X-Api-Key and the secret name are placeholders: use the ones Cegid UR expects for the brand's environment.
The mapper below customizes one direction only:
Common pitfalls
Y2 member names are used on a UR object: UR members are camelCase.
The interceptor is registered with only one of its two methods.
The Cegid UR rate limiter is disabled unless configured: set the limit in the configuration rather than in a script.
Last updated

