Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update generated code for beta #1469

Merged
merged 12 commits into from
Oct 18, 2024
Merged
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1273
v1314
9 changes: 7 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
From the examples folder, run:
`RUBYLIB=../lib ruby your_example.rb`

e.g.

`RUBYLIB=../lib ruby thinevent_webhook_handler.rb`

## Adding a new example

1. Clone new_example.rb
2. Implement your example
3. Run it (as per above)
4. 👍
3. Fill out the file comment. Include a description and key steps that are being demonstrated.
4. Run it (as per above)
5. 👍
36 changes: 36 additions & 0 deletions examples/example_template.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true

# example_template.py - This is a template for defining new examples. It is not intended to be used directly.
#
# <describe what this example does>
#
# In this example, we:
# - <key step 1>
# - <key step 2
# - ...
#
# <describe assumptions about the user's stripe account, environment, or configuration;
# or things to watch out for when running>

require "stripe"
require "date"

class ExampleTemplate
attr_accessor :api_key

def initialize(api_key)
@api_key = api_key
end

def do_something_great
puts "Hello World"
# client = Stripe::StripeClient.new(api_key)
# client.v1
end
end

# Send meter events
api_key = "{{API_KEY}}"

example = ExampleTemplate.new(api_key)
example.do_something_great
10 changes: 10 additions & 0 deletions examples/meter_event_stream.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# frozen_string_literal: true

# meter_event_stream.py - use the high-throughput meter event stream to report create billing meter events.
#
# In this example, we:
# - create a meter event session and store the session's authentication token
# - define an event with a payload
# - use the meter_event_stream service accessor in StripeClient to create an event stream that reports this event
#
# This example expects a billing meter with an event_name of 'alpaca_ai_tokens'. If you have
# a different meter event name, you can change it before running this example.

require "stripe"
require "date"

Expand Down
24 changes: 0 additions & 24 deletions examples/new_example.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# frozen_string_literal: true
# typed: false

# thinevent_webhook_handler.rb - receive and process thin events like the
# v1.billing.meter.error_report_triggered event.
#
# In this example, we:
# - create a StripeClient called client
# - use client.parse_thin_event to parse the received thin event webhook body
# - call client.v2.core.events.retrieve to retrieve the full event object
# - if it is a V1BillingMeterErrorReportTriggeredEvent event type, call
# event.fetchRelatedObject to retrieve the Billing Meter object associated
# with the event.

require "stripe"
require "sinatra"

Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/billing/credit_balance_summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

module Stripe
module Billing
# Indicates the credit balance for credits granted to a customer.
# Indicates the billing credit balance for billing credits granted to a customer.
class CreditBalanceSummary < SingletonAPIResource
OBJECT_NAME = "billing.credit_balance_summary"
def self.object_name
Expand Down
5 changes: 4 additions & 1 deletion lib/stripe/resources/billing/credit_grant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

module Stripe
module Billing
# A credit grant is a resource that records a grant of some credit to a customer.
# A credit grant is an API resource that documents the allocation of some billing credits to a customer.
#
# Related guide: [Billing credits](https://docs.stripe.com/billing/subscriptions/usage-based/billing-credits)
# end
class CreditGrant < APIResource
extend Stripe::APIOperations::Create
extend Stripe::APIOperations::List
Expand Down
4 changes: 2 additions & 2 deletions lib/stripe/resources/issuing/card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def ship_card(params = {}, opts = {})
)
end

# Updates the shipping status of the specified Issuing Card object to submitted. This method is only available with Stripe Version ‘2024-09-30.acacia' or above.
# Updates the shipping status of the specified Issuing Card object to submitted. This method requires Stripe Version ‘2024-09-30.acacia' or later.
def self.submit_card(card, params = {}, opts = {})
request_stripe_object(
method: :post,
Expand All @@ -134,7 +134,7 @@ def self.submit_card(card, params = {}, opts = {})
)
end

