Pet Profiles & Images
A pet profile belongs to a space and carries the pet’s details (PetSpecies.CAT / DOG), a profile image, and the reference images the recogniser learns from.
All calls are on InstaVision.petService.
Pre-requisite: The user has to be signed in to perform the following operations.
Get pet profiles
To get the list of pet profiles for a space, the following method can be used:
spaceId(required): The space ID of the device.
InstaVision.petService.getProfiles(
spaceId = "spaceId",
onSuccess = { profiles ->
// The list of PetProfile objects
},
onError = { error ->
// The error object contains the error code and message
}
)
Create a pet profile
To create a pet profile, the following method can be used:
spaceId(required): The space ID of the device.request(required): ACreatePetRequestcontaining the petname,speciesandage.
The species value is the type of a PetSpecies ("Cat" or "Dog"). Use PetSpecies.fromValue(...) to turn a species string received from the API back into the enum.
InstaVision.petService.createProfile(
spaceId = "spaceId",
request = CreatePetRequest(
name = "Buddy",
species = "Dog",
age = Age(years = 2, months = 3)
),
onSuccess = { profile ->
// The created PetProfile object
},
onError = { error ->
// The error object contains the error code and message
}
)
Deprecated An older overload of
createProfile(spaceId, name, species: PetSpecies, onSuccess, onError)also exists but is deprecated in favor of theCreatePetRequestoverload above.
Get a pet profile
To get a single pet profile, the following method can be used:
spaceId(required): The space ID of the device.petId(required): The pet ID.
InstaVision.petService.getProfile(
spaceId = "spaceId",
petId = "petId",
onSuccess = { profile ->
// The PetProfile object
},
onError = { error ->
// The error object contains the error code and message
}
)
Update a pet profile
To update a pet profile, the following method can be used:
spaceId(required): The space ID of the device.petId(required): The pet ID.request(required): AnUpdatePetRequestcontaining the fields to update (name,species,profileImageId,age), all optional.
InstaVision.petService.updateProfile(
spaceId = "spaceId",
petId = "petId",
request = UpdatePetRequest(
name = "Buddy",
species = "Dog",
profileImageId = "imageId1",
age = Age(years = 2, months = 3)
),
onSuccess = { profile ->
// The updated PetProfile object
},
onError = { error ->
// The error object contains the error code and message
}
)
Delete a pet profile
To delete a pet profile, the following method can be used:
spaceId(required): The space ID of the device.petId(required): The pet ID.
InstaVision.petService.deleteProfile(
spaceId = "spaceId",
petId = "petId",
onSuccess = {
// Called when the profile is deleted successfully
},
onError = { error ->
// The error object contains the error code and message
}
)
Upload pet images
To upload images for a pet, the following method can be used:
spaceId(required): The space ID of the device.petId(required): The pet ID.images(required): The list ofBitmapimages to upload.
InstaVision.petService.uploadImages(
spaceId = "spaceId",
petId = "petId",
images = listOf(bitmap),
onSuccess = { imageIds ->
// The list of uploaded image IDs
},
onError = { error ->
// The error object contains the error code and message
}
)
Attach images to a pet profile
To attach previously uploaded images to a pet profile, the following method can be used:
spaceId(required): The space ID of the device.petId(required): The pet ID.imageIds(required): The list of image IDs to attach.profileImageId(required, nullable — passnullto leave unchanged): The image ID to set as the profile image.
InstaVision.petService.attachImagesToProfile(
spaceId = "spaceId",
petId = "petId",
imageIds = listOf("imageId1", "imageId2"),
profileImageId = "imageId1",
onSuccess = { profile ->
// The updated PetProfile object
},
onError = { error ->
// The error object contains the error code and message
}
)
Detach images from a pet profile
To detach images from a pet profile, the following method can be used:
spaceId(required): The space ID of the device.petId(required): The pet ID.imageIds(required): The list of image IDs to detach.
InstaVision.petService.detachImagesFromProfile(
spaceId = "spaceId",
petId = "petId",
imageIds = listOf("imageId1", "imageId2"),
onSuccess = {
// Called when the images are detached successfully
},
onError = { error ->
// The error object contains the error code and message
}
)