Adoption Website Integration
This article details how an adoption website can retrieve Animals from AnimalOS to be displayed using the Salesforce REST API.
Retrieve Animals Available For Adoption
This API method will retrieve Animals that are available for adoption in AnimalOS.
https://documenter.getpostman.com/view/10160838/UzJSJCzh
Sample Request (Node.js - Request)
var request = require('request');
var options = {
'method': 'GET',
'url': '{{SF_API_ENDPOINT}}/services/apexrest/RetrieveAnimals?AnimalStatus=Adopted;Euthanised&LastModifiedDate=2022-10-03&Time=12:00&Limit=100&LastRecordId=a6e8u0000000JmtAAE&StatusChangedDate=2022-10-25&GalleryChangedDate=2022-10-25&AnimalType=Dog;Puppy&LocationName=Petbarn Belconnen’,
'headers': {
'Authorization': '{{access_token}}'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
Replace {{Variable_Name}} with the variable value provided in the table above.
{{access_token}} must be set. The table contains samples of these variables.
API Parameters
PARAM | EXAMPLE | NOTES |
---|---|---|
AnimalStatus (for many statuses separate values by semicolons) | Available For Adoption;Adopted
Lost & Found contains Stray Hold, Lost
|
|
LastModifiedDate (YYYY-MM-DD) | 2021-09-02 |
|
Time (HH:MM) | 12:00 |
|
Limit | 100 |
|
LastRecordId | a6e8u0000000JmtAAE | LastRecordId parameter must be set as the Id of the last retrieved record. Then on the next request, records after that record will be retrieved. totalNumberOfRecords and recordsLeft attribute were added to response to identify how many requests to make Demo in Postman |
StatusChangedDate (YYYY-MM-DD) | 2022-10-25 |
|
GalleryChangedDate (YYYY-MM-DD) | 2022-10-25 |
|
AnimalId | a6e8u0000000ftrAAA | If AnimalId parameter is not empty, all other parameters will be ignored and Animal record with Salesforce Id = AnimalId will be retrieved |
AnimalType (for many statuses separate values by semicolons) | Cat; Dog |
|
LocationName | Weston |
|
Sample Response
{
"totalNumberOfRecords": 4199,
"recordsLeft": 3998,
"animals": [
{
"animalos__Primary_Breed__r": {
"Name": "German Shepherd",
"Id": "a3cIo000000DCALIA4"
},
"OneDrive_Files__r": [
{
"Thumbnail_URL__c": "https://australiaeast1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YWxsc2l0ZXMud3JpdGUgYWxscHJvZmlsZXMucmVhZCBhbGxwcm9maWxlcy5yZWFkIGFsbHByb2ZpbGVzLndyaXRl.zT6bzLIn7fRl3TVIMU_Zck7rvurDGOOkS_rIV19cjmI%26version%3DPublished&width=800&height=800&cb=63857329251",
"Name": "Screenshot 2024-07-23 at 13.36.19.png",
"Is_Primary__c": false,
"Is_Deleted__c": false,
"Folder_Name__c": "A100023_staging-photos",
"File_ID__c": "01UUHX7T7QULMDAPA4PZALKS7WRKKO6K57",
"Id": "a3wIo000000GpA7IAK",
"animalos_Animal__c": "a3aIo000000XzM4IAK"
}
],
"animalos__Type__c": "Dog",
"animalos__Status__c": "Returned Home",
"animalos__Size__c": "Large",
"animalos__Secondary_Colour__c": "Gold",
"animalos__Primary_Colour__c": "Black",
"animalos__Primary_Breed__c": "a3cIo000000DCALIA4",
"animalos__Neutered_Spayed__c": false,
"animalos__Gender__c": "Male",
"animalos__Date_of_Birth__c": "2005-11-09",
"animalos__Animal_Name__c": "Max",
"Senior_Pet__c": true,
"Name": "A100023",
"Longterm_Resident__c": false,
"LastModifiedDate": "2024-07-25T16:15:12.000Z",
"Id": "a3aIo000000XzM4IAK",
"Age_for_Adoption_Website__c": "18 Years 8 Months",
"Adoption_EOI_Required__c": false
}
]
}
Get Access Token Request
For setting the {{access_token}} variable the Get Access Token request must be sent.
Sample Get Access Token request (Node.js - Request)
var request = require('request');
var options = {
'method': 'POST',
'url': '{{AccessTokenURL}}',
'headers': {
},
form: {
'grant_type': 'password',
'client_id': '{{SF_Client_ID}}',
'client_secret': '{{SF_Client_Secret}}',
'username': '{{SF_Username}}',
'password': '{{SF_Password}}'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
Sample Response
Get Shelters
A collection of queries https://documenter.getpostman.com/view/10160838/VUqmven9
Sample RetrieveShelters Request (Node.js - Request)
Replace {{Variable_Name}} with the variable value provided in the table above.
To enter required date in request replace YYYY-MM-DD with your date.
Example: 2022-08-17
Request Parameters
PARAM | EXAMPLE | NOTES |
LastModifiedDate (YYYY-MM-DD) | 2021-09-02 |
|
Sample Response