hubspot-api-client 17.0.0.pre.beta.4 → 17.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2c752c107b386d795312696c8189ae9f8df886d2a8f8ef8598724b5411e92e6
4
- data.tar.gz: 5887a6799cd014e69612817eb022d45e7c9324d1438770c937225c499c17a06b
3
+ metadata.gz: abbad95ec7ed2eab3eec2d180f721b54f7de216328c1df44670c32b3e14a882e
4
+ data.tar.gz: 0ac955e55206a6cd81881825c3f2669eb8cc5a792af273cb24cfaf1342230d6f
5
5
  SHA512:
6
- metadata.gz: 04a06eca1bbb17c4e71ed4c209f1637bead5e1afb318add65d80f14fa940551a784d2507d39644f25b4cd6f973e0b78ad0685482d474785019e5d8967003c0e8
7
- data.tar.gz: 902eaeb25c0d10fdced246c6b7d18b325633b049d07bedd3cb105816b6702f12c3fde6be5625a7f6fc8e7fc6fe63ce63551e56c7743603a00b1db1db95a2de2f
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.pre.beta.4...HEAD)
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hubspot-api-client (17.0.0.pre.beta.4)
4
+ hubspot-api-client (17.0.0)
5
5
  json (~> 2.1, >= 2.1.0)
6
6
  typhoeus (~> 1.4.0)
7
7
 
@@ -19,7 +19,7 @@ module Hubspot
19
19
  events
20
20
  files
21
21
  marketing
22
- o_auth
22
+ oauth
23
23
  settings
24
24
  webhooks
25
25
  ].freeze
@@ -13,10 +13,6 @@ module Hubspot
13
13
  tokens
14
14
  ].freeze
15
15
  end
16
-
17
- def discovery_module_path
18
- super.gsub('o_auth', 'oauth')
19
- end
20
16
  end
21
17
  end
22
18
  end
@@ -2,7 +2,11 @@ module Hubspot
2
2
  module Helpers
3
3
  class CamelCase
4
4
  def format(string)
5
- string.split('_').collect(&:capitalize).join
5
+ if string == 'oauth'
6
+ 'OAuth'
7
+ else
8
+ string.split('_').collect(&:capitalize).join
9
+ end
6
10
  end
7
11
  end
8
12
  end
@@ -8,12 +8,11 @@ module Hubspot
8
8
  end
9
9
 
10
10
  def require_with_mapping(path)
11
- require path.gsub('o_auth', 'oauth')
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')
@@ -2,7 +2,8 @@ module Hubspot
2
2
  module Helpers
3
3
  class SnakeCase
4
4
  def format(string)
5
- string.gsub(/::/, '/').
5
+ string.gsub('OAuth', 'Oauth').
6
+ gsub(/::/, '/').
6
7
  gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
7
8
  gsub(/([a-z\d])([A-Z])/,'\1_\2').
8
9
  tr("-", "_").
@@ -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:, redirect_uri:, scope:, optional_scope: [])
6
- query = URI.encode_www_form(
7
- client_id: client_id,
8
- redirect_uri: redirect_uri,
9
- scope: Array(scope),
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
- "#{AUTHORIZE_URL}?#{query}"
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
@@ -1,3 +1,3 @@
1
1
  module Hubspot
2
- VERSION = '17.0.0.pre.beta.4'
2
+ VERSION = '17.0.0'
3
3
  end
@@ -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(:o_auth) }
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').o_auth.access_tokens_api }
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').o_auth.refresh_tokens_api }
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').o_auth.tokens_api }
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.pre.beta.4
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-05-17 00:00:00.000000000 Z
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: 1.3.1
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