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

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf03f85e815cda2314c5d9433d05baf61dc9cff1578027fbf719df17346b2a22
4
- data.tar.gz: b10c430908fde3591fbe586ec97a1078ea4d5dfc6b5c151c02468d5650a76b61
3
+ metadata.gz: e2c752c107b386d795312696c8189ae9f8df886d2a8f8ef8598724b5411e92e6
4
+ data.tar.gz: 5887a6799cd014e69612817eb022d45e7c9324d1438770c937225c499c17a06b
5
5
  SHA512:
6
- metadata.gz: ba61d9af22ac49d15c2ca40bf8545bd036441eba289b13faa18d657717ae40bc5d2c830a220ac44fd625a31020bc7844d2bfd5a6ce84c6dd5ba8a7d02f239ac7
7
- data.tar.gz: 24b656e117c4d7515ef257ba111634ecff1267831934361bf59046090bfd3aabf20929b966dc041c3a548ede2aabce7770a31841c16988c297d54ffd032de766
6
+ metadata.gz: 04a06eca1bbb17c4e71ed4c209f1637bead5e1afb318add65d80f14fa940551a784d2507d39644f25b4cd6f973e0b78ad0685482d474785019e5d8967003c0e8
7
+ data.tar.gz: 902eaeb25c0d10fdced246c6b7d18b325633b049d07bedd3cb105816b6702f12c3fde6be5625a7f6fc8e7fc6fe63ce63551e56c7743603a00b1db1db95a2de2f
data/CHANGELOG.md CHANGED
@@ -5,9 +5,20 @@ 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-beta.3...HEAD)
8
+ ## [Unreleased](https://github.com/HubSpot/hubspot-api-ruby/compare/v17.0.0.pre.beta.4...HEAD)
9
9
 
10
10
 
11
+ ## [17.0.0.pre.beta.4] - 2023-05-17
12
+
13
+ ## Added
14
+
15
+ - added custom exceptions for Signature
16
+ - add associations types
17
+
18
+ ## Updated
19
+
20
+ - remove deprecated `validate_signature`
21
+
11
22
  ## [17.0.0-beta.3] - 2023-05-12
12
23
 
13
24
  ## 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-beta.3)
4
+ hubspot-api-client (17.0.0.pre.beta.4)
5
5
  json (~> 2.1, >= 2.1.0)
6
6
  typhoeus (~> 1.4.0)
7
7
 
@@ -1,14 +1,16 @@
1
1
  module Hubspot
2
2
  class ConfigurationError < StandardError; end
3
-
4
- class InvalidSignatureError < StandardError
5
- def initialize(msg: nil, signature: nil, signature_version: nil, hash_result: nil)
6
- @signature = signature
3
+ class InvalidSignatureVersionError < StandardError
4
+ def initialize(signature_version)
7
5
  @signature_version = signature_version
8
- @hash_result = hash_result
9
- msg = "Invalid signature passed to request" if msg.nil?
6
+ super("Invalid signature version passed to request: #{@signature_version}")
7
+ end
8
+ end
10
9
 
11
- super(msg)
10
+ class InvalidSignatureTimestampError < StandardError
11
+ def initialize(timestamp)
12
+ @timestamp = timestamp
13
+ super("Signature timestamp is invalid: #{@timestamp}.")
12
14
  end
13
15
  end
14
16
  end
