Pet Services
Pet services are a set of APIs that allow you to manage pet profiles, images and activity insights.
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
}
)
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
}
)
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.
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.
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(optional): 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
}
)
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
}
)
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
}
)
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
}
)
Get recommended images
To get the recommended profile images for a pet, the following method can be used:
spaceId(required): The space ID of the device.petId(required): The pet ID.
InstaVision.petService.getRecommendations(
spaceId = "spaceId",
petId = "petId",
onSuccess = { recommendations ->
// The list of PetProfileImage objects
},
onError = { error ->
// The error object contains the error code and message
}
)
Update recommended image feedback
To submit feedback on recommended images for a pet, the following method can be used:
spaceId(required): The space ID of the device.petId(required): The pet ID.recommendations(required): ARecommendedImagesFeedbackRequestcontaining a list ofImageFeedback(idandfeedback).
InstaVision.petService.updateRecommendations(
spaceId = "spaceId",
petId = "petId",
recommendations = RecommendedImagesFeedbackRequest(
feedbacks = listOf(ImageFeedback(id = "imageId1", feedback = true))
),
onSuccess = {
// Called when the feedback is submitted successfully
},
onError = { error ->
// The error object contains the error code and message
}
)
Deprecated An older overload of
updateRecommendations(spaceId, petId, recommendations: List<String>, onSuccess, onError)also exists but is deprecated in favor of theRecommendedImagesFeedbackRequestoverload above.
Get pet activity summary
To get a pet’s activity summary over a time range, the following method can be used:
spaceId(required): The space ID of the device.petId(required): The pet ID.startDate(required): The start of the time range, in epoch milliseconds.endDate(required): The end of the time range, in epoch milliseconds.
InstaVision.petService.getActivitySummary(
spaceId = "spaceId",
petId = "petId",
startDate = 1700000000000,
endDate = 1700086400000,
onSuccess = { summaries ->
// The list of PetActivitySummary objects
},
onError = { error ->
// The error object contains the error code and message
}
)
Get pet activity insight
To get an AI-generated activity insight for a pet, the following method can be used:
spaceId(required): The space ID of the device.petId(required): The pet ID.
InstaVision.petService.getActivityInsight(
spaceId = "spaceId",
petId = "petId",
onSuccess = { insight ->
// The insight text (String)
},
onError = { error ->
// The error object contains the error code and message
}
)