984 Commits

Author SHA1 Message Date
Remi Jannel
0632afb5be Fix payment intent methods to take extra parameters and remove delete 2018-08-28 15:55:19 -04:00
Tomer Elmalem
3a8f1d7172 Bump version to 3.24.0 2018-08-27 16:31:56 -07:00
tomer-stripe
0d7315f037
Merge pull request #675 from stripe/tomer-remove-edittable-bitcoin-receivers-actions
Remove ability to perform edit-actions on bitcoin receivers
2018-08-27 16:29:21 -07:00
Olivier Bellone
156145b96b
Merge pull request #677 from stripe/ob-prep-file
Use `::File` instead of `File`
2018-08-27 16:50:57 +02:00
Olivier Bellone
21db64fe0e
Use ::File instead of File 2018-08-27 15:32:10 +02:00
Olivier Bellone
a2f9822de7
Bump version to 3.23.0 2018-08-23 10:09:25 +02:00
Remi Jannel
f5dc3ab0c3 Add support for usage record summary 2018-08-21 08:56:18 -04:00
Tomer Elmalem
2da53af59b Remove ability to perform edit-actions on bitcoint receivers 2018-08-16 11:00:22 -07:00
Brandur
2b2c2c3cd6 Bump version to 3.22.0 2018-08-15 10:15:17 -07:00
Brandur
c1ff8bdc4c Integer-index encode all arrays
Changes all arrays from classic Rack encoding:

``` sh
arr[]=...&arr[]=...&arr[]=...
```

To integer-indexed encoding:

``` sh
arr[0]=...&arr[1]=...&arr[2]=...
```

We think that this should be tractable now that we've fully converted
all endpoints over to the new AbstractAPIMethod infrastructure on the
backend (although we should do a little more testing to make sure that
all endpoints still work).

As part of the conversion, we also remove any places that we were "spot
encoding" to get required integer-indexed syntax. This should now all be
built in.
2018-08-14 14:44:43 -07:00
Olivier Bellone
24143ab7d7
Bump version to 3.21.0 2018-08-03 15:48:21 +02:00
Olivier Bellone
d698bd6fc7
Add cancel support for topups 2018-08-03 12:50:39 +02:00
Olivier Bellone
7e914bc9cb
Bump version to 3.20.0 2018-08-03 12:26:19 +02:00
Olivier Bellone
9c357c803f
file_link support 2018-08-03 00:07:27 +02:00
Brandur
ebbce668fd Rubocop: Cap method length at 50 lines + disable module length
Remi pointed out in #666 that we basically just have to keep adding more
more onto the `Max` exception for both these rules every time we add a
new API resource.

Here I suggest that we modify the check on method length in two ways:

1. Permanently disable the cop on `Util.object_classes`. This is just
   going to keep growing until we change are approach to it.
2. Choose a more reasonable maximum of 50 lines for elsewhere (IMO, the
   default of 10 is just too short). Most of our methods already come in
   below this, but there's a couple outliers like `#execute_request` in
   `StripeClient`. If we knock over some of those, we could lower this
   number again, but I suspect that we'd probably want somewhere closer
   to 30 (instead of 10) event then.

I also disable the check on module length completely. I'm not convinced
this is a very good heuristic for code quality.
2018-07-27 17:13:07 -07:00
Brandur
4e3f38ec09 Bump version to 3.19.0 2018-07-27 17:01:39 -07:00
Remi Jannel
4c39c35fd8 Add support for ScheduledQueryRun 2018-07-27 19:14:37 -04:00
Brandur
ec5c51c3ba Very minor fix for alphabetical ordering 2018-07-26 11:32:35 -07:00
Brandur
3b0c34d53b Bump version to 3.18.0 2018-07-26 11:19:23 -07:00
Remi Jannel
04ae411754 Add support for Issuing resources 2018-07-26 13:35:50 -04:00
Brandur
7c9492b37d Bump version to 3.17.2 2018-07-19 09:56:15 -07:00
Brandur
b3eb5d3e30
Merge pull request #664 from jasonwebster/do_not_colorize_logger_logging
Do not colorize output destined for configured logger
2018-07-19 09:55:30 -07:00
Jason Webster
9d0cd25897 Do not colorize output destined for configured logger
This changes the predicate supplied to the #colorize method to ensure
that if a logger is set, the colorizing ANSI escape codes are not applied.

