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

Add a README section for globally configuration an API version #643

Merged
merged 1 commit into from May 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 20 additions & 4 deletions README.md
Expand Up @@ -80,14 +80,20 @@ require "stripe"

Stripe::Charge.list(
{},
:api_key => "sk_test_...",
:stripe_account => "acct_..."
{
:api_key => "sk_test_...",
:stripe_account => "acct_...",
:stripe_version => "2018-02-28"
}
)

Stripe::Charge.retrieve(
"ch_18atAXCdGbJFKhCuBAa4532Z",
:api_key => "sk_test_...",
:stripe_account => "acct_..."
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the issue is that the Charge Retrieve API (And any retrieve) supports expand. And that would be in the first hash. So really the call should be

Stripe::Charge.retrieve(
  "ch_18atAXCdGbJFKhCuBAa4532Z",
  {}, // where expand would go
  {
    :api_key => "sk_test_...",
    :stripe_account => "acct_...",
    :stripe_version => "2018-02-28"
  }
)

right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, it's really bad that this is confusing to even us, but the correct invocation with an expansion is this (include both the retrieval ID and expand in one hash):

Stripe::Charge.retrieve( { id: "ch_1COBry2eZvKYlo2CmgIUoaBZ", expand: [:customer] }, { stripe_version: "2018-02-28" })

The method won't take three parameters:

[28] pry(main)> Stripe::Charge.retrieve("ch_1COBry2eZvKYlo2CmgIUoaBZ", {}, {})
ArgumentError: wrong number of arguments (3 for 1..2)
from /Users/brandur/stripe/stripe-ruby/lib/stripe/api_resource.rb:61:in `retrieve'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah damn it you're right I though it depended on the language but it does not.

:api_key => "sk_test_...",
:stripe_account => "acct_...",
:stripe_version => "2018-02-28"
}
)
```

Expand All @@ -108,6 +114,15 @@ end
puts resp.request_id
```

### Configuration an API Version

By default, the library will use the API version pinned to the account making
a request. This can be overridden with this global option:

Stripe.api_version = "2018-02-28"

See [versioning in the API reference][versioning] for more information.

### Configuring CA Bundles

By default, the library will use its own internal bundle of known CA
Expand Down Expand Up @@ -204,6 +219,7 @@ Update the bundled [stripe-mock] by editing the version number found in
[faraday]: https://github.com/lostisland/faraday
[idempotency-keys]: https://stripe.com/docs/api/ruby#idempotent_requests
[stripe-mock]: https://github.com/stripe/stripe-mock
[versioning]: https://stripe.com/docs/api/ruby#versioning

<!--
# vim: set tw=79:
Expand Down