@@ -0,0 +1,92 @@
1
+ module Hubspot
2
+ module Helpers
3
+ class AssociationType
4
+ PRIMARY_CONTACT_TO_COMPANY = 1
5
+ PRIMARY_COMPANY_TO_CONTACT = 2
6
+ DEAL_TO_CONTACT = 3
7
+ CONTACT_TO_DEAL = 4
8
+ PRIMARY_DEAL_TO_COMPANY = 5
9
+ PRIMARY_COMPANY_TO_DEAL = 6
10
+ CONTACT_TO_TICKET = 15
11
+ TICKET_TO_CONTACT = 16
12
+ DEAL_TO_LINE_ITEM = 19
13
+ LINE_ITEM_TO_DEAL = 20
14
+ PRIMARY_COMPANY_TO_TICKET = 25
15
+ PRIMARY_TICKET_TO_COMPANY = 26
16
+ DEAL_TO_TICKET = 27
17
+ TICKET_TO_DEAL = 28
18
+ DEAL_TO_QUOTE = 63
19
+ QUOTE_TO_DEAL = 64
20
+ QUOTE_TO_LINE_ITEM = 67
21
+ LINE_ITEM_TO_QUOTE = 68
22
+ QUOTE_TO_CONTACT = 69
23
+ CONTACT_TO_QUOTE = 70
24
+ QUOTE_TO_COMPANY = 71
25
+ COMPANY_TO_QUOTE = 72
26
+ CONTACT_TO_FEEDBACK_SUBMISSION = 97
27
+ FEEDBACK_SUBMISSION_TO_CONTACT = 98
28
+ TICKET_TO_FEEDBACK_SUBMISSION = 99
29
+ FEEDBACK_SUBMISSION_TO_TICKET = 100
30
+ COMPANY_TO_CALL = 181
31
+ CALL_TO_COMPANY = 182
32
+ COMPANY_TO_EMAIL = 185
33
+ EMAIL_TO_COMPANY = 186
34
+ COMPANY_TO_MEETING = 187
35
+ MEETING_TO_COMPANY = 188
36
+ COMPANY_TO_NOTE = 189
37
+ NOTE_TO_COMPANY = 190
38
+ COMPANY_TO_TASK = 191
39
+ TASK_TO_COMPANY = 192
40
+ CONTACT_TO_CALL = 193
41
+ CALL_TO_CONTACT = 194
42
+ CONTACT_TO_EMAIL = 197
43
+ EMAIL_TO_CONTACT = 198
44
+ CONTACT_TO_MEETING = 199
45
+ MEETING_TO_CONTACT = 200
46
+ CONTACT_TO_NOTE = 201
47
+ NOTE_TO_CONTACT = 202
48
+ CONTACT_TO_TASK = 203
49
+ TASK_TO_CONTACT = 204
50
+ DEAL_TO_CALL = 205
51
+ CALL_TO_DEAL = 206
52
+ DEAL_TO_EMAIL = 209
53
+ EMAIL_TO_DEAL = 210
54
+ DEAL_TO_MEETING = 211
55
+ MEETING_TO_DEAL = 212
56
+ DEAL_TO_NOTE = 213
57
+ NOTE_TO_DEAL = 214
58
+ DEAL_TO_TASK = 215
59
+ TASK_TO_DEAL = 216
60
+ QUOTE_TO_TASK = 217
61
+ TASK_TO_QUOTE = 218
62
+ TICKET_TO_CALL = 219
63
+ CALL_TO_TICKET = 220
64
+ TICKET_TO_EMAIL = 223
65
+ EMAIL_TO_TICKET = 224
66
+ TICKET_TO_MEETING = 225
67
+ MEETING_TO_TICKET = 226
68
+ TICKET_TO_NOTE = 227
69
+ NOTE_TO_TICKET = 228
70
+ TICKET_TO_TASK = 229
71
+ TASK_TO_TICKET = 230
72
+ CONTACT_TO_COMPANY = 279
73
+ COMPANY_TO_CONTACT = 280
74
+ TICKET_TO_COMPANY = 339
75
+ COMPANY_TO_TICKET = 340
76
+ DEAL_TO_COMPANY = 341
77
+ COMPANY_TO_DEAL = 342
78
+ CALL_TO_MEETING = 399
79
+ MEETING_TO_CALL = 400
80
+ POSTAL_MAIL_TO_CONTACT = 453
81
+ CONTACT_TO_POSTAL_MAIL = 454
82
+ POSTAL_MAIL_TO_TICKET = 455
83
+ TICKET_TO_POSTAL_MAIL = 456
84
+ POSTAL_MAIL_TO_DEAL = 457
85
+ DEAL_TO_POSTAL_MAIL = 458
86
+ POSTAL_MAIL_TO_COMPANY = 459
87
+ COMPANY_TO_POSTAL_MAIL = 460
88
+ end
89
+ end
90
+ end
91
+
92
+
@@ -17,7 +17,7 @@ module Hubspot
17
17
  if signature_version == "v3"
18
18
  current_time = DateTime.now.strftime("%s").to_i
19
19
  if current_time - timestamp.to_i > MAX_ALLOWED_TIMESTAMP
20
- raise StandardError("Timestamp is invalid, reject request.")
20
+ raise InvalidSignatureTimestampError.new(timestamp)
21
21
  end
22
22
  end
