Affect device to site
1. Check if the device is already affected to a site
To check if the device is already affected to a site, you need to make a request to the Emerit API.
query IS_DEVICE_AFFECTED_TO_SITE($deviceId: String!) {
isDeviceAlreadyAffected(deviceId: $deviceId)
}
2. Affect the device to a site
From the siteId you found on the GetMyIntegratorInfos query, you can now affect the device to the site.
mutation AFFECT_DEVICE_TO_SITE($siteId:String!, $input: AffectDeviceSiteInput!) {
affectDeviceToSite(siteId: $siteId, input: $input) {
id
uniqueIdNumber
site {
id
name
}
createdAt
updatedAt
}
}
Here an example of graphql variables for this request
{
"siteId": "6cfcafc3-a6a5-4292-bb36-aa095c435c6a",
"input" : {
"uniqueIdNumber": "123456789",
"infos" : {
"username" : "Username on the watch"
}
}
}
In the response, you will get the device id, the uniqueIdNumber, the site id, the site name, the creation date and the update date of the device.
Here an example of response:
{
"data": {
"affectDeviceToSite": {
"id": "6cfcafc3-a6a5-4292-bb36-aa095c435c6a",
"uniqueIdNumber": "123456789",
"site": {
"id": "6cfcafc3-a6a5-4292-bb36-aa095c435c6a",
"name": "Site name"
},
"createdAt": "2021-09-29T14:00:00.000Z",
"updatedAt": "2021-09-29T14:00:00.000Z"
}
}
}