410 Commits

Author SHA1 Message Date
Brandur
395d16b8c1 Remove sorting hack from parameter encoding
I added this for a regression suite so that 1.8.7 could pass its tests,
but unfortunately this caused a regression in the way that parameters
are encoded for arrays of hashes. This patch reverts the change and adds
tests to detect a future regression.

(And 1.8.7 is expected to fail on this initial commit.)
2015-10-10 12:12:57 -07:00
Brandur
daf2789ad7 Pass through all paging filters to descendent pages
When additional filters were provided for pagination like an expansion
or a predicate, they would not propagate to any call after the first.
This patch addresses that issue by storing all filters and moving them
to any new page objects being created.

Fixes #331.
2015-10-09 13:58:23 -07:00
Brandur
cdb8599119 Bump version to 1.30.0 2015-10-09 10:45:25 -07:00
Brandur
900fa4b5dc Add StripeObject#deleted?
Adds a special helper to `StripeObject` that helps a developer to
determine whether or not an object is deleted.

As described originally in #257, this is a bit of a special case because
a non-deleted object does not respond with `deleted` as part of its
representation, so while a deleted object would have this accessor
available automatically, non-deleted objects would not. This made use of
the SDK awkward because the presence of the method was not guaranteed.

Fixes #257 (again, heh).
2015-10-09 10:16:59 -07:00
Brandur
b3912c1712 Merge branch 'brandur-deprecate-refresh-from'
Conflicts:
	lib/stripe/stripe_object.rb
2015-10-08 17:49:27 -07:00
Brandur
1a96d7cf8e Use Gem:: deprecation method instead of a custom one 2015-10-08 17:24:59 -07:00
Brandur
925066efd4 Remove outdated option 2015-10-08 14:44:42 -07:00
Brandur
11dd870900 Have StripeObject#update_attributes reflect behavior of accessors
This dials down the safety of `StripeObject`'s `#update_attributes`
method so that it allows properties to be assigned that it doesn't yet
know about. We're doing this for a few reasons:

1. To reflect the current behavior of accessors (i.e. `obj.name = ...`)
   through `method_missing`.
2. To allow `#update_attributes` to assign properties on new projects
   that don't yet know their schema from an API call.

Fixes #324.
2015-10-08 14:04:11 -07:00
Brandur
3468698ce9 Make 1.8 happy 2015-10-08 10:03:18 -07:00
Brandur
8b255c7005 Deprecate StripeObject#refresh_from
As discussed in #325, this deprecates the public visibility of
`#refresh_from` (by renaming it). It also adds some deprecation
infrastructure to produce warnings when it's used.
2015-10-08 09:57:16 -07:00
Brandur
e75fd86ae5 Fix miswording of error message 2015-10-08 07:39:56 -07:00
Brandur
eb8787754c Replace deprecated URI.escape with a customized CGI.escape
Replaces my original attempt in #319 in a way that doesn't depend on
`URI.encode_www_form` which doesn't exist in 1.8.7. This should
hopefully get us the best of all worlds.

Caveats around use of `+` instead of `%20` as detailed in #319 still
apply.

Fixes #286.
2015-10-06 14:46:58 -07:00
Brandur
91262c9042 Sort encoded parameters for stability in 1.8.7 tests 2015-10-06 14:17:51 -07:00
Brandur
a48fd12c70 Add regression suite for testing parameter encoding
Pulls the test suite out of #319 so that we can get some coverage around
parameter encoding. This should prevent any recurrence of #318.

Also includes a little bit of refactoring.
2015-10-06 14:04:02 -07:00
Brandur
b7d714b58e Bump version to 1.29.1 2015-10-06 13:40:13 -07:00
Brandur
d38250d717 Revert "Remove use of deprecated URI.escape" 2015-10-06 13:30:39 -07:00
Brandur
a2b56178fe Bump version to 1.29.0 2015-10-05 12:56:44 -07:00
Brandur
aa7e559115 Extend Stripe::APIOperations::Create instead of including
Lets not be too shy about just using `extend` instead of `include` here
when it's more appropriate to do so. The advantage to this approach is
that the module can be either extended _or_ included with this change,
but couldn't be without it due to the `ClassMethods` meta-magic.