23
23
  hashed_signature = get_signature(
@@ -54,7 +54,7 @@ module Hubspot
54
54
  hash_result = OpenSSL::HMAC.base64digest('SHA256', client_secret, source_string.encode('utf-8'))
55
55
  return hash_result
56
56
  else
57
- raise StandardError("Not supported signature version: #{signature_version}")
57
+ raise InvalidSignatureVersionError.new(signature_version)
58
58
  end
59
59
  end
60
60
  end
@@ -1,3 +1,3 @@
1
1
  module Hubspot
2
- VERSION = '17.0.0-beta.3'
2
+ VERSION = '17.0.0.pre.beta.4'
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require 'date'
2
2
  require_relative "../../lib/hubspot/helpers/signature"
3
+ require_relative "../../lib/hubspot/exceptions"
3
4
 
4
5
  TEST_DATA = {
5
6
  :client_secret=> "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy",
@@ -49,7 +50,7 @@ describe "Hubspot::Helpers::Signature.get_signature" do
49
50
  client_secret: TEST_DATA[:client_secret],
50
51
  request_body: TEST_DATA[:request_body],
51
52
  signature_version: "wrong_signature_version"
52
- ) }.to raise_error(StandardError)
53
+ ) }.to raise_error(Hubspot::InvalidSignatureVersionError)
53
54
  end
54
55
 
55
56
  end
@@ -102,7 +103,7 @@ describe "Hubspot::Helpers::Signature.is_valid" do
102
103
  request_body: TEST_DATA[:request_body],
103
104
  http_uri: TEST_DATA[:http_uri],
104
105
  signature_version: "v3"
105
- ) }.to raise_error(StandardError)
106
+ ) }.to raise_error(Hubspot::InvalidSignatureTimestampError)
106
107
  end
107
108
  it "should raise exception if :signature_version=>v3 and :timestamp=>wrong_timestamp" do
108
109
  expect { signature.is_valid(
@@ -112,6 +113,6 @@ describe "Hubspot::Helpers::Signature.is_valid" do
112
113
  http_uri: TEST_DATA[:http_uri],
113
114
  timestamp: "wrong_timestamp",
114
115
  signature_version: "v3"
115
- ) }.to raise_error(StandardError)
116
+ ) }.to raise_error(Hubspot::InvalidSignatureTimestampError)
116
117
  end
117
118
  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.3
4
+ version: 17.0.0.pre.beta.4
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-12 00:00:00.000000000 Z
11
+ date: 2023-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -1783,12 +1783,12 @@ files:
1783
1783
  - lib/hubspot/discovery/webhooks/api/subscriptions_api.rb
1784
1784
  - lib/hubspot/discovery/webhooks/client.rb
1785
1785
  - lib/hubspot/exceptions.rb
1786
+ - lib/hubspot/helpers/association_type.rb
1786
1787
  - lib/hubspot/helpers/camel_case.rb
1787
1788
  - lib/hubspot/helpers/get_all_helper.rb
1788
1789
  - lib/hubspot/helpers/path.rb
1789
1790
  - lib/hubspot/helpers/signature.rb
1790
1791
  - lib/hubspot/helpers/snake_case.rb
1791
- - lib/hubspot/helpers/webhooks_helper.rb
1792
1792
  - lib/hubspot/oauth_helper.rb
1793
1793
  - lib/hubspot/version.rb
1794
1794
  - spec/discovery/automation/actions/callbacks_api_spec.rb
@@ -1,32 +0,0 @@
1
- # @deprecated
2
- module Hubspot
3
- module Helpers
4
- class WebhooksHelper
5
- def self.validate_signature(
6
- signature:,
7
- client_secret:,
8
- http_uri:,
9
- request_body:,
10
- http_method: 'POST',
11
- signature_version: 'v2'
12
- )
13
-
14
- if signature_version == 'v1'
15
- source_string = client_secret + request_body.to_s
16
- else
17
- source_string = client_secret + http_method + http_uri + request_body.to_s
18
- end
19
-
20
- hash_result = Digest::SHA2.hexdigest(source_string.encode('utf-8'))
21
-
22
- if hash_result != signature
23
- raise InvalidSignatureError.new(
24
- signature: signature,
25
- signature_version: signature_version,
26
- hash_result: hash_result
27
- )
28
- end
29
- end
30
- end
31
- end
32
- end