hubspot-api-client 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/lib/hubspot-api-client.rb +1 -0
  4. data/lib/hubspot/exceptions.rb +11 -0
  5. data/lib/hubspot/helpers/webhooks_helper.rb +31 -0
  6. data/lib/hubspot/version.rb +1 -1
  7. data/sample-apps/imports-contacts-app/.env.template +2 -0
  8. data/sample-apps/imports-contacts-app/.env.test.template +3 -0
  9. data/sample-apps/imports-contacts-app/.gitignore +37 -0
  10. data/sample-apps/imports-contacts-app/.rspec +1 -0
  11. data/sample-apps/imports-contacts-app/.ruby-version +1 -0
  12. data/sample-apps/imports-contacts-app/Dockerfile +22 -0
  13. data/sample-apps/imports-contacts-app/Gemfile +33 -0
  14. data/sample-apps/imports-contacts-app/Gemfile.lock +271 -0
  15. data/sample-apps/imports-contacts-app/README.md +27 -0
  16. data/sample-apps/imports-contacts-app/Rakefile +6 -0
  17. data/sample-apps/imports-contacts-app/app/assets/config/manifest.js +3 -0
  18. data/sample-apps/imports-contacts-app/app/assets/images/.keep +0 -0
  19. data/sample-apps/imports-contacts-app/app/assets/javascripts/application.js +15 -0
  20. data/sample-apps/imports-contacts-app/app/assets/javascripts/cable.js +13 -0
  21. data/sample-apps/imports-contacts-app/app/assets/javascripts/channels/.keep +0 -0
  22. data/sample-apps/imports-contacts-app/app/assets/stylesheets/application.css +87 -0
  23. data/sample-apps/imports-contacts-app/app/controllers/application_controller.rb +12 -0
  24. data/sample-apps/imports-contacts-app/app/controllers/concerns/.keep +0 -0
  25. data/sample-apps/imports-contacts-app/app/controllers/concerns/exception_handler.rb +12 -0
  26. data/sample-apps/imports-contacts-app/app/controllers/imports_controller.rb +24 -0
  27. data/sample-apps/imports-contacts-app/app/controllers/oauth/authorization_controller.rb +19 -0
  28. data/sample-apps/imports-contacts-app/app/helpers/application_helper.rb +2 -0
  29. data/sample-apps/{webhooks-contacts-app → imports-contacts-app}/app/lib/services/authorization/authorize_hubspot.rb +0 -0
  30. data/sample-apps/{webhooks-contacts-app → imports-contacts-app}/app/lib/services/authorization/get_authorization_uri.rb +1 -1
  31. data/sample-apps/{webhooks-contacts-app → imports-contacts-app}/app/lib/services/authorization/tokens/base.rb +0 -0
  32. data/sample-apps/{webhooks-contacts-app → imports-contacts-app}/app/lib/services/authorization/tokens/generate.rb +2 -2
  33. data/sample-apps/{webhooks-contacts-app → imports-contacts-app}/app/lib/services/authorization/tokens/refresh.rb +3 -4
  34. data/sample-apps/imports-contacts-app/app/lib/services/hubspot/imports/create.rb +52 -0
  35. data/sample-apps/imports-contacts-app/app/models/application_record.rb +3 -0
  36. data/sample-apps/imports-contacts-app/app/models/concerns/.keep +0 -0
  37. data/sample-apps/imports-contacts-app/app/views/imports/index.html.erb +70 -0
  38. data/sample-apps/imports-contacts-app/app/views/layouts/application.html.erb +23 -0
  39. data/sample-apps/imports-contacts-app/app/views/oauth/authorization/login.html.erb +15 -0
  40. data/sample-apps/imports-contacts-app/app/views/shared/_header.html.erb +15 -0
  41. data/sample-apps/imports-contacts-app/bin/bundle +3 -0
  42. data/sample-apps/imports-contacts-app/bin/rails +9 -0
  43. data/sample-apps/imports-contacts-app/bin/rake +9 -0
  44. data/sample-apps/imports-contacts-app/bin/setup +36 -0
  45. data/sample-apps/imports-contacts-app/bin/spring +17 -0
  46. data/sample-apps/imports-contacts-app/bin/update +31 -0
  47. data/sample-apps/imports-contacts-app/bin/yarn +11 -0
  48. data/sample-apps/imports-contacts-app/config.ru +5 -0
  49. data/sample-apps/imports-contacts-app/config/application.rb +19 -0
  50. data/sample-apps/imports-contacts-app/config/boot.rb +3 -0
  51. data/sample-apps/imports-contacts-app/config/cable.yml +10 -0
  52. data/sample-apps/imports-contacts-app/config/database.yml +25 -0
  53. data/sample-apps/imports-contacts-app/config/environment.rb +5 -0
  54. data/sample-apps/imports-contacts-app/config/environments/development.rb +61 -0
  55. data/sample-apps/imports-contacts-app/config/environments/production.rb +94 -0
  56. data/sample-apps/imports-contacts-app/config/environments/test.rb +46 -0
  57. data/sample-apps/imports-contacts-app/config/initializers/assets.rb +14 -0
  58. data/sample-apps/imports-contacts-app/config/initializers/filter_parameter_logging.rb +4 -0
  59. data/sample-apps/imports-contacts-app/config/initializers/hubspot-api-client.rb +3 -0
  60. data/sample-apps/imports-contacts-app/config/initializers/mime_types.rb +1 -0
  61. data/sample-apps/imports-contacts-app/config/initializers/wrap_parameters.rb +14 -0
  62. data/sample-apps/imports-contacts-app/config/locales/en.yml +33 -0
  63. data/sample-apps/imports-contacts-app/config/puma.rb +34 -0
  64. data/sample-apps/imports-contacts-app/config/routes.rb +11 -0
  65. data/sample-apps/imports-contacts-app/config/spring.rb +6 -0
  66. data/sample-apps/imports-contacts-app/db/seeds.rb +7 -0
  67. data/sample-apps/imports-contacts-app/docker-compose.yml +11 -0
  68. data/sample-apps/imports-contacts-app/docker-entrypoint.sh +8 -0
  69. data/sample-apps/imports-contacts-app/lib/assets/.keep +0 -0
  70. data/sample-apps/imports-contacts-app/lib/tasks/.keep +0 -0
  71. data/sample-apps/imports-contacts-app/log/.keep +0 -0
  72. data/sample-apps/imports-contacts-app/package.json +5 -0
  73. data/sample-apps/imports-contacts-app/public/404.html +67 -0
  74. data/sample-apps/imports-contacts-app/public/422.html +67 -0
  75. data/sample-apps/imports-contacts-app/public/500.html +66 -0
  76. data/sample-apps/imports-contacts-app/public/apple-touch-icon-precomposed.png +0 -0
  77. data/sample-apps/imports-contacts-app/public/apple-touch-icon.png +0 -0
  78. data/sample-apps/imports-contacts-app/public/examples/example.csv +2 -0
  79. data/sample-apps/imports-contacts-app/public/favicon.ico +0 -0
  80. data/sample-apps/imports-contacts-app/public/robots.txt +1 -0
  81. data/sample-apps/imports-contacts-app/tmp/.keep +0 -0
  82. data/sample-apps/webhooks-contacts-app/.env.template +3 -1
  83. data/sample-apps/webhooks-contacts-app/Gemfile.lock +1 -1
  84. data/sample-apps/webhooks-contacts-app/README.md +24 -21
  85. data/sample-apps/webhooks-contacts-app/app/assets/stylesheets/application.css +7 -55
  86. data/sample-apps/webhooks-contacts-app/app/controllers/events_controller.rb +8 -10
  87. data/sample-apps/webhooks-contacts-app/app/controllers/home_controller.rb +44 -0
  88. data/sample-apps/webhooks-contacts-app/app/controllers/oauth/authorization_controller.rb +6 -6
  89. data/sample-apps/webhooks-contacts-app/app/controllers/webhooks_controller.rb +1 -1
  90. data/sample-apps/webhooks-contacts-app/app/lib/services/hubspot/authorization/authorize.rb +17 -0
  91. data/sample-apps/webhooks-contacts-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb +35 -0
  92. data/sample-apps/webhooks-contacts-app/app/lib/services/hubspot/authorization/tokens/base.rb +21 -0
  93. data/sample-apps/webhooks-contacts-app/app/lib/services/hubspot/authorization/tokens/generate.rb +28 -0
  94. data/sample-apps/webhooks-contacts-app/app/lib/services/hubspot/authorization/tokens/refresh.rb +35 -0
  95. data/sample-apps/webhooks-contacts-app/app/lib/services/hubspot/webhooks/configure_target_url.rb +25 -0
  96. data/sample-apps/webhooks-contacts-app/app/lib/services/hubspot/webhooks/create_or_activate_subscription.rb +44 -0
  97. data/sample-apps/webhooks-contacts-app/app/lib/services/hubspot/webhooks/handle.rb +13 -1
  98. data/sample-apps/webhooks-contacts-app/app/lib/services/hubspot/webhooks/pause_active_subscriptions.rb +39 -0
  99. data/sample-apps/webhooks-contacts-app/app/models/event.rb +3 -0
  100. data/sample-apps/webhooks-contacts-app/app/views/events/index.html.erb +14 -16
  101. data/sample-apps/webhooks-contacts-app/app/views/home/index.html.erb +47 -0
  102. data/sample-apps/webhooks-contacts-app/app/views/oauth/authorization/login.html.erb +6 -6
  103. data/sample-apps/webhooks-contacts-app/app/views/shared/_header.html.erb +3 -0
  104. data/sample-apps/webhooks-contacts-app/config/database.yml +9 -9
  105. data/sample-apps/webhooks-contacts-app/config/routes.rb +2 -0
  106. data/sample-apps/webhooks-contacts-app/db/schema.rb +2 -5
  107. data/sample-apps/webhooks-contacts-app/docker-compose.yml +13 -10
  108. metadata +299 -7
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,3 @@
1
+ Hubspot.configure do |config|
2
+ config.params_encoding = :multi
3
+ end
@@ -0,0 +1 @@
1
+ Mime::Type.register "text/csv", :csv
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json]
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,33 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # The following keys must be escaped otherwise they will not be retrieved by
20
+ # the default I18n backend:
21
+ #
22
+ # true, false, on, off, yes, no
23
+ #
24
+ # Instead, surround them with single quotes.
25
+ #
26
+ # en:
27
+ # 'true': 'foo'
28
+ #
29
+ # To learn more, please read the Rails Internationalization guide
30
+ # available at http://guides.rubyonrails.org/i18n.html.
31
+
32
+ en:
33
+ hello: "Hello world"
@@ -0,0 +1,34 @@
1
+ # Puma can serve each request in a thread from an internal thread pool.
2
+ # The `threads` method setting takes two numbers: a minimum and maximum.
3
+ # Any libraries that use thread pools should be configured to match
4
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
5
+ # and maximum; this matches the default thread size of Active Record.
6
+ #
7
+ threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8
+ threads threads_count, threads_count
9
+
10
+ # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
11
+ #
12
+ port ENV.fetch("PORT") { 3000 }
13
+
14
+ # Specifies the `environment` that Puma will run in.
15
+ #
16
+ environment ENV.fetch("RAILS_ENV") { "development" }
17
+
18
+ # Specifies the number of `workers` to boot in clustered mode.
19
+ # Workers are forked webserver processes. If using threads and workers together
20
+ # the concurrency of the application would be max `threads` * `workers`.
21
+ # Workers do not work on JRuby or Windows (both of which do not support
22
+ # processes).
23
+ #
24
+ # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
25
+
26
+ # Use the `preload_app!` method when specifying a `workers` number.
27
+ # This directive tells Puma to first boot the application and load code
28
+ # before forking the application. This takes advantage of Copy On Write
29
+ # process behavior so workers use less memory.
30
+ #
31
+ # preload_app!
32
+
33
+ # Allow puma to be restarted by `rails restart` command.
34
+ plugin :tmp_restart
@@ -0,0 +1,11 @@
1
+ Rails.application.routes.draw do
2
+ resources :imports, only: %i(index create)
3
+ get '/download', to: 'imports#download_example'
4
+
5
+ resources :properties
6
+
7
+ get '/oauth', to: 'oauth/authorization#authorize'
8
+ get '/oauth/callback', to: 'oauth/authorization#callback'
9
+ get '/login', to: 'oauth/authorization#login'
10
+ root to: 'imports#index'
11
+ end
@@ -0,0 +1,6 @@
1
+ %w[
2
+ .ruby-version
3
+ .rbenv-vars
4
+ tmp/restart.txt
5
+ tmp/caching-dev.txt
6
+ ].each { |path| Spring.watch(path) }
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
7
+ # Character.create(name: 'Luke', movie: movies.first)
@@ -0,0 +1,11 @@
1
+ version: '3'
2
+ services:
3
+ web:
4
+ build:
5
+ context: ../../
6
+ dockerfile: ./sample-apps/imports-contacts-app/Dockerfile
7
+ command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
8
+ volumes:
9
+ - .:/imports-contacts-app
10
+ ports:
11
+ - "3000:3000"
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ # Remove a potentially pre-existing server.pid for Rails.
5
+ rm -f /myapp/tmp/pids/server.pid
6
+
7
+ # Then exec the container's main process (what's set as CMD in the Dockerfile).
8
+ exec "$@"
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "imports-contacts-app",
3
+ "private": true,
4
+ "dependencies": {}
5
+ }
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ .rails-default-error-page {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ .rails-default-error-page div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ .rails-default-error-page div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ .rails-default-error-page h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ .rails-default-error-page div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body class="rails-default-error-page">
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
@@ -0,0 +1,2 @@
1
+ firstname,email
2
+ example2020327,example2020327@hubspot.com
@@ -0,0 +1 @@
1
+ # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
@@ -1,2 +1,4 @@
1
- HUBSPOT_API_KEY=demo
1
+ HUBSPOT_APPLICATION_ID=
2
+ HUBSPOT_CLIENT_ID=
2
3
  HUBSPOT_CLIENT_SECRET=
4
+ HUBSPOT_DEVELOPER_API_KEY=
@@ -9,7 +9,7 @@ GIT
9
9
  PATH
10
10
  remote: ../..
11
11
  specs:
12
- hubspot-api-client (1.0.0)
12
+ hubspot-api-client (3.2.0)
13
13
  faraday (>= 0.14.0)
14
14
  json (~> 2.1, >= 2.1.0)
15
15
 
@@ -1,16 +1,29 @@
1
- # HubSpot-ruby sample Webhooks Tutorial app
1
+ # HubSpot-ruby sample Webhooks app
2
2
 
3
- This is a sample app for the [hubspot-ruby SDK](../../../../)
3
+ This is a sample app for the [hubspot-ruby SDK](../../../..).
4
4
  Currently, this app focuses on demonstrating the functionality of [Webhooks API](https://developers.hubspot.com/docs-beta/crm/extensions), contact creation/deletion in particular.
5
5
 
6
- Please see the documentation on [How do I create an app in HubSpot?](https://developers.hubspot.com/docs/faq/how-do-i-create-an-app-in-hubspot)
6
+ Please see the documentation on [Creating an app in HubSpot](https://developers.hubspot.com/docs-beta/creating-an-app)
7
7
 
8
8
  ### HubSpot Public API links used in this application
9
9
 
10
- - [Initiate an Integration with OAuth 2.0](https://developers.hubspot.com/docs/methods/oauth2/initiate-oauth-integration)
11
- - [Get OAuth 2.0 Access Token and Refresh Tokens](https://developers.hubspot.com/docs/methods/oauth2/get-access-and-refresh-tokens)
12
- - [Refresh OAuth 2.0 Access Token](https://developers.hubspot.com/docs/methods/oauth2/refresh-access-token)
13
10
  - [Read a batch of contact objects by ID](https://developers.hubspot.com/docs-beta/crm/contacts)
11
+ ### Note on the Data Base
12
+ This application uses MySQL database to store the events coming from Webhooks. There is a single events table:
13
+ ```
14
+ create table if not exists events
15
+ (
16
+ id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
17
+ event_type VARCHAR(255),
18
+ object_id int default null,
19
+ event_id bigint default null,
20
+ occurred_at bigint default null,
21
+ property_name varchar(255) default null,
22
+ property_value varchar(255) default null,
23
+ created_at datetime default CURRENT_TIMESTAMP
24
+ );
25
+ ```
26
+ Please note that event_id sent by HubSpot needs to be stored as int
14
27
 
15
28
  ### Setup App
16
29
 
@@ -19,19 +32,15 @@ Make sure you have [Docker Compose](https://docs.docker.com/compose/) and [Ngrok
19
32
  ### Configure
20
33
 
21
34
  1. Copy .env.template to .env
22
- 2. Paste your HUBSPOT_CLIENT_ID and HUBSPOT_CLIENT_SECRET
35
+ 2. Paste your HUBSPOT_CLIENT_ID, HUBSPOT_CLIENT_SECRET, HUBSPOT_APPLICATION_ID and HUBSPOT_DEVELOPER_API_KEY
23
36
 
24
37
  ### Running
25
38
 
26
- The best way to run this project (with the least configuration), is using docker compose. Change to the webroot and start it
39
+ The best way to run this project (with the least configuration), is using docker compose. Change to the webroot and start it
27
40
 
28
41
  ```bash
29
42
  docker-compose up --build
30
43
  ```
31
- In another terminal, run:
32
- ```bash
33
- docker-compose run web rake db:create db:migrate
34
- ```
35
44
 
36
45
  Copy Ngrok url from console. Now you should now be able to navigate to that url and use the application.
37
46
 
@@ -40,12 +49,6 @@ Copy Ngrok url from console. Now you should now be able to navigate to that url
40
49
  If you are using Ngrok free plan and testing the application with large amount of import/deletions of Contacts you are likely to see Ngrok "Too Many Connections" error.
41
50
  This is caused by a large amount of weebhooks events being sent to Ngrok tunnel. To avoid it you can deploy sample applications on your server w/o Ngrok or upgrade to Ngrok Enterprise version
42
51
 
43
- ### Configure webhooks
44
-
45
- Required webhooks url should look like https://***.ngrok.io/webhooks/callback
46
-
47
- Following [Webhooks Setup](https://developers.hubspot.com/docs/methods/webhooks/webhooks-overview) guide please note:
48
-
49
- - Every time the app is restarted you should update the webhooks url
50
- - The app supports `contact.creation` and `contact.deletion` subscription types only
51
- - Subscription are paused by default. You need to activate them manually after creating
52
+ ### HubSpot Signature
53
+ To help improve security, HubSpot webhooks are sent with signature so you can verify that it came from HubSpot. This sample application shows how to do that verification. You can read more about validation in general here: https://developers.hubspot.com/docs/api/webhooks/validating-requests.
54
+ The source code for validating webhooks is at [hubspot\utils\webhooks](../../hubspot/utils/webhooks.py) and [an usage example](./src/routes/webhooks.py).