(Beta) simplify stripe.Backend
interface
#1778
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Along similar lines to stripe/stripe-java#1702 in stripe-java.
Summary
Introduces
stripe.StripeRequest
struct, and changesBackend
interface:Setting up
StripeRequest
is broken up into two steps: To achieve the equivalent ofb.Call(method, path, key, params, &result)
, you now doTo achieve the equivalent of
b.CallRaw(method, path, key, body, params, &result)
:To achieve the equivalent of
b.CallMultipart(method, path, key, boundary, body, params, &result)
:Why
This is breaking, but this:
.Call
by adding it ontoStripeRequest
. Otherwise, we would have to break the interface and add a new parameter to.Call
or a new method toBackend
, or we would have to smuggle the data ontoParams
, which isn't really an appropriate place.usage
that we are soon adding to all libraries,ApiMode
that is used byRawRequest
to send preview requests.Backend
, which should make the experience better for future users who need to write an implementation ofBackend
(for mocking in their tests?) --Call
is essentially a convenience wrapper forCallRaw
, but by putting both on the interface, we force users to implement both.Planned follow-ups
RawRequestBackend
now and subsume it intoBackend
. (Will do in a follow-up, to keep the diff manageable).