This definitely appears to have been the intention behind the original
implementation, but the tests didn't reflect how .log_internal was
actually called. In reality, it is always supplied with an `out:`
argument, not nil. This caused all logger bound output to also be
colorized.
2018-07-19 12:28:28 -04:00
Olivier Bellone
74b25a40dd
Bump version to 3.17.1 2018-07-19 16:42:10 +02:00
Olivier Bellone
b4e57ea981
Better resource_url method 2018-07-19 14:23:07 +02:00
Brandur
9e35a5e0d9 Bump version to 3.17.0 2018-06-28 08:57:18 -07:00
zach wick
ab3949b8da Adds support for 'partner_id' in 'set_app_info' (#658)
* Adds support for 'partner_id' in 'set_app_info'

Signed-off-by: zach wick <zwick@stripe.com>
2018-06-28 08:55:58 -07:00
Olivier Bellone
32151d5a31
Bump version to 3.16.0 2018-06-28 14:09:58 +02:00
Remi Jannel
201f9c29f4 Add support for the PaymentIntent resource
This feature is gated so the tests are stubbed for now
2018-06-27 19:24:23 -04:00
Brandur
02200e4c96 Add missing magic comment 2018-05-16 16:52:58 +02:00
Brandur
e8b272653e Bump version to 3.15.0 2018-05-10 15:42:50 -07:00
Brandur
863da48398 Add frozen_string_literal to every file and enforce Rubocop rule
Adds the magic `frozen_string_literal: true` comment to every file and
enables a Rubocop rule to make sure that it's always going to be there
going forward as well.

See here for more background [1], but the basic idea is that unlike many
other languages, static strings in code are mutable by default. This has
since been acknowledged as not a particularly good idea, and the
intention is to rectify the mistake when Ruby 3 comes out, where all
string literals will be frozen. The `frozen_string_literal` magic
comment was introduced in Ruby 2.3 as a way of easing the transition,
and allows libraries and projects to freeze their literals in advance.

I don't think this is breaking in any way: it's possible that users
might've been pulling out one of are literals somehow and mutating it,
but that would probably not have been useful for anything and would
certainly not be recommended, so I'm quite comfortable pushing this
change through as a minor version.

As discussed in #641.

[1] https://stackoverflow.com/a/37799399
2018-05-10 14:56:14 -07:00
Brandur
40e4883ddc Bump version to 3.14.0 2018-05-09 14:56:01 -07:00
Fay Wu
6ce45193d2 Add support for v1/issuer_fraud_records endpoints (#645) 2018-05-09 14:55:10 -07:00
Brandur
a44259b8f7 Bump version to 3.13.1 2018-05-07 15:11:56 -07:00
Brandur
3a2724bfcc Merge query parameters coming from path with params argument
If specifying both query parameters in a path/URL down to Faraday (e.g.,
`/v1/invoices/upcoming?coupon=25OFF`) _and_ query parameters in a hash
(e.g., `{ customer: "cus_123" }`), it will silently overwrite the ones
in the path with the ones in the hash. This can cause problems where
some critical parameters are discarded and causes an error, as seen in
issue #646.

This patch modifies `#execute_request` so that before going out to
Faraday we check whether the incoming path has query parameters. If it
does, we decode them and add them to our `query_params` hash so that
all parameters from either place are preserved.

Fixes #646.
2018-05-07 14:51:25 -07:00
Brandur
21b0514d1e Bump version to 3.13.0 2018-04-11 13:51:35 -07:00
Alexander Thiemann
c066c9c5f8 flexible billing primitives and tests 2018-04-11 13:29:24 -07:00
Brandur
f6e542e6ab Bump version to 3.12.1 2018-04-05 16:18:02 -07:00
Brandur
776d45f116 Initialize instance variable on the getter too
The test suite is currently throwing a bunch of warnings from some
recent changes I made -- although we initialize `@additive_params` when
setting one with `self.additive_object_param`, we don't when we check
one with `self.additive_object_param?`. This often isn't a problem
because every API resource sets `metadata`, but it is from the test
suite and probably for vanilla `StripeObject`s too.
2018-04-05 15:42:46 -07:00
Brandur
2f322cadb4 Bump version to 3.12.0 2018-04-05 07:17:58 -07:00
Brandur
39b80e518b Now that most hashes are non-additive, remove hack on subscription items
See the discussion here: https://github.com/stripe/stripe-ruby/pull/632
2018-04-05 07:10:15 -07:00
Brandur
5cfdf35d20 Introduce additive_object_param for use with metadata 2018-04-05 07:02:36 -07:00
Brandur
256556efa0 Fix replacement of non-metadata embedded StripeObjects
So we have a bit of a problem right now when it comes to replacing a
`StripeObject` that's embedded in an API resource.

Most of the time when someone does this, they want to _replace_ an
object embedded in another object. Take setting a source on a
subscription for example:

``` ruby
subscription.source = {
  object: 'card',
  number: 123,
}
subscription.save
```

In the case above, the serialized parameters should come out as:

```
source[object]=card&source[number]=123
```

That should apply even if the previous source had something else set on
it which we're not going to set this time -- say an optional parameter
like `source[address_state]`. Those should not be present at all in the
final serialized parameters.

(Another example is setting a `payout_schedule` as seen in #631 which is
PR is intended to address.)

There is an exception to this rule in the form of metadata though.
Metadata is a bit of a strange case in that the API will treat it as
additive, so if we send `metadata[foo]`, that will set the `foo` key,
but it won't overwrite any other keys that were already present.

This is a problem because when a user fully sets `metadata` to a new
object in Ruby, what they're probably trying to do is _replace_ it
rather than add to it. For example:

``` ruby
subscription.metadata
=> { old: 'bar' }

subscription.metadata = {
  new: 'baz'
}
subscription.save
```

To accomplish what the user is probably trying to do, we actually need
to send `metadata[old]=&metadata[new]=baz` so that we empty the value of
`old` while simultaneously setting `new` to `baz`.

In summary, metadata behaves different from other embedded objects in a
fairly fundamental way, and because the code is currently only set up to
handle the metadata case, it's not behaving correctly when other types
of objects are being set. A lot of the time emptying values like we do
for `metadata` is benign, but as we've seen in #631, sometimes it's not.

In this patch, I modify serialization to only empty out object values
when we see that parameter is `metadata`.

I'm really not crazy about the implementation here _at all_, but I'm
having trouble thinking of a better way to do it. One possibility is to
introduce a new class annotation like `empty_embedded_object :metadata`,
but that will have to go everywhere and might be error-prone in case
someone forgets it on a new resource type. If anyone has a suggestion
for an alternative (or can let me know if I'm missing something), I'd
love to hear it.

This PR is an alternate to #631.
2018-04-03 16:52:14 -07:00
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