38 Commits

Author SHA1 Message Date
helenye-stripe
6d34376960
Explicitly pass through custom headers in retrieve (#1576)
* Fix options passing in execute_request_initialize_from

* fix comments

* bug with combine then extract

* rubocop

* more thorough testing

* fix extra call

* pr feedback
2025-04-09 10:02:13 -07:00
helenye-stripe
fb11d83248
Fix APIResource#retrieve bug not returning instance of custom resources (#1476)
* Fix refresh bug not returning specific instance type for custom resources

* tests
2024-10-28 10:29:13 -07:00
Jonathan Smith
042918c5f8
Always return the result of APIResource#refresh in APIResource.retrieve (#1473)
* Always return the result of .refresh in .retrieve

With the refactor of v13, there are now cases where `self` is not
mutated in the call to refresh and instead a new object is returned.
This change ensures that the new object is always returned by returning
the result of refresh instead.

* Update install instructions for stripe-mock
2024-10-23 08:45:51 -07:00
Ramya Rao
39d8736525
Support for APIs in the new API version 2024-09-30.acacia (#1458) 2024-10-01 09:35:59 -07:00
helenye-stripe
a12ff9cdb8
Add last_response to StripeObject (#1377)
* Add last_response to StripeObject

* Add more data to test and fix README
2024-04-09 10:52:43 -07:00
helenye-stripe
ce8d7ca4cc
Add methods for dynamically referenced constants (#1327)
* Update dynamic constant references

* Manual additionsg

* Fix lint

* Use const_Get

* Remove puts
2024-02-09 17:15:39 -08:00
pakrym-stripe
b841931ffe
Use request_stripe_object for all requests (#1071) 2022-06-13 10:21:38 -07:00
pakrym-stripe
fc480cdb6c
Add supporting classes for test helper generation (#1034) 2022-03-28 08:00:54 -07:00
Dominic Charley-Roy
59eb8d06cf
Add support for making a request and receiving the response as a stream. (#983) 2021-06-24 10:24:11 -04:00
Brandur
3433130c5d
Rename API resource's request method (#936)
As seen in #928, the `refresh` method doesn't work for an event class.
This is because event has a field called `request`, and it ends up
replacing the `request` method that it inherited from being an API
resource, so when `refresh` tries to make a request, it fails because it
tries to invoke it on the accessor added for the event's property.

Here we give `request` a much more unique name so that it will never
conflict with a property field again, and update all internal references
to use the new name. We use `alias` to make the old name available for
backwards compatibility reasons because its been around for so long that
people are probably calling it.

Fixes #928.
2020-08-05 16:00:37 -07:00
Alex Rattray
69b5e6e1c3 Rename to request_stripe_object, use with codegen 2019-08-06 17:23:11 -07:00
Alex Rattray
5e8faa28ed wip 2019-08-02 12:34:53 -07:00
Brandur
d71cda7adf Better error message when passing non-string to custom method
Raises a slightly more helpful error message when passing a non-string
to a custom method (currently, it reads "no implicit conversion of Hash
into String", which is terrible).

This a partial remediation for the problem encountered in #809.
2019-07-15 16:38:05 -07:00
Olivier Bellone
ec91de6849
Upgrade Rubocop and fix a bunch of issues (#786)
* Bump Rubocop to 0.57.2

* Style/StderrPuts: Use warn instead of .puts

* Style/ExpandPathArguments: Use expand_path('../test_helper', __dir__) instead of expand_path('../../test_helper', __FILE__)

* Style/Encoding: Unnecessary utf-8 encoding comment

* Style/StringLiterals: Prefer double-quoted strings

* Style/AccessModifierDeclarations

* Style/FormatStringToken: Prefer annotated tokens

* Naming/UncommunicativeMethodParamName

* Metrics/LineLength: set maximum line length to 100 characters

* Style/IfUnlessModifier: Favor modifier if usage when having a single-line body

* Style/ClassVars

* Metrics/LineLength: set maximum line length to 80 characters (default)

* Style/AccessModifierDeclarations: EnforcedStyle: inline
2019-05-24 10:43:42 -07:00
Olivier Bellone
160028ada1
New custom_method DSL for defining custom API request methods as static methods (#754)
New `custom_method` DSL for defining custom API request methods as static methods
2019-04-02 10:06:40 -07:00
Olivier Bellone
b4e57ea981
Better resource_url method 2018-07-19 14:23:07 +02: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
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
Brandur
1886d9a625 Move to an alternative system based on StripeClient 2017-02-14 12:17:37 -08:00
Brandur
593bbab53f Use unambiguous wording "StripeResponse object" instead of "structure" 2017-02-14 12:17:37 -08:00
Brandur
843ea88219 Add a StripeResponse to objects created by API calls 2017-02-14 12:17:37 -08:00
Brandur
c796958516 Generalize saving nested resources
Since #433, saving API resources nested under other API resources has
not been the default. Instead, any instances where this should occur
have been special cased with specific method implementations that would
set the `#save_with_parent` flag when a field is written.

This ended up causing some problems because as seen in #457, because
places that we need to do this aren't well vetted, some were forgotten.

This makes implementation of new fields that need this behavior simpler
by implementing a `.save_nested_resource` metraprogramming method on the
`APIResource` class. This can be called as necessary by any concrete API
resource implementations.

We replace existing implementatinos and also add one to `Subscription`,
which had previously been suffering from a similar problem where its
`#source` had not received a special case.
2016-08-30 11:52:16 -07:00
Brandur
6560cfaf4b Don't talk about "default source" here 2016-07-01 15:54:38 -07:00
Brandur
2a4a50da8e Introduce #save_with_parent flag
Introduce a `#save_with_parent` flag that allows the default behavior of
never saving API resources nested under a parent to be overridden, a
feature that we so far only know to need for updating a source under a
customer.
2016-07-01 15:54:38 -07:00
Joshua Kovach
e226ef2ea1 Change everything from url to resource_url 2016-03-11 02:53:50 -05: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
Bob Long
c269e9bd9b Safer argument parsing (attempt 2) 2015-03-25 15:15:02 +00:00
Brian Krausz
9659b403c9 Fix object expansion
Fixes #206
2015-02-15 20:34:16 -08:00
Brian Krausz
4d611c62f7 Support persisted use of Stripe-Account header everywhere
Including implicit use in /v1/accounts/ endpoints
2015-02-09 23:38:34 -08:00
Weston Platter
30b0e4156a formatting. remove () from methods that don't have arguments 2014-11-02 20:28:43 -07:00
Tim Craft
0fc6ee5e5b Return self from Stripe::StripeObject#refresh_from 2014-08-22 19:43:13 +01:00
Ross Boucher
5ffde047d3 Add the ability to send options with retrieve requests. 2013-02-01 12:12:03 -08:00
Ross Boucher
7f87b2bc4a Add support for list objects. Bumps version to 1.7.5 2012-10-25 19:42:23 -07:00
Amber Feng
478ff80ac4 Add Account API resource. 2012-08-16 12:25:15 -07:00
Greg Brockman
22907c7046 Fixup whitespace 2012-06-19 23:15:08 -07:00
Greg Brockman
6031cbf7b1 Improve method layout 2012-06-19 23:13:59 -07:00
Akash Manohar J
481d8110f2 Moves classes to seperate files
Signed-off-by: Akash Manohar J <akash@akash.im>
2012-05-15 02:38:09 +05:30