List has already started doing this as of #314, so we don't have to be
afraid of breaking convention here.
2015-10-05 12:24:53 -07:00
Brandur
42ea34b969 Pagination
Usage on a top-level collection:

```
Stripe::Customer.list.auto_paging_each do |customer|
  puts customer
end
```

Usage on a subcollection:

``` ruby
customer.invoices.auto_paging_each do |invoice|
  puts invoice
end
```

We've also renamed `#all` to `#list` to prevent confusion ("all" implies
that all resources are being returned, and in Stripe's paginated API
this was not the case). An alias has been provided for backward API
compatibility.

Fixes #167.

Replaces #211 and #248.
2015-10-05 12:15:09 -07:00
Brandur
60b7617624 Bump version to 1.28.1 2015-10-05 11:45:37 -07:00
Kyle Conroy
8287904c00 Merge pull request #316 from stripe/apt-file-uploads-retrieve-url
Use correct URL for file upload retrieval
2015-10-05 11:36:30 -07:00
Brandur
84f3bd8f17 Bump version to 1.28.0 2015-10-05 11:00:34 -07:00
Jieren Chen
7d28eaab64 Merge pull request #310 from stripe/drj/t5176-legal-entity-override
Disallow directly overriding legal_entity
2015-10-02 12:12:09 -07:00
Andrew Thorp
841a34385a Use correct URL for file upload retrieval 2015-10-01 17:36:51 -07:00
Brandur
b57cd5aca4 Support Ruby 1.8.7 2015-10-01 16:59:56 -07:00
Brandur
71a44f70f5 Move internal method to protected 2015-10-01 16:28:21 -07:00
Jieren Chen
387edb5163 PR Fix: rename to protected_fields 2015-10-01 16:26:30 -07:00
Brandur
e23b57628f Add attribute mass assignment and use it in #save
As detailed in issue #119, we've somewhat unfortunately been allowing
object attributes to be passed in during a #save because we mix any
arguments directly into the serialized hash (it seems that this was
originally intended to be used more for meta parameters that go to the
request).

As also noted in #119, this use causes problems when certain types of
parameters (like subobjects) are used. We're now left in the somewhat
awkward position of either:

1. Removing this functionality on #save and breaking what may be
   behavior that people depend on.
2. Fully support this mass assignment.

This patch takes the second path by extracting a new #update_attributes
method and using it from #save. It's still far from a perfect approach
because keys that have the same name as certain options (e.g. `req_url`)
are not going to work, but it should capture the behavior that most
people want.

