640 Commits

Author SHA1 Message Date
Olivier Bellone
3bc4256e25
Bump version to 3.11.0 2018-02-26 13:30:29 +01:00
Olivier Bellone
3805968741
Add support for code attribute on all Stripe exceptions 2018-02-23 19:02:26 +01:00
Brandur
a7ea9cf1e9 Bump version to 3.10.0 2018-02-21 11:36:26 -08:00
Jamu Kakar
0be22683a3 Add support for /v1/topups endpoints. 2018-02-16 15:03:46 -08:00
Olivier Bellone
fafd449c5f
Bump version to 3.9.2 2018-02-12 11:32:24 -08:00
Olivier Bellone
5f1ddf2a96
Skip calling to_hash for nil 2018-02-12 11:20:19 -08:00
Brandur
f6484e3240 Bump version to 3.9.1 2017-12-15 00:47:53 -08:00
Olivier Bellone
b83a0e5583
Use duck typing to detect File-like objects 2017-12-14 19:54:47 +01:00
Brandur
bfbc4b7862 Bump version to 3.9.0 2017-12-08 10:48:47 -08:00
Brandur
3fc5e5b351 Introduce new IdempotencyError type
A few weeks back a new error type `idempotency_error` was introduced in
the API. I put it in to respond to #503, but then forgot to add support
for it in this library. This patch introduces a new exception class that
represents it.
2017-12-07 17:39:14 -08:00
Brandur
c36bf00151 Bump version to 3.8.2 2017-12-07 12:56:27 -08:00
Brandur
2bc471d501 Fix encoding of arrays that are sent in query strings
As discussed in #608, we currently have a problem where Faraday
deconstructs a query string that we encode and strips out any of the
array index numbers that we added. It's not too clear on why it does
this, but it appears to be built in at a pretty low level and hard to
change.

I spent a little time on this and it turns out that we can avoid the bad
code by depending on Faraday's `params` accessor on a request instead of
trying to do the encoding ourselves. Webmock has a pretty hard time
detecting the difference, but you can see some before and after encoding
here.

Before:

```
I, [2017-12-06T17:41:23.083942 #36737]  INFO -- : get
http://localhost:12111/v1/invoices/upcoming?customer=cus_123&subscription_items%5B%5D%5Bplan%5D=gold&subscription_items%5B%5D%5Bquantity%5D=2
```

After:

```
I, [2017-12-06T17:42:12.727752 #37158]  INFO -- : get
http://localhost:12111/v1/invoices/upcoming?customer=cus_123&subscription_items%5B0%5D%5Bplan%5D=gold&subscription_items%5B0%5D%5Bquantity%5D=2
```

Honestly, some of this can still use a lot of cleanup: it's weird that
we manually encode parameters ourselves for bodies, but not for queries;
but I think this'll fix the problem for now.

Fixes #608.
2017-12-07 10:51:07 -08:00
Brandur
ea426108f0 Bump version to 3.8.1 2017-12-06 10:16:11 -08:00
Olivier Bellone
949efb017d
Support Tempfiles in file_upload creation requests 2017-12-05 16:52:37 -08:00
Brandur
44e590fdb8 Bump version to 3.8.0 2017-10-31 08:49:33 -07:00
Olivier Bellone
b153b39203
Add support for exchange_rates API requests 2017-10-31 10:25:18 +01:00
Brandur
36e6c16cc8 Bump version to 3.7.0 2017-10-26 07:53:09 -07:00
Olivier Bellone
c455be74d4
Add support for listing source_transactions 2017-10-26 15:43:34 +02:00
Brandur
2a087595a9 Add explicit operations list everywhere
Makes the `operations` argument to `nested_resource_class_methods`
required and adds explicit lists to any invocations that were missing
one.

The impetus here is that I think it's more easily digestible if each
call site is explicit about what operations it supports and therefore
which methods it's about to create on the class.
2017-10-17 18:02:36 -07:00
Brandur
9ade60b082 Remove trailing whitespace 2017-10-17 18:01:56 -07:00
Brandur
53c2f1a760 Bump version to 3.6.0 2017-10-17 17:56:07 -07:00
Brandur
af51af2577 Add some documentation to NestedResource module 2017-10-17 17:52:35 -07:00
Brandur
cf5354cc27 Alphabetize inclusion order 2017-10-17 17:50:20 -07:00
Brandur
7699033d90 Merge pull request #597 from stripe/ob-nested-resource-class-methods
Nested resource class methods
2017-10-17 17:50:52 -07:00
Brandur
20f4feaec0 Bump version to 3.5.3 2017-10-16 13:13:41 -07:00
Brandur
5c3b741a2c Merge pull request #599 from stripe/brandur-dont-persist-idempotency-key
Don't persist `idempotency_key` option between API requests
2017-10-16 13:09:52 -07:00
Brandur
b4e64969cc Don't persist idempotency_key option between API requests
Excludes `idempotency_key` from opts to persist between API requests.
Obviously the same idempotency key is not something that we ever want to
use again.

