increase 1.241.0 → 1.242.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a04be041eba6a264331c3d2790223aac3bcd162e58d41c948ee77895342f59ed
4
- data.tar.gz: acbd6d8dbf14a45bd3eca79fce36e3d6fbcd38cbc00fe9d7355133ee1269c7eb
3
+ metadata.gz: fce3493743b7f1e3f2193de6a7e044d9e7b987320e8eaec2715c6c19b26e87e6
4
+ data.tar.gz: 8a9a9b0689feff56ecd5005669356613b69a33f67e44e545ae1170d79dfa62e3
5
5
  SHA512:
6
- metadata.gz: 344aec2294c913273b00a4fcc7aba0ac974ced037aebd2048c5e60d482c925778ba7da9c98d909f11c50302022c3f945d9c2c0af4e72aa9f7d334d30d0cb29d2
7
- data.tar.gz: 73c02285fab40ef9d198665de68036fe6cda8c8a7d47167371497b57d54e2516d41706d8cbcfd699b07845a4cb712b2fa40d8eda8917a03db1d6266d242e8017
6
+ metadata.gz: 9f299a870b76d3fb04e30499ba66af6bf54dbd225d061846d4e519746ea6399e121302149124382ab46ca93cb6286820056949f5ed46c801cb1847e4d648d0bc
7
+ data.tar.gz: 02b939d5884249325b3f4d1a54d78603d421b26189c34fec5f0624e3aa017694933585c5b2dd053b9df1033d2108a1f90b745b7bb12a66f91c012393eb890be2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.242.0 (2026-03-11)
4
+
5
+ Full Changelog: [v1.241.0...v1.242.0](https://github.com/Increase/increase-ruby/compare/v1.241.0...v1.242.0)
6
+
7
+ ### Features
8
+
9
+ * **client:** add webhook support ([227d6ab](https://github.com/Increase/increase-ruby/commit/227d6ab8bec444b348c61ae7b85969cd38dcd764))
10
+
3
11
  ## 1.241.0 (2026-03-11)
4
12
 
5
13
  Full Changelog: [v1.240.0...v1.241.0](https://github.com/Increase/increase-ruby/compare/v1.240.0...v1.241.0)
data/README.md CHANGED
@@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
15
15
  <!-- x-release-please-start-version -->
16
16
 
17
17
  ```ruby
18
- gem "increase", "~> 1.241.0"
18
+ gem "increase", "~> 1.242.0"
19
19
  ```
20
20
 
21
21
  <!-- x-release-please-end -->
@@ -23,6 +23,9 @@ module Increase
23
23
  # @return [String]
24
24
  attr_reader :api_key
25
25
 
26
+ # @return [String, nil]
27
+ attr_reader :webhook_secret
28
+
26
29
  # @return [Increase::Resources::Accounts]
27
30
  attr_reader :accounts
28
31
 
@@ -210,6 +213,8 @@ module Increase
210
213
  #
211
214
  # @param api_key [String, nil] Defaults to `ENV["INCREASE_API_KEY"]`
212
215
  #
216
+ # @param webhook_secret [String, nil] Defaults to `ENV["INCREASE_WEBHOOK_SECRET"]`
217
+ #
213
218
  # @param environment [:production, :sandbox, nil] Specifies the environment to use for the API.
214
219
  #
215
220
  # Each environment maps to a different base URL:
@@ -231,6 +236,7 @@ module Increase
231
236
  # @param idempotency_header [String]
232
237
  def initialize(
233
238
  api_key: ENV["INCREASE_API_KEY"],
239
+ webhook_secret: ENV["INCREASE_WEBHOOK_SECRET"],
234
240
  environment: nil,
235
241
  base_url: ENV["INCREASE_BASE_URL"],
236
242
  max_retries: self.class::DEFAULT_MAX_RETRIES,
@@ -249,6 +255,7 @@ module Increase
249
255
  end
250
256
 
251
257
  @api_key = api_key.to_s
258
+ @webhook_secret = webhook_secret&.to_s
252
259
 
253
260
  super(
254
261
  base_url: base_url,
@@ -60,8 +60,18 @@ module Increase
60
60
 
61
61
  # @param payload [String] The raw webhook payload as a string
62
62
  #
63
+ # @param headers [Hash{String=>String}] The raw HTTP headers that came with the payload
64
+ #
65
+ # @param key [String, nil] The webhook signing key
66
+ #
63
67
  # @return [Increase::Models::UnwrapWebhookEvent]
64
- def unwrap(payload)
68
+ def unwrap(payload, headers:, key: @client.webhook_secret)
69
+ if key.nil?
70
+ raise ArgumentError.new("Cannot verify a webhook without a key on either the client's webhook_secret or passed in as an argument")
71
+ end
72
+
73
+ ::StandardWebhooks::Webhook.new(Base64.strict_encode64(key)).verify(payload, headers)
74
+
65
75
  parsed = JSON.parse(payload, symbolize_names: true)
66
76
  Increase::Internal::Type::Converter.coerce(Increase::Models::UnwrapWebhookEvent, parsed)
67
77
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Increase
4
- VERSION = "1.241.0"
4
+ VERSION = "1.242.0"
5
5
  end
data/lib/increase.rb CHANGED
@@ -30,6 +30,7 @@ end
30
30
 
31
31
  # Gems.
32
32
  require "connection_pool"
33
+ require "standardwebhooks"
33
34
 
34
35
  # Package files.
35
36
  require_relative "increase/version"
@@ -22,6 +22,9 @@ module Increase
22
22
  sig { returns(String) }
23
23
  attr_reader :api_key
24
24
 
25
+ sig { returns(T.nilable(String)) }
26
+ attr_reader :webhook_secret
27
+
25
28
  sig { returns(Increase::Resources::Accounts) }
26
29
  attr_reader :accounts
27
30
 
@@ -205,6 +208,7 @@ module Increase
205
208
  sig do
206
209
  params(
207
210
  api_key: T.nilable(String),
211
+ webhook_secret: T.nilable(String),
208
212
  environment: T.nilable(T.any(Symbol, String)),
209
213
  base_url: T.nilable(String),
210
214
  max_retries: Integer,
@@ -217,6 +221,8 @@ module Increase
217
221
  def self.new(
218
222
  # Defaults to `ENV["INCREASE_API_KEY"]`
219
223
  api_key: ENV["INCREASE_API_KEY"],
224
+ # Defaults to `ENV["INCREASE_WEBHOOK_SECRET"]`
225
+ webhook_secret: ENV["INCREASE_WEBHOOK_SECRET"],
220
226
  # Specifies the environment to use for the API.
221
227
  #
222
228
  # Each environment maps to a different base URL:
@@ -42,10 +42,20 @@ module Increase
42
42
  )
43
43
  end
44
44
 
45
- sig { params(payload: String).returns(Increase::UnwrapWebhookEvent) }
45
+ sig do
46
+ params(
47
+ payload: String,
48
+ headers: T::Hash[String, String],
49
+ key: T.nilable(String)
50
+ ).returns(Increase::UnwrapWebhookEvent)
51
+ end
46
52
  def unwrap(
47
53
  # The raw webhook payload as a string
48
- payload
54
+ payload,
55
+ # The raw HTTP headers that came with the payload
56
+ headers:,
57
+ # The webhook signing key
58
+ key: @client.webhook_secret
49
59
  )
50
60
  end
51
61
 
@@ -15,6 +15,8 @@ module Increase
15
15
 
16
16
  attr_reader api_key: String
17
17
 
18
+ attr_reader webhook_secret: String?
19
+
18
20
  attr_reader accounts: Increase::Resources::Accounts
19
21
 
20
22
  attr_reader account_numbers: Increase::Resources::AccountNumbers
@@ -135,6 +137,7 @@ module Increase
135
137
 
136
138
  def initialize: (
137
139
  ?api_key: String?,
140
+ ?webhook_secret: String?,
138
141
  ?environment: :production | :sandbox | nil,
139
142
  ?base_url: String?,
140
143
  ?max_retries: Integer,
@@ -15,7 +15,11 @@ module Increase
15
15
  ?request_options: Increase::request_opts
16
16
  ) -> Increase::Internal::Page[Increase::Event]
17
17
 
18
- def unwrap: (String payload) -> Increase::UnwrapWebhookEvent
18
+ def unwrap: (
19
+ String payload,
20
+ headers: ::Hash[String, String],
21
+ ?key: String?
22
+ ) -> Increase::UnwrapWebhookEvent
19
23
 
20
24
  def initialize: (client: Increase::Client) -> void
21
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: increase
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.241.0
4
+ version: 1.242.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Increase
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: standardwebhooks
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description:
42
56
  email: dev-feedback@increase.com
43
57
  executables: []