Skip to content

Commit 84192a8

Browse files
author
Brooke Fisher
committed
Add this repository to the official GitHub organization.
0 parents  commit 84192a8

File tree

6 files changed

+190
-0
lines changed

6 files changed

+190
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
node_modules
3+
package-lock.json
4+
.env

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Welcome to the Integrating With HubSpot I: Foundations Practicum
2+
3+
This repository is for the Integrating With HubSpot I: Foundations course. This practicum is one of two requirements for receiving your Integrating With HubSpot I: Foundations certification. You must also take the exam and receive a passing grade (at least 75%).
4+
5+
To read the full directions, please go to the [practicum instructions](https://app.hubspot.com/academy/l/tracks/1092124/1093824/5493?language=en).
6+
7+
**Put your HubSpot developer test account custom objects URL link here:**
8+
9+
___
10+
## Tips:
11+
- Commit to your repository often. Even if you make small tweaks to your code, it’s best to be committing to your repository frequently.
12+
- The subject of the custom object is up to you. Feel free to get creative!
13+
- Don’t include your private app access token in your repo. We’ll grab this from your test account private app.
14+
15+
## Pre-requisites:
16+
- Using [Node](https://nodejs.org/en/download) and node packages
17+
- Using [Express](https://expressjs.com/en/starter/installing.html)
18+
- Using [Axios](https://axios-http.com/docs/intro)
19+
- Using [Pug templating system](https://pugjs.org/api/getting-started.html)
20+
- Using the command line
21+
- Using [Git and GitHub](https://product.hubspot.com/blog/git-and-github-tutorial-for-beginners)
22+
23+
## Requirements
24+
- All work must be your own. During the grading process we will check the revision history. Submissions that do not meet this requirement will not be considered.
25+
- You must have at least two new routes in your index.js file and one new pug template for the homepage.
26+
- You must create a developer test account and link to it in your README.md file. Submissions that do not meet this requirement will not be considered.

index.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
const express = require('express');
2+
const axios = require('axios');
3+
const app = express();
4+
5+
app.set('view engine', 'pug');
6+
app.use(express.static(__dirname + '/public'));
7+
app.use(express.urlencoded({ extended: true }));
8+
app.use(express.json());
9+
10+
// * Please include the private app access token in your repo BUT only an access token built in a TEST ACCOUNT. Don't do this practicum in your normal account.
11+
const PRIVATE_APP_ACCESS = '';
12+
13+
// TODO: ROUTE 1 - Create a new app.get route for the homepage to call your custom object data. Pass this data along to the front-end and create a new pug template in the views folder.
14+
15+
// * Code for Route 1 goes here
16+
17+
// TODO: ROUTE 2 - Create a new app.get route for the form to create or update new custom object data. Send this data along in the next route.
18+
19+
// * Code for Route 2 goes here
20+
21+
// TODO: ROUTE 3 - Create a new app.post route for the custom objects form to create or update your custom object data. Once executed, redirect the user to the homepage.
22+
23+
// * Code for Route 3 goes here
24+
25+
/**
26+
* * This is sample code to give you a reference for how you should structure your calls.
27+
28+
* * App.get sample
29+
app.get('/contacts', async (req, res) => {
30+
const contacts = 'https://api.hubspot.com/crm/v3/objects/contacts';
31+
const headers = {
32+
Authorization: `Bearer ${PRIVATE_APP_ACCESS}`,
33+
'Content-Type': 'application/json'
34+
}
35+
try {
36+
const resp = await axios.get(contacts, { headers });
37+
const data = resp.data.results;
38+
res.render('contacts', { title: 'Contacts | HubSpot APIs', data });
39+
} catch (error) {
40+
console.error(error);
41+
}
42+
});
43+
44+
* * App.post sample
45+
app.post('/update', async (req, res) => {
46+
const update = {
47+
properties: {
48+
"favorite_book": req.body.newVal
49+
}
50+
}
51+
52+
const email = req.query.email;
53+
const updateContact = `https://api.hubapi.com/crm/v3/objects/contacts/${email}?idProperty=email`;
54+
const headers = {
55+
Authorization: `Bearer ${PRIVATE_APP_ACCESS}`,
56+
'Content-Type': 'application/json'
57+
};
58+
59+
try {
60+
await axios.patch(updateContact, update, { headers } );
61+
res.redirect('back');
62+
} catch(err) {
63+
console.error(err);
64+
}
65+
66+
});
67+
*/
68+
69+
70+
// * Localhost
71+
app.listen(3000, () => console.log('Listening on http://localhost:3000'));

package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "integrating-with-hubspot-i-foundations-practicum",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "HubSpot Academy learner",
10+
"license": "ISC",
11+
"dependencies": {
12+
"axios": "^1.3.5",
13+
"express": "^4.18.2",
14+
"pug": "^3.0.2"
15+
}
16+
}

public/css/style.css

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
2+
3+
body, * {
4+
font-family: 'Roboto', sans-serif;
5+
margin: 0;
6+
padding: 0;
7+
}
8+
9+
h1 {
10+
margin: 1rem;
11+
}
12+
13+
.cards {
14+
display: flex;
15+
align-items: center;
16+
justify-content: space-evenly;
17+
flex-wrap: wrap;
18+
}
19+
20+
.card {
21+
flex-basis: 31%;
22+
margin: 1rem 0.4rem;
23+
padding: 1rem 0.4rem 2.5rem 0.4rem;
24+
border: solid 1px lightgrey;
25+
border-radius: 15px;
26+
box-shadow: 3px 2px 6px lightgrey;
27+
}
28+
29+
.card__email {
30+
font-size: 1rem;
31+
}
32+
33+
.form-wrapper {
34+
font-size: 18px;
35+
max-width: 768px;
36+
margin: 2rem auto;
37+
padding: 2rem;
38+
border: solid 1px lightgrey;
39+
border-radius: 15px;
40+
box-shadow: 3px 2px 6px lightgrey;
41+
}
42+
43+
label, input {
44+
margin-top: 5px;
45+
display: block;
46+
font-size: inherit;
47+
}
48+
49+
input[type="text"] {
50+
padding: .25rem;
51+
}
52+
53+
input[type="submit"] {
54+
background-color: lightgrey;
55+
border: none;
56+
padding: .375rem 1rem;
57+
margin-top: 10px;
58+
}

views/contacts.pug

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//- ** This is a sample of a pug template and how it uses the data passed to it from index.js.
2+
3+
//- doctype html
4+
//- html
5+
//- head
6+
//- title= `${title}`
7+
//- meta(name="viewport" content="width=device-width, initial-scale=1")
8+
//- link(rel="stylesheet", href="/css/style.css")
9+
//- body
10+
//- h1 Contacts
11+
//- .cards
12+
//- each contact in data
13+
//- .card
14+
//- h2.card__name #{contact.properties.firstname} #{contact.properties.lastname}
15+
//- p.card__email #{contact.properties.email}

0 commit comments

Comments
 (0)