Fixes #598.
2017-10-16 13:00:32 -07:00
Brandur
6dca58937d Merge require lists together + add uri
There's really no reason for these to have been two separate lists.
Also, add `uri` as an explicit dependency (so far it's been getting
included by luck with other libraries).
2017-10-16 12:32:18 -07:00
Brandur
e4af9ad820 Merge pull request #596 from stripe/ob-fix-554
Encode arrays as hashes when needed
2017-10-16 12:03:59 -07:00
Brandur
cfa6c2b8ae Merge pull request #595 from stripe/ob-fix-524
Call Object#method if method accessor is called with arguments
2017-10-16 12:01:07 -07:00
Olivier Bellone
7f866aab5c
Nested resource class methods 2017-10-15 18:49:13 +02:00
Olivier Bellone
4406f8e258
Call Object#method if method accessor is called with arguments 2017-10-14 23:00:40 +02:00
Olivier Bellone
de21302f4e
Encode arrays as hashes when needed 2017-10-14 17:48:20 +02:00
Olivier Bellone
c920a7c649
Maintain class in deep_copy 2017-10-14 01:05:06 +02:00
Brandur
c59c3661c6 Bump version to 3.5.2 2017-10-13 10:33:30 -07:00
Brandur
91099f9ee5 Implement custom Marshal encoder/decoder for StripeObject
Backtracks a little bit #586 by bringing back custom `StripeObject`
encoding and decoding methods for Ruby's `Marshal`. These work by just
persisting values and some opts, and skipping everything else. It's
mostly the same as what we had before, but implemented a little more
cleanly so that we don't actually need to invoke `Marshal` anywhere
ourselves.

In #586 we still managed to remove all the uses of `Marshal` in our own
codebase to make the linter happy. Even though we wouldn't recommend the
use of `Marshal`, this code at least enables it for anyone using a Rails
cache or similar mechanism.

Addresses #90.
2017-10-13 09:31:08 -07:00
Brandur
2a0df29bf4 Bump version to 3.5.1 2017-10-12 10:20:24 -07:00
Olivier Bellone
a210c5cd76
Ensure that each thread has its own client 2017-10-12 18:20:13 +02:00
Brandur
c251dfa952 Bump version to 3.5.0 2017-10-11 09:30:35 -07:00
Olivier Bellone
92e216634c
detach method for detaching sources from customers 2017-10-11 11:15:38 +02:00
Brandur
6bd1d6b9a0 Bump version to 3.4.1 2017-10-05 09:56:33 -07:00
Brandur
8ea866616b Log query string as well as body on log debug
This patch modifies the debugging-level logging logic slightly so that
if it's a `GET` request that includes a query string, we log that string
just like we would've for a request body on a `POST` or like.

This especially comes in handy when looking when trying to resolve
something like a problem with the upcoming invoices endpoint like we saw
in #576, but will be useful in a number of situations.
2017-10-04 13:00:35 -07:00
Brandur
3f454495bf Merge pull request #586 from stripe/brandur-remove-marshal
Implement deep copy for StripeObject and remove marshal/unmarshal
2017-09-29 07:13:32 -07:00
Brandur
80d85a522c Implement deep copy for StripeObject and remove marshal/unmarshal
We were previously using a bit of a hack to get a free deep copy
implementation through Ruby's marshaling framework. Lint call this out
as a security problem though, and rightfully so: when combined with
unsanitized user input, unmarshaling can result in very serious security
breaches involving arbitrary code execution.

This patch removes all uses of marshal/unmarshal in favor of
implementing a deep copy method for `StripeObject`. I also reworked some
of the constants around what keys are available for `opts`. I'm still
not completely happy with the results, but I think it's going to need a
slightly larger refactor in order to get somewhere truly good.

There is what could be a breaking change for people doing non-standard
stuff with the library: the opts that we copy with an object are now
whitelisted, so if they were being used to pass around extraneous data,
that might not work as expected anymore. But because this is a contract
that we never committed to, I don't think I'd bump the major version for
change.
2017-09-28 11:02:20 -07:00
Brandur
cb198baaa3 Remove Rubocop TODO around guard clauses
Removes Rubocop TODO around guard clauses and fixes the outstanding
offenses.

This is starting to get into territory that feels of more dubious value
to me, but at least it did get me writing a couple more tests, so let's
see how it goes by keeping this on.
2017-09-28 09:32:44 -07:00
Brandur
7f85eea3ee Fix low hanging Rubocop TODOs
I wanted to see what fixing Rubocop TODOs was like, so I tried to
eliminate all the easy ones. Most of these were pretty easy, and the
changes required are relatively minimal.

Some of the stuff left is harder. Pretty much everything under
`Metrics/*` is going to be a pretty big yak shave. A few of the others
are just going to need a little more work (e.g. `Style/ClassVars` and
`Style/GuardClause`). Going to stop here for now.
2017-09-27 15:07:18 -07:00
Olivier Bellone
e02ff7f849
Start using RuboCop for linting 2017-09-27 21:28:25 +02:00
Tim Maxwell
0b4ac62eae Remove recipient card tests 2017-09-20 14:03:00 -07:00
Tim Maxwell
d12fcdb862 Remove tests for legacy Bitcoin API 2017-09-20 13:48:05 -07:00
Brandur
ab1c971e8d Bump version to 3.3.2 2017-09-20 12:17:40 -07:00