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

Extract other CRUDL api operations from mixins #1323

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 61 additions & 1 deletion lib/stripe/resources/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module Stripe
# account has started to go through Connect Onboarding. Once you create an [Account Link](https://stripe.com/docs/api/account_links) or [Account Session](https://stripe.com/docs/api/account_sessions),
# some properties are only returned for Custom accounts. Learn about the differences [between accounts](https://stripe.com/docs/connect/accounts).
class Account < APIResource
extend Gem::Deprecate
anniel-stripe marked this conversation as resolved.
Show resolved Hide resolved
extend Stripe::APIOperations::Create
include Stripe::APIOperations::Delete
extend Stripe::APIOperations::List
Expand Down Expand Up @@ -195,5 +194,66 @@ def deauthorize(client_id = nil, opts = {})
end
update_hash
end

# With [Connect](https://stripe.com/docs/connect), you can create Stripe accounts for your users.
# To do this, you'll first need to [register your platform](https://dashboard.stripe.com/account/applications/settings).
#
# If you've already collected information for your connected accounts, you [can prefill that information](https://stripe.com/docs/connect/best-practices#onboarding) when
# creating the account. Connect Onboarding won't ask for the prefilled information during account onboarding.
# You can prefill any information on the account.
def self.create(params = {}, opts = {})
request_stripe_object(method: :post, path: "/v1/accounts", params: params, opts: opts)
end

# With [Connect](https://stripe.com/docs/connect), you can delete accounts you manage.
#
# Accounts created using test-mode keys can be deleted at any time. Standard accounts created using live-mode keys cannot be deleted. Custom or Express accounts created using live-mode keys can only be deleted once all balances are zero.
#
# If you want to delete your own account, use the [account information tab in your account settings](https://dashboard.stripe.com/settings/account) instead.
def self.delete(id, params = {}, opts = {})
request_stripe_object(
method: :delete,
path: format("/v1/accounts/%<id>s", { id: CGI.escape(id) }),
params: params,
opts: opts
)
end

