Skip to content

Commit

Permalink
Merge branch 'beta' into latest-codegen-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
pakrym-stripe authored Jan 25, 2024
2 parents afa13a5 + 452f8ca commit f84e115
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 10.7.0-beta.2 - 2024-01-19
* [#1307](https://github.com/stripe/stripe-ruby/pull/1307) Beta: report raw request usage


## 10.7.0-beta.1 - 2024-01-12
* [#1309](https://github.com/stripe/stripe-ruby/pull/1309) Update generated code for beta
* [#1305](https://github.com/stripe/stripe-ruby/pull/1305) Update generated code for beta
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.7.0-beta.1
10.7.0-beta.2
6 changes: 3 additions & 3 deletions lib/stripe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def initialize
@opts = {}
end

def execute(method, url, params = {}, opts = {})
resp, = execute_resource_request(method, url, params, opts)
def execute(method, url, params = {}, opts = {}, usage = [])
resp, = execute_resource_request(method, url, params, opts, usage)

resp
end
Expand All @@ -156,7 +156,7 @@ def execute(method, url, params = {}, opts = {})
# Sends a request to Stripe REST API
def self.raw_request(method, url, params = {}, opts = {})
req = RawRequest.new
req.execute(method, url, params, opts)
req.execute(method, url, params, opts, ["raw_request"])
end

def self.deserialize(data)
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Stripe
VERSION = "10.7.0-beta.1"
VERSION = "10.7.0-beta.2"
end
16 changes: 16 additions & 0 deletions test/stripe/raw_request_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,21 @@ class RawRequestTest < Test::Unit::TestCase

assert_equal stripe_version_override, req.headers["Stripe-Version"]
end
should "report usage" do
expected_body = "{\"id\": \"acc_123\"}"
telemetry_header = nil

Stripe.enable_telemetry = true

stub_request(:get, "#{Stripe.api_base}/v1/accounts/acc_124")
.with { |request| telemetry_header = request.headers["X-Stripe-Client-Telemetry"] }
.to_return(body: expected_body)

Stripe.raw_request(:get, "/v1/accounts/acc_123", {}, {})
Stripe.raw_request(:get, "/v1/accounts/acc_124", {}, {})
parsed_telemetry_header = JSON.parse(telemetry_header)

assert(parsed_telemetry_header["last_request_metrics"]["usage"] == ["raw_request"])
end
end
end

0 comments on commit f84e115

Please sign in to comment.