Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Thrive - Creates a new Contact #2139

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
281 changes: 281 additions & 0 deletions Thrive/Thrive_Creates_a_new_Contact.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
{
"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": 1,
"id": "a9c3f034-be77-4a72-baf7-f61cb9ffb466",
"metadata": {
"execution": {
"iopub.execute_input": "2023-08-30T13:45:04.041571Z",
"iopub.status.busy": "2023-08-30T13:45:04.041294Z",
"iopub.status.idle": "2023-08-30T13:45:08.975984Z",
"shell.execute_reply": "2023-08-30T13:45:08.975257Z",
"shell.execute_reply.started": "2023-08-30T13:45:04.041505Z"
},
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"import requests\n",
"import json\n",
"import naas"
]
},
{
"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": []
},
"outputs": [],
"source": [
"api_key = naas.secret.get(\"THRIVE_API_KEY\")\n",
"contact_data = {\n",
" \"first_name\": \"John\",\n",
" \"last_name\": \"Doe\",\n",
" \"email\": \"[email protected]\",\n",
" \"phone\": \"+11234567890\",\n",
"}"
]
},
{
"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": []
},
"outputs": [],
"source": [
"url = \"https://api.services.thrivetrm.com/v2/contacts\"\n",
"headers = {\"Authorization\": f\"Bearer {api_key}\", \"Content-Type\": \"application/json\"}\n",
"response = requests.post(url, headers=headers, data=json.dumps(contact_data))"
]
},
{
"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": []
},
"outputs": [],
"source": [
"print(response.json())"
]
},
{
"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
}