# With [Connect](https://stripe.com/docs/connect), you can delete accounts you manage.
#
# Accounts created using test-mode keys can be deleted at any time. Standard accounts created using live-mode keys cannot be deleted. Custom or Express accounts created using live-mode keys can only be deleted once all balances are zero.
#
# If you want to delete your own account, use the [account information tab in your account settings](https://dashboard.stripe.com/settings/account) instead.
def delete(params = {}, opts = {})
request_stripe_object(
method: :delete,
path: format("/v1/accounts/%<account>s", { account: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end

# Returns a list of accounts connected to your platform via [Connect](https://stripe.com/docs/connect). If you're not a platform, the list is empty.
def self.list(filters = {}, opts = {})
request_stripe_object(method: :get, path: "/v1/accounts", params: filters, opts: opts)
end

# Updates a [connected account](https://stripe.com/docs/connect/accounts) by setting the values of the parameters passed. Any parameters not provided are
# left unchanged.
#
# For Custom accounts, you can update any information on the account. For other accounts, you can update all information until that
# account has started to go through Connect Onboarding. Once you create an [Account Link or <a href="/docs/api/account_sessions">Account Session](https://stripe.com/docs/api/account_links),
# some properties can only be changed or updated for Custom accounts.
#
# To update your own account, use the [Dashboard](https://dashboard.stripe.com/settings/account). Refer to our
# [Connect](https://stripe.com/docs/connect/updating-accounts) documentation to learn more about updating accounts.
def self.update(id, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/accounts/%<id>s", { id: CGI.escape(id) }),
params: params,
opts: opts
)
end
end
end
5 changes: 5 additions & 0 deletions lib/stripe/resources/account_link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@ class AccountLink < APIResource
extend Stripe::APIOperations::Create

OBJECT_NAME = "account_link"

# Creates an AccountLink object that includes a single-use Stripe URL that the platform can redirect their user to in order to take them through the Connect Onboarding flow.
def self.create(params = {}, opts = {})
request_stripe_object(method: :post, path: "/v1/account_links", params: params, opts: opts)
end
end
end
5 changes: 5 additions & 0 deletions lib/stripe/resources/account_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@ class AccountSession < APIResource
extend Stripe::APIOperations::Create

OBJECT_NAME = "account_session"

# Creates a AccountSession object that includes a single-use token that the platform can use on their front-end to grant client-side API access.
def self.create(params = {}, opts = {})
request_stripe_object(method: :post, path: "/v1/account_sessions", params: params, opts: opts)
end
end
end
40 changes: 40 additions & 0 deletions lib/stripe/resources/apple_pay_domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,45 @@ class ApplePayDomain < APIResource
def self.resource_url
"/v1/apple_pay/domains"
end

# Create an apple pay domain.
def self.create(params = {}, opts = {})
request_stripe_object(
method: :post,
path: "/v1/apple_pay/domains",
params: params,
opts: opts
)
end

# Delete an apple pay domain.
def self.delete(id, params = {}, opts = {})
request_stripe_object(
method: :delete,
path: format("/v1/apple_pay/domains/%<id>s", { id: CGI.escape(id) }),
params: params,
opts: opts
)
end

# Delete an apple pay domain.
def delete(params = {}, opts = {})
request_stripe_object(
method: :delete,
path: format("/v1/apple_pay/domains/%<domain>s", { domain: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end

# List apple pay domains.
def self.list(filters = {}, opts = {})
request_stripe_object(
method: :get,
path: "/v1/apple_pay/domains",
params: filters,
opts: opts
)
end
end
end
5 changes: 5 additions & 0 deletions lib/stripe/resources/application_fee.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,10 @@ class ApplicationFee < APIResource
OBJECT_NAME = "application_fee"

nested_resource_class_methods :refund, operations: %i[create retrieve update list]

# Returns a list of application fees you've previously collected. The application fees are returned in sorted order, with the most recent fees appearing first.
def self.list(filters = {}, opts = {})
request_stripe_object(method: :get, path: "/v1/application_fees", params: filters, opts: opts)
end
end
end
10 changes: 10 additions & 0 deletions lib/stripe/resources/apps/secret.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ def self.find(params = {}, opts = {})
opts: opts
)
end

# Create or replace a secret in the secret store.
def self.create(params = {}, opts = {})
request_stripe_object(method: :post, path: "/v1/apps/secrets", params: params, opts: opts)
end

# List all secrets stored on the given scope.
def self.list(filters = {}, opts = {})
request_stripe_object(method: :get, path: "/v1/apps/secrets", params: filters, opts: opts)
end
end
end
end
12 changes: 12 additions & 0 deletions lib/stripe/resources/balance_transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,17 @@ class BalanceTransaction < APIResource
extend Stripe::APIOperations::List

OBJECT_NAME = "balance_transaction"

# Returns a list of transactions that have contributed to the Stripe account balance (e.g., charges, transfers, and so forth). The transactions are returned in sorted order, with the most recent transactions appearing first.
#
# Note that this endpoint was previously called “Balance history” and used the path /v1/balance/history.
def self.list(filters = {}, opts = {})
request_stripe_object(
method: :get,
path: "/v1/balance_transactions",
params: filters,
opts: opts
)
end
end
end
27 changes: 27 additions & 0 deletions lib/stripe/resources/bank_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,32 @@ def self.retrieve(_id, _opts = nil)
"or `Account.retrieve_external_account('account_id', " \
"'bank_account_id')`"
end

def self.delete(id, params = {}, opts = {})
request_stripe_object(
method: :delete,
path: "#{resource_url}/#{id}",
params: params,
opts: opts
)
end

def delete(params = {}, opts = {})
request_stripe_object(
method: :delete,
path: resource_url.to_s,
params: params,
opts: opts
)
end

def self.list(filters = {}, opts = {})
request_stripe_object(
method: :delete,
path: resource_url.to_s,
params: filters,
opts: opts
)
end
end
end
30 changes: 30 additions & 0 deletions lib/stripe/resources/billing_portal/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,36 @@ class Configuration < APIResource
include Stripe::APIOperations::Save

OBJECT_NAME = "billing_portal.configuration"

# Creates a configuration that describes the functionality and behavior of a PortalSession
def self.create(params = {}, opts = {})
request_stripe_object(
method: :post,
path: "/v1/billing_portal/configurations",
params: params,
opts: opts
)
end

# Returns a list of configurations that describe the functionality of the customer portal.
def self.list(filters = {}, opts = {})
request_stripe_object(
method: :get,
path: "/v1/billing_portal/configurations",
params: filters,
opts: opts
)
end

# Updates a configuration that describes the functionality of the customer portal.
def self.update(id, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/billing_portal/configurations/%<id>s", { id: CGI.escape(id) }),
params: params,
opts: opts
)
end
end
end
end
10 changes: 10 additions & 0 deletions lib/stripe/resources/billing_portal/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ class Session < APIResource
extend Stripe::APIOperations::Create

OBJECT_NAME = "billing_portal.session"

# Creates a session of the customer portal.
def self.create(params = {}, opts = {})
request_stripe_object(
method: :post,
path: "/v1/billing_portal/sessions",
params: params,
opts: opts
)
end
end
end
end
27 changes: 27 additions & 0 deletions lib/stripe/resources/card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,32 @@ def self.retrieve(_id, _opts = nil)
"'customer_id', 'card_id')` or " \
"`Account.retrieve_external_account('account_id', 'card_id')`"
end

def self.delete(id, params = {}, opts = {})
request_stripe_object(
method: :delete,
path: "#{resource_url}/#{id}",
params: params,
opts: opts
)
end

def delete(params = {}, opts = {})
request_stripe_object(
method: :delete,
path: resource_url.to_s,
params: params,
opts: opts
)
end

def self.list(filters = {}, opts = {})
request_stripe_object(
method: :delete,
path: resource_url.to_s,
params: filters,
opts: opts
)
end
end
end
22 changes: 22 additions & 0 deletions lib/stripe/resources/charge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,34 @@ def self.capture(charge, params = {}, opts = {})
)
end

# This method is no longer recommended—use the [Payment Intents API](https://stripe.com/docs/api/payment_intents)
# to initiate a new payment instead. Confirmation of the PaymentIntent creates the Charge
# object used to request payment.
def self.create(params = {}, opts = {})
request_stripe_object(method: :post, path: "/v1/charges", params: params, opts: opts)
end

# Returns a list of charges you've previously created. The charges are returned in sorted order, with the most recent charges appearing first.
def self.list(filters = {}, opts = {})
request_stripe_object(method: :get, path: "/v1/charges", params: filters, opts: opts)
end

def self.search(params = {}, opts = {})
request_stripe_object(method: :get, path: "/v1/charges/search", params: params, opts: opts)
end

def self.search_auto_paging_each(params = {}, opts = {}, &blk)
search(params, opts).auto_paging_each(&blk)
end

# Updates the specified charge by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
def self.update(id, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/charges/%<id>s", { id: CGI.escape(id) }),
params: params,
opts: opts
)
end
end
end
20 changes: 20 additions & 0 deletions lib/stripe/resources/checkout/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,26 @@ def self.list_line_items(session, params = {}, opts = {})
opts: opts
)
end

# Creates a Session object.
def self.create(params = {}, opts = {})
request_stripe_object(
method: :post,
path: "/v1/checkout/sessions",
params: params,
opts: opts
)
end

# Returns a list of Checkout Sessions.
def self.list(filters = {}, opts = {})
request_stripe_object(
method: :get,
path: "/v1/checkout/sessions",
params: filters,
opts: opts
)
end
end
end
end
22 changes: 22 additions & 0 deletions lib/stripe/resources/climate/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,28 @@ def self.cancel(order, params = {}, opts = {})
opts: opts
)
end

# Creates a Climate order object for a given Climate product. The order will be processed immediately
# after creation and payment will be deducted your Stripe balance.
def self.create(params = {}, opts = {})
request_stripe_object(method: :post, path: "/v1/climate/orders", params: params, opts: opts)
end

# Lists all Climate order objects. The orders are returned sorted by creation date, with the
# most recently created orders appearing first.
def self.list(filters = {}, opts = {})
request_stripe_object(method: :get, path: "/v1/climate/orders", params: filters, opts: opts)
end

# Updates the specified order by setting the values of the parameters passed.
def self.update(id, params = {}, opts = {})
request_stripe_object(
method: :post,
path: format("/v1/climate/orders/%<id>s", { id: CGI.escape(id) }),
params: params,
opts: opts
)
end
end
end
end
Loading
Loading