hubspot-api-client 3.3.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/hubspot-api-client.rb +61 -0
- data/lib/hubspot/codegen/cms/audit-logs/api/default_api.rb +106 -0
- data/lib/hubspot/codegen/cms/audit-logs/api_client.rb +422 -0
- data/lib/hubspot/codegen/cms/audit-logs/api_error.rb +61 -0
- data/lib/hubspot/codegen/cms/audit-logs/configuration.rb +258 -0
- data/lib/hubspot/codegen/cms/audit-logs/models/collection_response_public_audit_log.rb +226 -0
- data/lib/hubspot/codegen/cms/audit-logs/models/error.rb +292 -0
- data/lib/hubspot/codegen/cms/audit-logs/models/error_detail.rb +258 -0
- data/lib/hubspot/codegen/cms/audit-logs/models/next_page.rb +224 -0
- data/lib/hubspot/codegen/cms/audit-logs/models/paging.rb +210 -0
- data/lib/hubspot/codegen/cms/audit-logs/models/public_audit_log.rb +352 -0
- data/lib/hubspot/codegen/cms/domains/api/domains_api.rb +183 -0
- data/lib/hubspot/codegen/cms/domains/api_client.rb +422 -0
- data/lib/hubspot/codegen/cms/domains/api_error.rb +61 -0
- data/lib/hubspot/codegen/cms/domains/configuration.rb +258 -0
- data/lib/hubspot/codegen/cms/domains/models/collection_response_with_total_domain.rb +240 -0
- data/lib/hubspot/codegen/cms/domains/models/domain.rb +1091 -0
- data/lib/hubspot/codegen/cms/domains/models/domain_cdn_config.rb +497 -0
- data/lib/hubspot/codegen/cms/domains/models/domain_setup_info.rb +231 -0
- data/lib/hubspot/codegen/cms/domains/models/error.rb +292 -0
- data/lib/hubspot/codegen/cms/domains/models/error_detail.rb +258 -0
- data/lib/hubspot/codegen/cms/domains/models/next_page.rb +224 -0
- data/lib/hubspot/codegen/cms/domains/models/paging.rb +210 -0
- data/lib/hubspot/codegen/cms/performance/api/default_api.rb +186 -0
- data/lib/hubspot/codegen/cms/performance/api_client.rb +422 -0
- data/lib/hubspot/codegen/cms/performance/api_error.rb +61 -0
- data/lib/hubspot/codegen/cms/performance/configuration.rb +258 -0
- data/lib/hubspot/codegen/cms/performance/models/error.rb +292 -0
- data/lib/hubspot/codegen/cms/performance/models/error_detail.rb +258 -0
- data/lib/hubspot/codegen/cms/performance/models/performance_view.rb +528 -0
- data/lib/hubspot/codegen/cms/performance/models/public_performance_response.rb +332 -0
- data/lib/hubspot/codegen/cms/site-search/api/default_api.rb +225 -0
- data/lib/hubspot/codegen/cms/site-search/api_client.rb +422 -0
- data/lib/hubspot/codegen/cms/site-search/api_error.rb +61 -0
- data/lib/hubspot/codegen/cms/site-search/configuration.rb +258 -0
- data/lib/hubspot/codegen/cms/site-search/models/content_search_result.rb +427 -0
- data/lib/hubspot/codegen/cms/site-search/models/error.rb +292 -0
- data/lib/hubspot/codegen/cms/site-search/models/error_detail.rb +258 -0
- data/lib/hubspot/codegen/cms/site-search/models/indexed_data.rb +279 -0
- data/lib/hubspot/codegen/cms/site-search/models/public_search_results.rb +282 -0
- data/lib/hubspot/codegen/cms/site-search/models/search_hit_field.rb +257 -0
- data/lib/hubspot/codegen/cms/url-redirects/api/redirects_api.rb +368 -0
- data/lib/hubspot/codegen/cms/url-redirects/api_client.rb +422 -0
- data/lib/hubspot/codegen/cms/url-redirects/api_error.rb +61 -0
- data/lib/hubspot/codegen/cms/url-redirects/configuration.rb +258 -0
- data/lib/hubspot/codegen/cms/url-redirects/models/collection_response_with_total_url_mapping.rb +242 -0
- data/lib/hubspot/codegen/cms/url-redirects/models/error.rb +292 -0
- data/lib/hubspot/codegen/cms/url-redirects/models/error_detail.rb +258 -0
- data/lib/hubspot/codegen/cms/url-redirects/models/next_page.rb +224 -0
- data/lib/hubspot/codegen/cms/url-redirects/models/paging.rb +210 -0
- data/lib/hubspot/codegen/cms/url-redirects/models/url_mapping.rb +596 -0
- data/lib/hubspot/codegen/cms/url-redirects/models/url_mapping_create_request_body.rb +306 -0
- data/lib/hubspot/version.rb +1 -1
- data/sample-apps/search-result-paging-app/.env.template +4 -0
- data/sample-apps/search-result-paging-app/.gitignore +35 -0
- data/sample-apps/search-result-paging-app/.rspec +1 -0
- data/sample-apps/search-result-paging-app/.ruby-version +1 -0
- data/sample-apps/search-result-paging-app/Dockerfile +22 -0
- data/sample-apps/search-result-paging-app/Gemfile +35 -0
- data/sample-apps/search-result-paging-app/Gemfile.lock +279 -0
- data/sample-apps/search-result-paging-app/README.md +0 -0
- data/sample-apps/search-result-paging-app/Rakefile +6 -0
- data/sample-apps/search-result-paging-app/app/assets/config/manifest.js +3 -0
- data/sample-apps/search-result-paging-app/app/assets/images/.keep +0 -0
- data/sample-apps/search-result-paging-app/app/assets/javascripts/application.js +25 -0
- data/sample-apps/search-result-paging-app/app/assets/javascripts/cable.js +13 -0
- data/sample-apps/search-result-paging-app/app/assets/javascripts/channels/.keep +0 -0
- data/sample-apps/search-result-paging-app/app/assets/stylesheets/application.css +77 -0
- data/sample-apps/search-result-paging-app/app/controllers/application_controller.rb +12 -0
- data/sample-apps/search-result-paging-app/app/controllers/concerns/.keep +0 -0
- data/sample-apps/search-result-paging-app/app/controllers/concerns/exception_handler.rb +12 -0
- data/sample-apps/search-result-paging-app/app/controllers/home_controller.rb +14 -0
- data/sample-apps/search-result-paging-app/app/controllers/oauth/authorization_controller.rb +19 -0
- data/sample-apps/search-result-paging-app/app/helpers/application_helper.rb +2 -0
- data/sample-apps/search-result-paging-app/app/lib/services/hubspot/authorization/authorize.rb +17 -0
- data/sample-apps/search-result-paging-app/app/lib/services/hubspot/authorization/get_authorization_uri.rb +35 -0
- data/sample-apps/search-result-paging-app/app/lib/services/hubspot/authorization/tokens/base.rb +21 -0
- data/sample-apps/search-result-paging-app/app/lib/services/hubspot/authorization/tokens/generate.rb +28 -0
- data/sample-apps/search-result-paging-app/app/lib/services/hubspot/authorization/tokens/refresh.rb +35 -0
- data/sample-apps/search-result-paging-app/app/lib/services/hubspot/contacts/get_page.rb +26 -0
- data/sample-apps/search-result-paging-app/app/lib/services/hubspot/contacts/search.rb +35 -0
- data/sample-apps/search-result-paging-app/app/lib/services/hubspot/properties/create.rb +23 -0
- data/sample-apps/search-result-paging-app/app/lib/services/hubspot/properties/destroy.rb +16 -0
- data/sample-apps/search-result-paging-app/app/models/application_record.rb +3 -0
- data/sample-apps/search-result-paging-app/app/models/concerns/.keep +0 -0
- data/sample-apps/search-result-paging-app/app/views/home/index.html.erb +13 -0
- data/sample-apps/search-result-paging-app/app/views/layouts/application.html.erb +23 -0
- data/sample-apps/search-result-paging-app/app/views/oauth/authorization/login.html.erb +15 -0
- data/sample-apps/search-result-paging-app/app/views/shared/_header.html.erb +18 -0
- data/sample-apps/search-result-paging-app/bin/bundle +3 -0
- data/sample-apps/search-result-paging-app/bin/rails +9 -0
- data/sample-apps/search-result-paging-app/bin/rake +9 -0
- data/sample-apps/search-result-paging-app/bin/setup +36 -0
- data/sample-apps/search-result-paging-app/bin/spring +17 -0
- data/sample-apps/search-result-paging-app/bin/update +31 -0
- data/sample-apps/search-result-paging-app/bin/yarn +11 -0
- data/sample-apps/search-result-paging-app/config.ru +5 -0
- data/sample-apps/search-result-paging-app/config/application.rb +19 -0
- data/sample-apps/search-result-paging-app/config/boot.rb +3 -0
- data/sample-apps/search-result-paging-app/config/cable.yml +10 -0
- data/sample-apps/search-result-paging-app/config/database.yml +25 -0
- data/sample-apps/search-result-paging-app/config/environment.rb +5 -0
- data/sample-apps/search-result-paging-app/config/environments/development.rb +61 -0
- data/sample-apps/search-result-paging-app/config/environments/production.rb +94 -0
- data/sample-apps/search-result-paging-app/config/environments/test.rb +46 -0
- data/sample-apps/search-result-paging-app/config/initializers/assets.rb +14 -0
- data/sample-apps/search-result-paging-app/config/initializers/filter_parameter_logging.rb +4 -0
- data/sample-apps/search-result-paging-app/config/initializers/hubspot-api-client.rb +3 -0
- data/sample-apps/search-result-paging-app/config/initializers/mime_types.rb +1 -0
- data/sample-apps/search-result-paging-app/config/initializers/wrap_parameters.rb +14 -0
- data/sample-apps/search-result-paging-app/config/locales/en.yml +33 -0
- data/sample-apps/search-result-paging-app/config/puma.rb +34 -0
- data/sample-apps/search-result-paging-app/config/routes.rb +7 -0
- data/sample-apps/search-result-paging-app/config/spring.rb +6 -0
- data/sample-apps/search-result-paging-app/db/seeds.rb +7 -0
- data/sample-apps/search-result-paging-app/docker-compose.yml +11 -0
- data/sample-apps/search-result-paging-app/docker-entrypoint.sh +8 -0
- data/sample-apps/search-result-paging-app/lib/assets/.keep +0 -0
- data/sample-apps/search-result-paging-app/lib/tasks/.keep +0 -0
- data/sample-apps/search-result-paging-app/lib/tasks/search_contacts.rake +36 -0
- data/sample-apps/search-result-paging-app/log/.keep +0 -0
- data/sample-apps/search-result-paging-app/package.json +5 -0
- data/sample-apps/search-result-paging-app/public/404.html +67 -0
- data/sample-apps/search-result-paging-app/public/422.html +67 -0
- data/sample-apps/search-result-paging-app/public/500.html +66 -0
- data/sample-apps/search-result-paging-app/public/apple-touch-icon-precomposed.png +0 -0
- data/sample-apps/search-result-paging-app/public/apple-touch-icon.png +0 -0
- data/sample-apps/search-result-paging-app/public/favicon.ico +0 -0
- data/sample-apps/search-result-paging-app/public/robots.txt +1 -0
- data/sample-apps/search-result-paging-app/tmp/.keep +0 -0
- metadata +309 -2
File without changes
|
File without changes
|
@@ -0,0 +1,25 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
|
5
|
+
// vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require rails-ujs
|
14
|
+
//= require jquery
|
15
|
+
//= require activestorage
|
16
|
+
//= require clipboard
|
17
|
+
//= require_tree .
|
18
|
+
|
19
|
+
$(document).ready(function(){
|
20
|
+
var clipboard = new Clipboard('.clipboard-btn');
|
21
|
+
clipboard.on('success', function(e) {
|
22
|
+
$(e.trigger).text('Copied!');
|
23
|
+
$(e.trigger).addClass('is-copy');
|
24
|
+
});
|
25
|
+
});
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
+
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
|
3
|
+
//
|
4
|
+
//= require action_cable
|
5
|
+
//= require_self
|
6
|
+
//= require_tree ./channels
|
7
|
+
|
8
|
+
(function() {
|
9
|
+
this.App || (this.App = {});
|
10
|
+
|
11
|
+
App.cable = ActionCable.createConsumer();
|
12
|
+
|
13
|
+
}).call(this);
|
File without changes
|
@@ -0,0 +1,77 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
|
6
|
+
* vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
16
|
+
|
17
|
+
.wrapper .container {
|
18
|
+
padding-bottom: 2rem;
|
19
|
+
padding-top: 2rem;
|
20
|
+
}
|
21
|
+
|
22
|
+
.navigation {
|
23
|
+
background: #f4f5f6;
|
24
|
+
border-bottom: .1rem solid #d1d1d1;
|
25
|
+
display: block;
|
26
|
+
height: 5.2rem;
|
27
|
+
left: 0;
|
28
|
+
max-width: 100%;
|
29
|
+
width: 100%;
|
30
|
+
}
|
31
|
+
|
32
|
+
.navigation .container {
|
33
|
+
padding-bottom: 0;
|
34
|
+
padding-top: 0
|
35
|
+
}
|
36
|
+
|
37
|
+
.navigation .navigation-list {
|
38
|
+
list-style: none;
|
39
|
+
margin-bottom: 0;
|
40
|
+
}
|
41
|
+
|
42
|
+
.navigation .navigation-item {
|
43
|
+
float: left;
|
44
|
+
margin-bottom: 0;
|
45
|
+
margin-left: 2.5rem;
|
46
|
+
position: relative
|
47
|
+
}
|
48
|
+
|
49
|
+
.navigation .navigation-title, .navigation .title {
|
50
|
+
color: #606c76;
|
51
|
+
position: relative
|
52
|
+
}
|
53
|
+
|
54
|
+
.navigation .navigation-link, .navigation .navigation-title, .navigation .title {
|
55
|
+
display: inline;
|
56
|
+
font-size: 1.6rem;
|
57
|
+
line-height: 5.2rem;
|
58
|
+
padding: 0;
|
59
|
+
text-decoration: none
|
60
|
+
}
|
61
|
+
|
62
|
+
.navigation .navigation-link.active {
|
63
|
+
color: #606c76
|
64
|
+
}
|
65
|
+
|
66
|
+
pre {
|
67
|
+
padding-left: 1rem;
|
68
|
+
}
|
69
|
+
|
70
|
+
.authorize-button {
|
71
|
+
justify-content: center;
|
72
|
+
}
|
73
|
+
|
74
|
+
.text-center {
|
75
|
+
text-align: center;
|
76
|
+
}
|
77
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class ApplicationController < ActionController::Base
|
2
|
+
include ExceptionHandler
|
3
|
+
|
4
|
+
before_action :check_env_variables
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def check_env_variables
|
9
|
+
missing_vars = %w[HUBSPOT_CLIENT_ID HUBSPOT_CLIENT_SECRET].select { |var| ENV[var].blank? }
|
10
|
+
raise(ExceptionHandler::HubspotError.new, "Please specify #{missing_vars.join(', ')} in .env") if missing_vars.present?
|
11
|
+
end
|
12
|
+
end
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class HomeController < ApplicationController
|
2
|
+
before_action :authorize
|
3
|
+
|
4
|
+
def index;end
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def authorize
|
9
|
+
redirect_to login_path and return if session['tokens'].blank?
|
10
|
+
|
11
|
+
session['tokens'] = Services::Hubspot::Authorization::Tokens::Refresh.new(tokens: session['tokens'], request: request).call
|
12
|
+
Services::Hubspot::Authorization::Authorize.new(tokens: session['tokens']).call
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Oauth
|
2
|
+
class AuthorizationController < ApplicationController
|
3
|
+
def authorize
|
4
|
+
url = Services::Hubspot::Authorization::GetAuthorizationUri.new(request: request).call
|
5
|
+
redirect_to url
|
6
|
+
end
|
7
|
+
|
8
|
+
def callback
|
9
|
+
session[:tokens] = Services::Hubspot::Authorization::Tokens::Generate.new(
|
10
|
+
code: params[:code],
|
11
|
+
request: request
|
12
|
+
).call
|
13
|
+
Services::Hubspot::Authorization::Authorize.new(tokens: session[:tokens]).call
|
14
|
+
redirect_to '/'
|
15
|
+
end
|
16
|
+
|
17
|
+
def login;end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Services
|
2
|
+
module Hubspot
|
3
|
+
module Authorization
|
4
|
+
class Authorize
|
5
|
+
def initialize(tokens:)
|
6
|
+
@tokens = tokens
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
::Hubspot.configure do |config|
|
11
|
+
config.access_token = @tokens[:access_token]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Services
|
2
|
+
module Hubspot
|
3
|
+
module Authorization
|
4
|
+
class GetAuthorizationUri
|
5
|
+
CALLBACK_PATH = '/oauth/callback'.freeze
|
6
|
+
|
7
|
+
def initialize(request:)
|
8
|
+
@request = request
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
check_presence_of_credentials
|
13
|
+
|
14
|
+
::Hubspot::OAuthHelper.authorize_url(
|
15
|
+
client_id: ENV['HUBSPOT_CLIENT_ID'],
|
16
|
+
redirect_uri: redirect_uri,
|
17
|
+
scope: %w[contacts]
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def redirect_uri
|
24
|
+
@request.protocol + @request.host_with_port + CALLBACK_PATH
|
25
|
+
end
|
26
|
+
|
27
|
+
def check_presence_of_credentials
|
28
|
+
return if ENV['HUBSPOT_CLIENT_ID'].present?
|
29
|
+
|
30
|
+
raise(ExceptionHandler::HubspotError.new, 'Please specify HUBSPOT_CLIENT_ID in .env')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/sample-apps/search-result-paging-app/app/lib/services/hubspot/authorization/tokens/base.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Services
|
2
|
+
module Hubspot
|
3
|
+
module Authorization
|
4
|
+
module Tokens
|
5
|
+
class Base
|
6
|
+
CALLBACK_PATH = '/oauth/callback'.freeze
|
7
|
+
|
8
|
+
def expires_at(expires_in)
|
9
|
+
Time.current + (expires_in * 0.95).round
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def redirect_uri
|
15
|
+
@request.protocol + @request.host_with_port + CALLBACK_PATH
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/sample-apps/search-result-paging-app/app/lib/services/hubspot/authorization/tokens/generate.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
module Services
|
2
|
+
module Hubspot
|
3
|
+
module Authorization
|
4
|
+
module Tokens
|
5
|
+
class Generate < Tokens::Base
|
6
|
+
def initialize(code:, request:)
|
7
|
+
@code = code
|
8
|
+
@request = request
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
default_api = ::Hubspot::OAuth::DefaultApi.new
|
13
|
+
tokens = default_api.create_token(
|
14
|
+
grant_type: :authorization_code,
|
15
|
+
code: @code,
|
16
|
+
redirect_uri: redirect_uri,
|
17
|
+
client_id: ENV['HUBSPOT_CLIENT_ID'],
|
18
|
+
client_secret: ENV['HUBSPOT_CLIENT_SECRET'],
|
19
|
+
return_type: 'Object'
|
20
|
+
)
|
21
|
+
tokens[:expires_at] = expires_at(tokens[:expires_in])
|
22
|
+
tokens
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/sample-apps/search-result-paging-app/app/lib/services/hubspot/authorization/tokens/refresh.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module Services
|
2
|
+
module Hubspot
|
3
|
+
module Authorization
|
4
|
+
module Tokens
|
5
|
+
class Refresh < Tokens::Base
|
6
|
+
def initialize(tokens:, request:)
|
7
|
+
@tokens = tokens
|
8
|
+
@request = request
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
@tokens = refresh_tokens if Time.current > @tokens[:expires_at]
|
13
|
+
@tokens
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def refresh_tokens
|
19
|
+
default_api = ::Hubspot::OAuth::DefaultApi.new
|
20
|
+
tokens = default_api.create_token(
|
21
|
+
grant_type: :refresh_token,
|
22
|
+
refresh_token: @tokens[:refresh_token],
|
23
|
+
redirect_uri: redirect_uri,
|
24
|
+
client_id: ENV['HUBSPOT_CLIENT_ID'],
|
25
|
+
client_secret: ENV['HUBSPOT_CLIENT_SECRET'],
|
26
|
+
return_type: 'Object'
|
27
|
+
)
|
28
|
+
tokens[:expires_at] = expires_at(tokens[:expires_in])
|
29
|
+
tokens
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Services
|
2
|
+
module Hubspot
|
3
|
+
module Contacts
|
4
|
+
class GetPage
|
5
|
+
def initialize(limit: 10)
|
6
|
+
@limit = limit
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
basic_api = ::Hubspot::Crm::Contacts::BasicApi.new
|
11
|
+
results = basic_api.get_page(auth_names: 'oauth2', limit: @limit).results
|
12
|
+
results = add_fullnames(results)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def add_fullnames(contacts)
|
18
|
+
contacts.each do |contact|
|
19
|
+
fullname = [contact.properties['firstname'], contact.properties['lastname']].reject(&:empty?).join(' ')
|
20
|
+
contact.properties['fullname'] = fullname
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Services
|
2
|
+
module Hubspot
|
3
|
+
module Contacts
|
4
|
+
class Search
|
5
|
+
def initialize(after:, limit:, search_query:, search_api: nil)
|
6
|
+
@after = after
|
7
|
+
@limit = limit
|
8
|
+
@search_query = search_query
|
9
|
+
@search_api = search_api.nil? ? ::Hubspot::Crm::Contacts::SearchApi.new : search_api
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
@search_api.do_search(body: search_request, auth_names: 'oauth2').results
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def search_request
|
19
|
+
filter = ::Hubspot::Crm::Contacts::Filter.new(
|
20
|
+
property_name: 'hs_object_id',
|
21
|
+
operator: 'GT',
|
22
|
+
value: @after
|
23
|
+
)
|
24
|
+
filter_group = ::Hubspot::Crm::Contacts::FilterGroup.new(filters: [filter])
|
25
|
+
::Hubspot::Crm::Contacts::PublicObjectSearchRequest.new(
|
26
|
+
query: @search_query,
|
27
|
+
limit: @limit,
|
28
|
+
filter_groups: [filter_group],
|
29
|
+
sorts: [{'propertyName' => 'hs_object_id', 'direction' => 'ASCENDING'}]
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Services
|
2
|
+
module Hubspot
|
3
|
+
module Properties
|
4
|
+
class Create
|
5
|
+
def initialize(params)
|
6
|
+
@params = params
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
core_api = ::Hubspot::Crm::Properties::CoreApi.new
|
11
|
+
params = { auth_names: 'oauth2', body: property_create }
|
12
|
+
core_api.create('contact',params)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def property_create
|
18
|
+
@property_create ||= ::Hubspot::Crm::Properties::PropertyCreate.new(@params)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Services
|
2
|
+
module Hubspot
|
3
|
+
module Properties
|
4
|
+
class Destroy
|
5
|
+
def initialize(name)
|
6
|
+
@name = name
|
7
|
+
end
|
8
|
+
|
9
|
+
def call
|
10
|
+
core_api = ::Hubspot::Crm::Properties::CoreApi.new
|
11
|
+
core_api.archive('contact', @name, auth_names: 'oauth2')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|