Skip to content

Commit

Permalink
Codegen for openapi v154 (#1070)
Browse files Browse the repository at this point in the history
  • Loading branch information
pakrym-stripe authored Jun 9, 2022
1 parent ad84b25 commit 001db8b
Show file tree
Hide file tree
Showing 34 changed files with 816 additions and 183 deletions.
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v152
v154
27 changes: 22 additions & 5 deletions lib/stripe/resources/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ class Account < APIResource

OBJECT_NAME = "account"

custom_method :persons, http_verb: :get
custom_method :reject, http_verb: :post

nested_resource_class_methods :capability,
operations: %i[retrieve update list],
resource_plural: "capabilities"
Expand All @@ -24,7 +21,7 @@ class Account < APIResource
def persons(params = {}, opts = {})
request_stripe_object(
method: :get,
path: resource_url + "/persons",
path: format("/v1/accounts/%<account>s/persons", { account: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
Expand All @@ -33,12 +30,32 @@ def persons(params = {}, opts = {})
def reject(params = {}, opts = {})
request_stripe_object(
method: :post,
path: resource_url + "/reject",
path: format("/v1/accounts/%<account>s/reject", { account: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end

def self.persons(account, params = {}, opts = {})
resp, opts = execute_resource_request(
:get,
format("/v1/accounts/%<account>s/persons", { account: CGI.escape(account) }),
params,
opts
)
Util.convert_to_stripe_object(resp.data, opts)
end

def self.reject(account, params = {}, opts = {})
resp, opts = execute_resource_request(
:post,
format("/v1/accounts/%<account>s/reject", { account: CGI.escape(account) }),
params,
opts
)
Util.convert_to_stripe_object(resp.data, opts)
end

save_nested_resource :external_account

nested_resource_class_methods :external_account,
Expand Down
4 changes: 2 additions & 2 deletions lib/stripe/resources/apps/secret.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Secret < APIResource
def self.delete_where(params = {}, opts = {})
resp, opts = execute_resource_request(
:post,
resource_url + "/delete",
"/v1/apps/secrets/delete",
params,
opts
)
Expand All @@ -22,7 +22,7 @@ def self.delete_where(params = {}, opts = {})
def self.find(params = {}, opts = {})
resp, opts = execute_resource_request(
:get,
resource_url + "/find",
"/v1/apps/secrets/find",
params,
opts
)
Expand Down
14 changes: 11 additions & 3 deletions lib/stripe/resources/charge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,25 @@ class Charge < APIResource

OBJECT_NAME = "charge"

custom_method :capture, http_verb: :post

def capture(params = {}, opts = {})
request_stripe_object(
method: :post,
path: resource_url + "/capture",
path: format("/v1/charges/%<charge>s/capture", { charge: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end

def self.capture(charge, params = {}, opts = {})
resp, opts = execute_resource_request(
:post,
format("/v1/charges/%<charge>s/capture", { charge: CGI.escape(charge) }),
params,
opts
)
Util.convert_to_stripe_object(resp.data, opts)
end

def self.search(params = {}, opts = {})
_search("/v1/charges/search", params, opts)
end
Expand Down
14 changes: 11 additions & 3 deletions lib/stripe/resources/checkout/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,26 @@ class Session < APIResource

OBJECT_NAME = "checkout.session"

custom_method :expire, http_verb: :post

nested_resource_class_methods :line_item, operations: %i[list]

def expire(params = {}, opts = {})
request_stripe_object(
method: :post,
path: resource_url + "/expire",
path: format("/v1/checkout/sessions/%<session>s/expire", { session: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end

def self.expire(session, params = {}, opts = {})
resp, opts = execute_resource_request(
:post,
format("/v1/checkout/sessions/%<session>s/expire", { session: CGI.escape(session) }),
params,
opts
)
Util.convert_to_stripe_object(resp.data, opts)
end
end
end
end
14 changes: 11 additions & 3 deletions lib/stripe/resources/credit_note.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,25 @@ class CreditNote < APIResource

OBJECT_NAME = "credit_note"

custom_method :void_credit_note, http_verb: :post, http_path: "void"

def void_credit_note(params = {}, opts = {})
request_stripe_object(
method: :post,
path: resource_url + "/void",
path: format("/v1/credit_notes/%<id>s/void", { id: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end

def self.void_credit_note(id, params = {}, opts = {})
resp, opts = execute_resource_request(
:post,
format("/v1/credit_notes/%<id>s/void", { id: CGI.escape(id) }),
params,
opts
)
Util.convert_to_stripe_object(resp.data, opts)
end

def self.preview(params, opts = {})
resp, opts = execute_resource_request(:get, resource_url + "/preview", params, opts)
Util.convert_to_stripe_object(resp.data, opts)
Expand Down
27 changes: 22 additions & 5 deletions lib/stripe/resources/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ class Customer < APIResource

OBJECT_NAME = "customer"

custom_method :create_funding_instructions, http_verb: :post, http_path: "funding_instructions"
custom_method :list_payment_methods, http_verb: :get, http_path: "payment_methods"

nested_resource_class_methods :balance_transaction,
operations: %i[create retrieve update list]
nested_resource_class_methods :tax_id,
Expand All @@ -23,7 +20,7 @@ class Customer < APIResource
def create_funding_instructions(params = {}, opts = {})
request_stripe_object(
method: :post,
path: resource_url + "/funding_instructions",
path: format("/v1/customers/%<customer>s/funding_instructions", { customer: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
Expand All @@ -32,7 +29,7 @@ def create_funding_instructions(params = {}, opts = {})
def list_payment_methods(params = {}, opts = {})
request_stripe_object(
method: :get,
path: resource_url + "/payment_methods",
path: format("/v1/customers/%<customer>s/payment_methods", { customer: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
Expand All @@ -47,6 +44,26 @@ def retrieve_payment_method(payment_method, params = {}, opts = {})
)
end

def self.create_funding_instructions(customer, params = {}, opts = {})
resp, opts = execute_resource_request(
:post,
format("/v1/customers/%<customer>s/funding_instructions", { customer: CGI.escape(customer) }),
params,
opts
)
Util.convert_to_stripe_object(resp.data, opts)
end

def self.list_payment_methods(customer, params = {}, opts = {})
resp, opts = execute_resource_request(
:get,
format("/v1/customers/%<customer>s/payment_methods", { customer: CGI.escape(customer) }),
params,
opts
)
Util.convert_to_stripe_object(resp.data, opts)
end

def self.retrieve_payment_method(
customer,
payment_method,
Expand Down
14 changes: 11 additions & 3 deletions lib/stripe/resources/dispute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,23 @@ class Dispute < APIResource

OBJECT_NAME = "dispute"

custom_method :close, http_verb: :post

def close(params = {}, opts = {})
request_stripe_object(
method: :post,
path: resource_url + "/close",
path: format("/v1/disputes/%<dispute>s/close", { dispute: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end

def self.close(dispute, params = {}, opts = {})
resp, opts = execute_resource_request(
:post,
format("/v1/disputes/%<dispute>s/close", { dispute: CGI.escape(dispute) }),
params,
opts
)
Util.convert_to_stripe_object(resp.data, opts)
end
end
end
40 changes: 33 additions & 7 deletions lib/stripe/resources/financial_connections/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ class Account < APIResource

OBJECT_NAME = "financial_connections.account"

custom_method :disconnect, http_verb: :post
custom_method :list_owners, http_verb: :get, http_path: "owners"
custom_method :refresh_account, http_verb: :post, http_path: "refresh"

def disconnect(params = {}, opts = {})
request_stripe_object(
method: :post,
path: resource_url + "/disconnect",
path: format("/v1/financial_connections/accounts/%<account>s/disconnect", { account: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
Expand All @@ -24,7 +20,7 @@ def disconnect(params = {}, opts = {})
def list_owners(params = {}, opts = {})
request_stripe_object(
method: :get,
path: resource_url + "/owners",
path: format("/v1/financial_connections/accounts/%<account>s/owners", { account: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
Expand All @@ -33,11 +29,41 @@ def list_owners(params = {}, opts = {})
def refresh_account(params = {}, opts = {})
request_stripe_object(
method: :post,
path: resource_url + "/refresh",
path: format("/v1/financial_connections/accounts/%<account>s/refresh", { account: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end

def self.disconnect(account, params = {}, opts = {})
resp, opts = execute_resource_request(
:post,
format("/v1/financial_connections/accounts/%<account>s/disconnect", { account: CGI.escape(account) }),
params,
opts
)
Util.convert_to_stripe_object(resp.data, opts)
end

def self.list_owners(account, params = {}, opts = {})
resp, opts = execute_resource_request(
:get,
format("/v1/financial_connections/accounts/%<account>s/owners", { account: CGI.escape(account) }),
params,
opts
)
Util.convert_to_stripe_object(resp.data, opts)
end

def self.refresh_account(account, params = {}, opts = {})
resp, opts = execute_resource_request(
:post,
format("/v1/financial_connections/accounts/%<account>s/refresh", { account: CGI.escape(account) }),
params,
opts
)
Util.convert_to_stripe_object(resp.data, opts)
end
end
end
end
27 changes: 22 additions & 5 deletions lib/stripe/resources/identity/verification_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ class VerificationSession < APIResource

OBJECT_NAME = "identity.verification_session"

custom_method :cancel, http_verb: :post
custom_method :redact, http_verb: :post

def cancel(params = {}, opts = {})
request_stripe_object(
method: :post,
path: resource_url + "/cancel",
path: format("/v1/identity/verification_sessions/%<session>s/cancel", { session: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
Expand All @@ -25,11 +22,31 @@ def cancel(params = {}, opts = {})
def redact(params = {}, opts = {})
request_stripe_object(
method: :post,
path: resource_url + "/redact",
path: format("/v1/identity/verification_sessions/%<session>s/redact", { session: CGI.escape(self["id"]) }),
params: params,
opts: opts
)
end

def self.cancel(session, params = {}, opts = {})
resp, opts = execute_resource_request(
:post,
format("/v1/identity/verification_sessions/%<session>s/cancel", { session: CGI.escape(session) }),
params,
opts
)
Util.convert_to_stripe_object(resp.data, opts)
end

def self.redact(session, params = {}, opts = {})
resp, opts = execute_resource_request(
:post,
format("/v1/identity/verification_sessions/%<session>s/redact", { session: CGI.escape(session) }),
params,
opts
)
Util.convert_to_stripe_object(resp.data, opts)
end
end
end
end
Loading

0 comments on commit 001db8b

Please sign in to comment.