Fixes #119.
2015-10-01 16:21:34 -07:00
Jieren Chen
797478786d Disallow directly overriding legal_entity 2015-10-01 13:39:11 -07:00
Brandur
df2e36287d Merge pull request #309 from stripe/brandur-boolean-accessors
Add question mark helpers (e.g. #paid?) for boolean object values
2015-09-30 14:36:23 -07:00
Brandur
a88b062beb Merge pull request #300 from stripe/brandur-upsert
Create if #save is called on a new object
2015-09-30 13:54:20 -07:00
Brandur
c301c6c0f6 Add question mark helpers (e.g. #paid?) for boolean object values
This patch adds question marks helpers (e.g. #paid?) for any values in a
StripeObject that are a boolean. This is fairly idiomatic Ruby in that
it behaves similarly to other libraries like ActiveRecord.

Note that a caveat here is that nullable booleans will not get a helper
added for them if their current value is null. For this reason, we
should eventually prefer to derive these methods from some sort of
programmatic API manifest.

Replaces #257 and #274.
2015-09-30 13:48:59 -07:00
Brandur
af72a57c9d Add #empty? helper on ListObject
This makes ListObject behave a little more like an Array in that it gets
an #empty? helper. This should fit pretty well with the Enumerable
methods that it already has.

Replaces #193.
2015-09-30 13:13:41 -07:00
Brandur
9aa13697f7 Merge pull request #302 from stripe/franklin-normalize-opts
StripeObject: use Util.normalize_opts
2015-09-30 13:05:03 -07:00
Brandur
34ae473d6e Merge pull request #304 from stripe/brandur-enumerable-list-object
Mix `Enumerable` into `ListObject`
2015-09-30 12:59:14 -07:00
Brandur
8c7a976ffb Space this method out a little bit 2015-09-30 11:28:05 -07:00
Brandur
5515824fe2 Mix Enumerable into ListObject
This pulls the `Enumerable` mixin into `ListObject`. There is some
question in pulls like #167 as to the future of `ListObject` and how it
might change when pagination is introduced, but because we're unlikely
to make any backward incompatible changes to the API, it's likely that
`ListObject` will continue to represent a page of data that's been
extracted from the API. Given that assumption, pulling `Enumerable` in
should be relatively safe.

Fixes #227.
2015-09-29 22:26:00 -07:00
Brandur
e0354b70f7 Add RDoc for #save 2015-09-29 22:10:51 -07:00
Brandur
f308bb3a52 Merge pull request #301 from stripe/brandur-symbolize-names
Perform deep name symbolization from .construct_from
2015-09-29 19:02:16 -07:00
Brandur
f31eaa6b1e Perform deep name symbolization from .construct_from
When constructing an object using .construct_from treat keys that are
strings the same as keys which are symbols by calling Util's
symbolize_names on an input hash. This makes guarantees around
consistency a little better.

Fixes #151.
2015-09-29 17:52:16 -07:00
Brandur
ac7d050ecf Create if #save is called on a new object
Modifies the behavior of an update so that it can create an object if it
was new. This allows an "upsert"-like functionality where the SDK will
tend to do the right/expected thing.

This is a tad janky in that it checks for the existence of a class-level
`.create` method which is expected to come from a different module, but
most modules in the project are already fairly deeply intertwined and
co-dependent.

Fixes #165.
2015-09-29 17:39:43 -07:00
Brandur
0db40e43fc Remove use of deprecated URI.escape
But we still want to percent-encode entities like spaces, so instead of
using `CGI.escape` we use a utility from WEBrick.

Fixes #286.
2015-09-29 16:33:20 -07:00
Franklin Hu
844169a744 StripeObject: use Util.normalize_opts
For object initialization and refresh_from, call `normalize_opts` so
`@opts` is in an expected form.
2015-09-29 14:22:11 -07:00
Brandur
30688422c4 Merge pull request #251 from godfat/to_hash-with-array
to_hash should also walk into arrays to make recursive call.
2015-09-28 15:31:54 -07:00
Brandur
2a22605618 Bump version to 1.27.2 2015-09-25 14:25:38 -07:00
Brandur
1a49af7f94 Correct list + retrieval of Bitcoin transactions
Corrects the paths at which the client looks for Bitcoin transactions
and adds a small test suite to check these results.

Fixes stripe/stripe-ruby#236.
2015-09-22 18:23:57 -07:00
Rasmus Rygaard
accb624b35 Bump version to 1.27.1 2015-09-20 10:25:59 -07:00
Rasmus Rygaard
333613fca2 Fix hash literal for compatibility. 2015-09-19 17:10:54 -07:00
Russell Davis
7a0ead3fac Merge pull request #291 from stripe/handle-non-hash-error-responses
Handle error responses that are not hashes more gracefully
2015-09-14 21:34:37 -07:00
Rasmus Rygaard
721071d224 Bump version to 1.27.0 2015-09-14 16:42:14 -07:00