Skip to content

Instantly share code, notes, and snippets.

@sfboss
Created June 13, 2023 05:30
Show Gist options
  • Save sfboss/c053f739107fd032377b7f148e212361 to your computer and use it in GitHub Desktop.
Save sfboss/c053f739107fd032377b7f148e212361 to your computer and use it in GitHub Desktop.
ipy
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"toc_visible": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"source": [
"# Contact Tracing"
],
"metadata": {
"id": "5GR5KIXeddGt"
}
},
{
"cell_type": "markdown",
"source": [
"## Salesforce REST API Contact Tracing Functionality\n",
"\n",
"The `/v58.0/contact-tracing` endpoint in the Salesforce REST API provides functionality related to contact tracing. Contact tracing is the process of identifying individuals who may have come into contact with an infected person to mitigate the spread of diseases or infections.\n",
"\n",
"### Specifications for `/v58.0/contact-tracing` Resource\n",
"\n",
"- HTTP Method: GET\n",
"- Authentication: Requires a valid access token\n",
"- Resource URL: `https://instance.salesforce.com/services/data/v58.0/contact-tracing`\n",
"\n",
"#### Description\n",
"\n",
"The `/v58.0/contact-tracing` resource allows you to retrieve information related to contact tracing, such as contact tracing records, contact tracing configurations, and associated data.\n",
"\n",
"#### Parameters\n",
"\n",
"This resource does not require any additional parameters.\n",
"\n",
"#### Response\n",
"\n",
"The response from the `/v58.0/contact-tracing` endpoint will be a JSON object containing the contact tracing data.\n",
"\n",
"Here's an example response for a GET request to the `/v58.0/contact-tracing` endpoint:\n",
"\n",
"```json\n",
"{\n",
" \"data\": {\n",
" \"contactTracingRecords\": [\n",
" {\n",
" \"id\": \"001xxxxxxxxxxxx\",\n",
" \"name\": \"John Doe\",\n",
" \"contactDate\": \"2023-06-10\",\n",
" \"location\": \"Office Building A\"\n",
" },\n",
" {\n",
" \"id\": \"001yyyyyyyyyyyy\",\n",
" \"name\": \"Jane Smith\",\n",
" \"contactDate\": \"2023-06-09\",\n",
" \"location\": \"Office Building B\"\n",
" }\n",
" ],\n",
" \"contactTracingConfigurations\": [\n",
" {\n",
" \"id\": \"config_1\",\n",
" \"name\": \"Office Tracing\",\n",
" \"enabled\": true\n",
" },\n",
" {\n",
" \"id\": \"config_2\",\n",
" \"name\": \"Customer Tracing\",\n",
" \"enabled\": false\n",
" }\n",
" ]\n",
" }\n",
"}\n"
],
"metadata": {
"id": "KaSOnfG-coQp"
}
},
{
"cell_type": "code",
"source": [
"#@title Use the Contact Tracing API\n",
"import requests\n",
"import json\n",
"\n",
"def get_contact_tracing_data(access_token, instance):\n",
" url = f\"https://{instance}.salesforce.com/services/data/v58.0/contact-tracing\"\n",
" headers = {\n",
" \"Authorization\": f\"Bearer {access_token}\",\n",
" \"Content-Type\": \"application/json\"\n",
" }\n",
"\n",
" response = requests.get(url, headers=headers)\n",
" data = response.json()\n",
"\n",
" # Display data in a pretty way\n",
" print(json.dumps(data, indent=2))\n"
],
"metadata": {
"id": "704ZQBIBdAjF",
"cellView": "form"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"# Get Latest Version"
],
"metadata": {
"id": "rLaWrpQZdiaB"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment