hubspot-api-client 17.0.0.pre.beta.4 → 17.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/Gemfile.lock +1 -1
- data/lib/hubspot/client.rb +1 -1
- data/lib/hubspot/discovery/oauth/client.rb +0 -4
- data/lib/hubspot/helpers/camel_case.rb +5 -1
- data/lib/hubspot/helpers/path.rb +1 -2
- data/lib/hubspot/helpers/snake_case.rb +2 -1
- data/lib/hubspot/oauth_helper.rb +12 -8
- data/lib/hubspot/version.rb +1 -1
- data/spec/discovery/client_spec.rb +1 -1
- data/spec/discovery/oauth/access_tokens_api_spec.rb +1 -1
- data/spec/discovery/oauth/refresh_tokens_api_spec.rb +1 -1
- data/spec/discovery/oauth/tokens_api_spec.rb +1 -1
- data/spec/helpers/authorize_url_spec.rb +75 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abbad95ec7ed2eab3eec2d180f721b54f7de216328c1df44670c32b3e14a882e
|
4
|
+
data.tar.gz: 0ac955e55206a6cd81881825c3f2669eb8cc5a792af273cb24cfaf1342230d6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3961b180b6ca01a771749514c85d48cbca3b7ba18344038c39d2aed54c53389e6a3c1490a5f77913d67cbf9897ec9f101ac8ece545e528d0c2e54c73749c6da0
|
7
|
+
data.tar.gz: 579b92cbc0cb4c1db21a313866953d586a7e1c61ec200400265007625fcd5f817b6b4653c99e6d7ee6e5768a6685a036905391b83bde016b6c49daac4a985d41
|
data/CHANGELOG.md
CHANGED
@@ -5,9 +5,15 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
-
## [Unreleased](https://github.com/HubSpot/hubspot-api-ruby/compare/v17.0.0
|
8
|
+
## [Unreleased](https://github.com/HubSpot/hubspot-api-ruby/compare/v17.0.0...HEAD)
|
9
9
|
|
10
10
|
|
11
|
+
## [17.0.0.pre.beta.4] - 2023-06-14
|
12
|
+
|
13
|
+
## Updated
|
14
|
+
|
15
|
+
- Fix `Hubspot::OAuthHelper.authorize_url()` (don't add empty scopes or optional scopes to OAuth url)
|
16
|
+
|
11
17
|
## [17.0.0.pre.beta.4] - 2023-05-17
|
12
18
|
|
13
19
|
## Added
|
data/Gemfile.lock
CHANGED
data/lib/hubspot/client.rb
CHANGED
data/lib/hubspot/helpers/path.rb
CHANGED
@@ -8,12 +8,11 @@ module Hubspot
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def require_with_mapping(path)
|
11
|
-
require path
|
11
|
+
require path
|
12
12
|
end
|
13
13
|
|
14
14
|
def require_with_codegen_mapping(path)
|
15
15
|
require path
|
16
|
-
.gsub('o_auth', 'oauth')
|
17
16
|
.gsub('audit_logs/', 'audit-logs/')
|
18
17
|
.gsub('blog_posts/', 'blog-posts/')
|
19
18
|
.gsub('site_search', 'site-search')
|
data/lib/hubspot/oauth_helper.rb
CHANGED
@@ -2,15 +2,19 @@ module Hubspot
|
|
2
2
|
class OAuthHelper
|
3
3
|
AUTHORIZE_URL = 'https://app.hubspot.com/oauth/authorize'.freeze
|
4
4
|
class << self
|
5
|
-
def authorize_url(client_id
|
6
|
-
|
7
|
-
client_id
|
8
|
-
redirect_uri
|
9
|
-
|
10
|
-
optional_scope: Array(optional_scope)
|
11
|
-
)
|
5
|
+
def authorize_url(client_id, redirect_uri, scopes = nil, optional_scopes = nil, state = nil)
|
6
|
+
query_params = {
|
7
|
+
"client_id" => client_id,
|
8
|
+
"redirect_uri" => redirect_uri
|
9
|
+
}
|
12
10
|
|
13
|
-
"
|
11
|
+
query_params["scope"] = scopes.join(' ') if scopes
|
12
|
+
query_params["optional_scope"] = optional_scopes.join(' ') if optional_scopes
|
13
|
+
query_params['state'] ||= state if state
|
14
|
+
|
15
|
+
params = URI.encode_www_form(query_params)
|
16
|
+
|
17
|
+
"#{AUTHORIZE_URL}?#{params}"
|
14
18
|
end
|
15
19
|
end
|
16
20
|
end
|
data/lib/hubspot/version.rb
CHANGED
@@ -11,6 +11,6 @@ describe 'Hubspot::Client' do
|
|
11
11
|
it { is_expected.to respond_to(:events) }
|
12
12
|
it { is_expected.to respond_to(:files) }
|
13
13
|
it { is_expected.to respond_to(:marketing) }
|
14
|
-
it { is_expected.to respond_to(:
|
14
|
+
it { is_expected.to respond_to(:oauth) }
|
15
15
|
it { is_expected.to respond_to(:webhooks) }
|
16
16
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Hubspot::Discovery::OAuth::AccessTokensApi' do
|
4
|
-
subject(:api) { Hubspot::Client.new(access_token: 'test').
|
4
|
+
subject(:api) { Hubspot::Client.new(access_token: 'test').oauth.access_tokens_api }
|
5
5
|
|
6
6
|
it { is_expected.to respond_to(:get) }
|
7
7
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Hubspot::Discovery::OAuth::RefreshTokensApi' do
|
4
|
-
subject(:api) { Hubspot::Client.new(access_token: 'test').
|
4
|
+
subject(:api) { Hubspot::Client.new(access_token: 'test').oauth.refresh_tokens_api }
|
5
5
|
|
6
6
|
it { is_expected.to respond_to(:archive) }
|
7
7
|
it { is_expected.to respond_to(:get) }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Hubspot::Discovery::OAuth::TokensApi' do
|
4
|
-
subject(:api) { Hubspot::Client.new(access_token: 'test').
|
4
|
+
subject(:api) { Hubspot::Client.new(access_token: 'test').oauth.tokens_api }
|
5
5
|
|
6
6
|
it { is_expected.to respond_to(:create) }
|
7
7
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'rspec'
|
3
|
+
|
4
|
+
require_relative "../../lib/hubspot/oauth_helper"
|
5
|
+
|
6
|
+
describe 'get_auth_url' do
|
7
|
+
AUTHORIZE_URL = 'https://app.hubspot.com/oauth/authorize'
|
8
|
+
|
9
|
+
let(:data) do
|
10
|
+
{
|
11
|
+
client_id: 'client_id',
|
12
|
+
redirect_uri: 'http://localhost',
|
13
|
+
scope: ['contacts', 'timeline'],
|
14
|
+
optional_scope: ['scope1', 'scope3']
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'returns the correct URL with empty scope' do
|
19
|
+
expected_params = {
|
20
|
+
client_id: data[:client_id],
|
21
|
+
redirect_uri: data[:redirect_uri]
|
22
|
+
}
|
23
|
+
expected_url = "#{AUTHORIZE_URL}?#{URI.encode_www_form(expected_params)}"
|
24
|
+
|
25
|
+
result = Hubspot::OAuthHelper.authorize_url(data[:client_id], data[:redirect_uri])
|
26
|
+
|
27
|
+
expect(result).to eq(expected_url)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'returns the correct URL with scope' do
|
31
|
+
expected_params = {
|
32
|
+
client_id: data[:client_id],
|
33
|
+
redirect_uri: data[:redirect_uri],
|
34
|
+
scope: data[:scope].join(' ')
|
35
|
+
}
|
36
|
+
expected_url = "#{AUTHORIZE_URL}?#{URI.encode_www_form(expected_params)}"
|
37
|
+
|
38
|
+
result = Hubspot::OAuthHelper.authorize_url(data[:client_id], data[:redirect_uri], data[:scope])
|
39
|
+
|
40
|
+
expect(result).to eq(expected_url)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'returns the correct URL with optional_scope' do
|
44
|
+
expected_params = {
|
45
|
+
client_id: data[:client_id],
|
46
|
+
redirect_uri: data[:redirect_uri],
|
47
|
+
scope: data[:optional_scope].join(' ')
|
48
|
+
}
|
49
|
+
expected_url = "#{AUTHORIZE_URL}?#{URI.encode_www_form(expected_params)}"
|
50
|
+
|
51
|
+
result = Hubspot::OAuthHelper.authorize_url(data[:client_id], data[:redirect_uri], data[:optional_scope])
|
52
|
+
|
53
|
+
expect(result).to eq(expected_url)
|
54
|
+
end
|
55
|
+
it 'returns the correct URL' do
|
56
|
+
expected_params = {
|
57
|
+
client_id: data[:client_id],
|
58
|
+
redirect_uri: data[:redirect_uri],
|
59
|
+
scope: data[:scope].join(' '),
|
60
|
+
optional_scope: data[:optional_scope].join(' '),
|
61
|
+
state: "test_state"
|
62
|
+
}
|
63
|
+
expected_url = "#{AUTHORIZE_URL}?#{URI.encode_www_form(expected_params)}"
|
64
|
+
|
65
|
+
result = Hubspot::OAuthHelper.authorize_url(
|
66
|
+
data[:client_id],
|
67
|
+
data[:redirect_uri],
|
68
|
+
data[:scope],
|
69
|
+
data[:optional_scope],
|
70
|
+
"test_state"
|
71
|
+
)
|
72
|
+
|
73
|
+
expect(result).to eq(expected_url)
|
74
|
+
end
|
75
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hubspot-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 17.0.0
|
4
|
+
version: 17.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HubSpot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|
@@ -1939,6 +1939,7 @@ files:
|
|
1939
1939
|
- spec/discovery/settings/users/users_api_spec.rb
|
1940
1940
|
- spec/discovery/webhooks/settings_api_spec.rb
|
1941
1941
|
- spec/discovery/webhooks/subscriptions_api_spec.rb
|
1942
|
+
- spec/helpers/authorize_url_spec.rb
|
1942
1943
|
- spec/helpers/camel_case_spec.rb
|
1943
1944
|
- spec/helpers/signature_spec.rb
|
1944
1945
|
- spec/spec_helper.rb
|
@@ -1957,9 +1958,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1957
1958
|
version: '2.7'
|
1958
1959
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1959
1960
|
requirements:
|
1960
|
-
- - "
|
1961
|
+
- - ">="
|
1961
1962
|
- !ruby/object:Gem::Version
|
1962
|
-
version:
|
1963
|
+
version: '0'
|
1963
1964
|
requirements: []
|
1964
1965
|
rubygems_version: 3.2.3
|
1965
1966
|
signing_key:
|
@@ -2114,6 +2115,7 @@ test_files:
|
|
2114
2115
|
- spec/discovery/events/events_api_spec.rb
|
2115
2116
|
- spec/discovery/webhooks/settings_api_spec.rb
|
2116
2117
|
- spec/discovery/webhooks/subscriptions_api_spec.rb
|
2118
|
+
- spec/helpers/authorize_url_spec.rb
|
2117
2119
|
- spec/helpers/signature_spec.rb
|
2118
2120
|
- spec/helpers/camel_case_spec.rb
|
2119
2121
|
- spec/spec_helper.rb
|