# Updates the shipping status of the specified Issuing Card object to submitted. This method is only available with Stripe Version ‘2024-09-30.acacia' or above.
# Updates the shipping status of the specified Issuing Card object to submitted. This method requires Stripe Version ‘2024-09-30.acacia' or later.
def submit_card(params = {}, opts = {})
@resource.request_stripe_object(
method: :post,
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/resources/token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def self.object_name
end

# Creates a single-use token that represents a bank account's details.
# You can use this token with any API method in place of a bank account dictionary. You can only use this token once. To do so, attach it to a [connected account](https://stripe.com/docs/api#accounts) where [controller.requirement_collection](https://stripe.com/api/accounts/object#account_object-controller-requirement_collection) is application, which includes Custom accounts.
# You can use this token with any v1 API method in place of a bank account dictionary. You can only use this token once. To do so, attach it to a [connected account](https://stripe.com/docs/api#accounts) where [controller.requirement_collection](https://stripe.com/api/accounts/object#account_object-controller-requirement_collection) is application, which includes Custom accounts.
def self.create(params = {}, opts = {})
request_stripe_object(method: :post, path: "/v1/tokens", params: params, opts: opts)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/stripe/resources/v2/billing/meter_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ module V2
module Billing
# Fix me empty_doc_string.
class MeterEvent < APIResource
OBJECT_NAME = "billing.meter_event"
OBJECT_NAME = "v2.billing.meter_event"
def self.object_name
"billing.meter_event"
"v2.billing.meter_event"
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/stripe/resources/v2/billing/meter_event_adjustment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ module Stripe
module V2
module Billing
class MeterEventAdjustment < APIResource
OBJECT_NAME = "billing.meter_event_adjustment"
OBJECT_NAME = "v2.billing.meter_event_adjustment"
def self.object_name
"billing.meter_event_adjustment"
"v2.billing.meter_event_adjustment"
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/stripe/resources/v2/billing/meter_event_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ module Stripe
module V2
module Billing
class MeterEventSession < APIResource
OBJECT_NAME = "billing.meter_event_session"
OBJECT_NAME = "v2.billing.meter_event_session"
def self.object_name
"billing.meter_event_session"
"v2.billing.meter_event_session"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/services/test_helpers/issuing/card_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def ship_card(card, params = {}, opts = {})
)
end

# Updates the shipping status of the specified Issuing Card object to submitted. This method is only available with Stripe Version ‘2024-09-30.acacia' or above.
# Updates the shipping status of the specified Issuing Card object to submitted. This method requires Stripe Version ‘2024-09-30.acacia' or later.
def submit_card(card, params = {}, opts = {})
request(
method: :post,
Expand Down
2 changes: 1 addition & 1 deletion lib/stripe/services/token_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
module Stripe
class TokenService < StripeService
# Creates a single-use token that represents a bank account's details.
# You can use this token with any API method in place of a bank account dictionary. You can only use this token once. To do so, attach it to a [connected account](https://stripe.com/docs/api#accounts) where [controller.requirement_collection](https://stripe.com/api/accounts/object#account_object-controller-requirement_collection) is application, which includes Custom accounts.
# You can use this token with any v1 API method in place of a bank account dictionary. You can only use this token once. To do so, attach it to a [connected account](https://stripe.com/docs/api#accounts) where [controller.requirement_collection](https://stripe.com/api/accounts/object#account_object-controller-requirement_collection) is application, which includes Custom accounts.
def create(params = {}, opts = {})
request(method: :post, path: "/v1/tokens", params: params, opts: opts, base_address: :api)
end
Expand Down
2 changes: 1 addition & 1 deletion test/stripe/api_resource_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ def self.object_name

should "raise an NotImplementedError on refresh" do
stub_request(:post, "#{Stripe::DEFAULT_API_BASE}/v2/billing/meter_event_session")
.to_return(body: JSON.generate(object: "billing.meter_event_session"))
.to_return(body: JSON.generate(object: "v2.billing.meter_event_session"))

client = Stripe::StripeClient.new("sk_test_123")
session = client.v2.billing.meter_event_session.create
Expand Down
2 changes: 1 addition & 1 deletion test/stripe/stripe_service_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class StripeServiceTest < Test::Unit::TestCase

should "correctly deserialize v2 account object" do
stub_request(:post, "#{Stripe::DEFAULT_API_BASE}/v2/billing/meter_event_session")
.to_return(body: JSON.generate(object: "billing.meter_event_session"))
.to_return(body: JSON.generate(object: "v2.billing.meter_event_session"))

client = Stripe::StripeClient.new("sk_test_123")

Expand Down
Loading