Skip to content

Commit

Permalink
feat(Thrive): Add Creates a new Contact
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentLvr committed Aug 16, 2023
1 parent aeda89f commit 6b41f44
Showing 1 changed file with 252 additions and 0 deletions.
252 changes: 252 additions & 0 deletions Thrive/Thrive_Creates_a_new_Contact.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "3e7304cc-86d9-4920-b11e-b53a054acd27",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"<img width=\"10%\" alt=\"Naas\" src=\"https://landen.imgix.net/jtci2pxwjczr/assets/5ice39g4.png?w=160\"/>"
]
},
{
"cell_type": "markdown",
"id": "e8dafb41-ca03-40cb-9c8b-f0ece13f553e",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"# Thrive - Creates a new Contact"
]
},
{
"cell_type": "markdown",
"id": "1fb896ea-f4fe-4f6a-9ffe-86f94b2abb1e",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**Tags:** #thrive #contact #create #api #v2 #ingest"
]
},
{
"cell_type": "markdown",
"id": "ba462069-6119-4b2d-bf30-a4ec092bb3bf",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**Author:** [Mike Burrell](https://www.linkedin.com/in/michael-j-burrell/)"
]
},
{
"cell_type": "markdown",
"id": "dfb1a8ba-6b06-44ca-be29-c9a38aafb58b",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**Last update:** 2023-08-16 (Created: 2023-08-16)"
]
},
{
"cell_type": "markdown",
"id": "5a1fe7d2-3e8d-4415-b774-ac8179c3ea01",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**Description:** This notebook creates a new contact using the provided attributes. It is usefull for organizations to quickly create contacts using the Thrive API."
]
},
{
"cell_type": "markdown",
"id": "ecc81e1f-6a53-478f-b862-4ceeb48f7d4a",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"**References:**\n- [Thrive API Documentation](https://api.services.thrivetrm.com/api/docs/v2/ingest#!/Contacts/post_contacts)\n- [Thrive API Authentication](https://api.services.thrivetrm.com/api/docs/v2/authentication)"
]
},
{
"cell_type": "markdown",
"id": "926edbbc-1ba6-40a3-af15-eff2ceaa5737",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"## Input"
]
},
{
"cell_type": "markdown",
"id": "f40d8d1d-d14d-4fc6-8c97-244bd2febc7f",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Import libraries"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a9c3f034-be77-4a72-baf7-f61cb9ffb466",
"metadata": {
"papermill": {},
"tags": []
},
"source": "import requests\nimport json",
"outputs": []
},
{
"cell_type": "markdown",
"id": "902314a4-06c2-4231-bb23-c14f3b415e3a",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Setup variables\n- `api_key`: API key provided by Thrive. [Instructions to obtain an API key](https://api.services.thrivetrm.com/api/docs/v2/authentication).\n- `contact_data`: Dictionary containing the contact data."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "563735f9-977f-469a-b353-00df68a44425",
"metadata": {
"papermill": {},
"tags": []
},
"source": "api_key = \"<YOUR_API_KEY>\"\ncontact_data = {\n \"first_name\": \"John\",\n \"last_name\": \"Doe\",\n \"email\": \"[email protected]\",\n \"phone\": \"+11234567890\",\n}",
"outputs": []
},
{
"cell_type": "markdown",
"id": "af7a3996-219d-4a6e-a187-fd9f20d31bde",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"## Model"
]
},
{
"cell_type": "markdown",
"id": "17bf2897-e28d-46b9-8acf-0e58963ee592",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Create contact"
]
},
{
"cell_type": "markdown",
"id": "68dd9a0d-b3f3-410e-8ecf-6e298ed3b462",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"Create a new contact using the provided contact data."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "60a224f6-f0cb-4853-8eff-dca9a7ae95ef",
"metadata": {
"papermill": {},
"tags": []
},
"source": "url = \"https://api.services.thrivetrm.com/v2/contacts\"\nheaders = {\"Authorization\": f\"Bearer {api_key}\", \"Content-Type\": \"application/json\"}\nresponse = requests.post(url, headers=headers, data=json.dumps(contact_data))",
"outputs": []
},
{
"cell_type": "markdown",
"id": "bbd63830-2aa2-459c-a687-37f0f15696ec",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"## Output"
]
},
{
"cell_type": "markdown",
"id": "22a65ab0-017f-49da-af12-785078017909",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Display result"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c1087359-2d69-4440-9a79-c14d5df7ee04",
"metadata": {
"papermill": {},
"tags": []
},
"source": "print(response.json())",
"outputs": []
},
{
"cell_type": "markdown",
"id": "e6f0dde6-8a6b-4f5c-94c5-f65dd468ee92",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
" "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.6"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"state": {},
"version_major": 2,
"version_minor": 0
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit 6b41f44

Please sign in to comment.