Skip to content

Commit

Permalink
API Updates (#1010)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardm-stripe authored Oct 11, 2021
1 parent e534c87 commit 4c36bac
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ jobs:
with:
ruby-version: ${{ matrix.ruby-version }}
- name: Start stripe-mock
run: docker run -d -p 12111-12112:12111-12112 stripemock/stripe-mock && sleep 5
run: docker run -d -p 12111-12112:12111-12112 stripe/stripe-mock && sleep 5
- name: test
run: bundle install && bundle exec rake test
11 changes: 11 additions & 0 deletions lib/stripe/resources/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@ class Customer < APIResource

OBJECT_NAME = "customer"

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,
operations: %i[create retrieve delete list]

def list_payment_methods(params = {}, opts = {})
request_stripe_object(
method: :get,
path: resource_url + "/payment_methods",
params: params,
opts: opts
)
end

custom_method :delete_discount, http_verb: :delete, http_path: "discount"

save_nested_resource :source
Expand Down
6 changes: 6 additions & 0 deletions test/stripe/generated_examples_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ class CodegennedExampleTest < Test::Unit::TestCase
assert_requested :get, "#{Stripe.api_base}/v1/customers?limit=3"
end
end
context "Customer.list_payment_methods" do
should "support requests with args: customer, type" do
Stripe::Customer.list_payment_methods("cus_xyz", { type: "card" })
assert_requested :get, "#{Stripe.api_base}/v1/customers/cus_xyz/payment_methods?type=card"
end
end
context "Customer.retrieve" do
should "support requests with args: id" do
Stripe::Customer.retrieve("cus_xxxxxxxxxxxxx")
Expand Down

0 comments on commit 4c36bac

Please sign in to comment.