Online Registration
The following documentation describes how to set up, via API, an online registration, particularly for a customer who is already a prospect in a club.
Check that a user does not already exist
In Resamania, a contact is unique by their email address: it is impossible to use the same email address twice for the same clientToken.
If you attempt to create a contact whose email address is already in use for that clientToken, you will receive an api.error.contact.email-already-used error.
In a standard user journey, it is therefore recommended to ask the user for their email address and verify their existence as follows:
----------------------------------------------------[--------v--------]
curl --location 'https://{{baseUrl}}/{{clientToken}}/contacts?email={{email}}' \
--header 'accept: application/json, text/plain, */*' \
--header 'authorization: Bearer {{bearer}}' \
--header 'x-user-club-id: {{clubId}}' \
--header 'x-user-network-node-id: {{networkNodeId}}'{
"@context": "/demoapi/contexts/Contact",
"@id": "/demoapi/contacts",
"@type": "hydra:Collection",
"hydra:member": [
{
"@id": "/demoapi/contacts/2974221",
"@type": "http://schema.org/Person",
"number": "C2974221",
"address": {
"@id": "/demoapi/addresses/14284392",
"@type": "Address",
"addressCountry": "France",
"addressCountryIso": "FR",
"addressLocality": "NICE",
"postalCode": "06000",
"streetAddress": "1 The Street",
"supplement": ""
},
"birthDate": "1990-01-01",
"email": "[email protected]",
"familyName": "John",
"gender": null,
"givenName": "Test",
// ...
}
],
//...
}Warning
The email provided as a parameter must be URL-encoded: [email protected] must be john%2Btest%40email.tld
Case of http://contactclientcredentials authentication
For this authentication mode, you must have a contactId beforehand. To search for a contact, you will need to use another oAuth client with broader authorizations. We do not mix grant_type values with a contact scope with those having a broader scope for security reasons.
Case of club chains
The above example works well in situations where the clientToken contains only a single club.
When a clientToken contains multiple clubs (see dedicated documentation), you may need to search for a contact across the network using the endpoint /:clientToken/network/contact_search?email=.
This endpoint works the same way as the GET /:clientToken/contacts?email= described above, with the differences that:
- results span all clubs in the network.
- results are a limited view of the contact's data.
{
"@context": "/demoapi/contexts/Contact",
"@id": "/demoapi/contacts",
"@type": "hydra:Collection",
"hydra:member": [
{
"@id": "/demoapi/contacts/10296819",
"@type": "http://schema.org/Person",
"number": "ZM14314719",
"birthDate": "1992-04-22",
"familyName": "Doe",
"gender": "female",
"givenName": "Justine",
"pictureId": null,
"clubId": "{{clubId}}}",
"state": "old_client",
"partialPhoneNumber": "******1615"
}
],
"hydra:totalItems": 1,
// ..
}If it returns a response, you should retrieve the clubId of the relevant contact if you wish to proceed with a contact migration (see below) in the case where the contact is prospect.
A non-prospect contact present in another club cannot be migrated to a different club.
Create a new user
When creating a new user, they can be assigned either the status (state) temp if you want to create a temporary contact (see below), or prospect (default value).
Required fields
By default, the mandatory fields are email, familyName, givenName and birthDate. Whenever you need to make a sale for this contact, you will also need to provide their postal address (address). If there is a contract or mandate to sign, you will also need to provide the mobile phone number (mobile).
Other fields may be required
- Required fields sometimes depend on the
clientToken. If additional fields are requested (e.g. you receive arequirederror), this generally comes from the client configuration. - Contact your client to find out which fields must be required for your use case: a field you do not provide will be requested when an employee tries to edit the user's profile in Resamania.
- If the required fields configuration needs to be adapted for contacts coming from your application while maintaining obligations in Resamania, contact the API team to create a dedicated contact profile field configuration.
Contact source
It is important for your client to know the origin of their contacts, and useful for you that they can attribute contact creation to you.
To do this, contact profiles have a sourceId field that references a source. We refer you to the following api-reference to find out how to list and create a source.
Note: you will need to recreate this source when you go to production.
Creation request
Retrouvez ce scénario dans notre collection Bruno
Gagnez du temps dans votre implémentation en observant l'enchaînement des appels et en récupérant les requêtes directement depuis Bruno.
curl --location 'https://{{baseUrl}}/{{clientToken}}/contacts' \
--header 'accept: application/json, text/plain, */*' \
--header 'authorization: Bearer {{bearer}}' \
--header 'x-user-club-id: {{clubId}}' \
--header 'x-user-network-node-id: {{networkNodeId}}' \
--header 'Content-Type: application/json' \
--data '{
"familyName":"DEV",
"givenName":"Test",
"gender":"male",
"clubId": "{{clubId}}",
"birthDate":"2000-01-01",
"email": "{{fakeEmail}}",
"mobile":"+336123456789",
"sourceId": "{{sourceId}}",
"address": {
"addressCountry":"France",
"addressLocality":"Toulon",
"streetAddress":"52 chemin du test",
"postalCode":"83390"
}
}'{
"@context": "\/demoapi\/contexts\/Contact",
"@id": "\/demoapi\/contacts\/2974340", -- The contact id to reuse in your subsequent calls
"@type": "http:\/\/schema.org\/Person",
"number": "C2974340",
"address": {
"@id": "\/demoapi\/addresses\/14285613",
"@type": "Address",
"addressCountry": "France",
"addressCountryIso": "FR",
"addressLocality": "Toulon",
"postalCode": "83390",
"streetAddress": null,
"supplement": ""
},
"birthDate": null,
"email": "{{email}}",
"familyName": "Doe",
"gender": null,
"givenName": "John",
"pictureId": null,
"tags": [],
"clubId": "{{clubId}}",
"landline": null,
"mobile": null,
// ...
"parentalIdentificationValidated": false,
"state": "prospect",
"initialSalepersonId": null,
//...
}Case of a customer already a prospect in a club
It is impossible to create a new contact when that contact is already known to a club.
However, some external services need to create a new contact even though one already exists.
We have added two API endpoints to address this issue.
Retrouvez ce scénario dans notre collection Bruno
Gagnez du temps dans votre implémentation en observant l'enchaînement des appels et en récupérant les requêtes directement depuis Bruno.
Glossaire des notions clés
Avant d'aller plus loin, soyons certains que nous parlons des mêmes notions.
Le contact prospect
Il s’agit du client existant.
Son statut doit êtretemp, on le nommera contact source dans ce document.
Le contact temporaire
This is the customer to be registered.
Their status must beprospect; they will be referred to as the target contact in this document.
The club
This is the club where the target contact's information will be moved.
The sale
A sale corresponds to a cart. It groups a list of items that will then be sold to the contact.
Macro process and prerequisites
As indicated above, you must know the following information:
- the source contact
- the target contact
- the club
- the sale
The contact information transfer process is done in two calls:
- A first call to migrate the data from the source contact to the target contact:
Information migration - A second call to update the sale so that the linked contact's information is refreshed:
Updating information in the sale
Information migration
This API endpoint is used to migrate information from the source contact to the target contact.
Reminder:
- The source contact must have
prospectstatus - The target contact must have
tempstatus - The source contact's club must be different from the target contact's club
Important: for this call, you must be authenticated as the source contact
PUT /{clientToken}/contacts/{contactSourceId}/migrate
| parameter | description | example |
|---|---|---|
targetContactId | Contact identifier as IRI | /{clientToken}/clubs/1 |
targetClubId | Club identifier as IRI | /{clientToken}/clubs/1 |
Example
Migration of Contact 1 (prospect) to Contact 2 (temporary) / Club 1
Query
PUT /{clientToken}/contacts/1/migrate
Body
{
"targetContactId": "/{clientToken}/contacts/2",
"targetClubId": "/{clientToken}/clubs/1"
}Response 204 Migration processed
Updating information in the sale
This API endpoint is used to update the contact information within the sale.
The updated information includes:
- The contact identifier:
contactId - The contact number:
contactNumber - The contact last name:
contactFamilyName - The contact first name:
contactGivenName
PUT /{clientToken}/sale/{saleId}/update_contact
Example
Updating the information of sale 33
Query
PUT /{clientToken}/sale/33/update_contact
Response 204 Process finished