-
Notifications
You must be signed in to change notification settings - Fork 572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move all services to BasicService #1305
Move all services to BasicService #1305
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments that came to mind while porting everything.
|
||
public virtual StripeList<ApplicationFee> List(ApplicationFeeListOptions options = null, RequestOptions requestOptions = null) | ||
{ | ||
return this.GetEntityList($"{Urls.BaseUrl}/application_fees", requestOptions, options); | ||
} | ||
|
||
public virtual ApplicationFee Refund(string applicationFeeId, int? refundAmount = null, RequestOptions requestOptions = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just remove the Refund
method on this service and force devs to use the ApplicationFeeRefundService instead? If not, should we make this method take an Options class instead of an amount?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 on removing the method.
@@ -21,87 +21,52 @@ public TopupService(string apiKey = null) | |||
|
|||
public virtual Topup Cancel(string topupId, RequestOptions requestOptions = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cancel has no parameters today but might in the future. What is the best approach? Adding it in the future would be a breaking change (unless we add an overloaded method).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I suppose we could make it a convention that all non-standard request methods (i.e. request methods not covered by the CRUD + list interfaces) must take an options argument, even if the options class is empty.
Requestor.PostString( | ||
this.ApplyAllParameters(createOptions, classUrl, false), | ||
this.SetupRequestOptions(requestOptions))); | ||
return this.Post($"{classUrl}", requestOptions, options); | ||
} | ||
|
||
public virtual CardDetails Details(string cardId, RequestOptions requestOptions = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method still uses the old way since it returns CardDetails
and not Card
. What is the right approach? The current method is verbose and error prone IMO but not sure there's a better way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine for now. I have some ideas for covering these cases using generic methods (but will be much simpler to experiment once this PR is merged).
} | ||
|
||
public virtual async Task<Invoice> GetAsync(string invoiceId, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
public virtual StripeList<InvoiceLineItem> ListLineItems(string invoiceId, InvoiceListLineItemsOptions listOptions = null, RequestOptions requestOptions = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as Issuing.Card: This returns a different class so we can't use the GetEntity approach. What is the right way to do this? Should it be in the InvoiceLineItemService (does not yet exist)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave it as is for now.
Requestor.PostString( | ||
this.ApplyAllParameters(createOptions, $"{Urls.BaseUrl}/customers/{customerId}/bank_accounts"), | ||
this.SetupRequestOptions(requestOptions))); | ||
return this.Post($"{Urls.BaseUrl}/customers/{customerId}/bank_accounts", requestOptions, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we stop using /bank_accounts
and move to /sources
like we do with cards? I think this will require a default value for the options class but might be cleaner.
Issue is that stripe-mock will not return a bank account though not a big deal I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 on using /sources
.
@@ -4,7 +4,7 @@ namespace Stripe | |||
using System.Threading.Tasks; | |||
using Stripe.Infrastructure; | |||
|
|||
public class OAuthTokenService : StripeService, | |||
public class OAuthTokenService : BasicService<OAuthToken>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class has no OAuthTokenServiceTest
we should fix this as it makes it dangerous to make random changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with the sentiment, but in practice we'd need local mocking to test this (stripe-mock doesn't support OAuth endpoints).
} | ||
|
||
public virtual OAuthDeauthorize Deauthorize(string clientId, string stripeUserId, RequestOptions requestOptions = null) | ||
{ | ||
var url = ParameterBuilder.ApplyParameterToUrl(Urls.OAuthDeauthorize, "client_id", clientId); | ||
var url = ParameterBuilder.ApplyParameterToUrl($"{Urls.BaseConnectUrl}/oauth/deauthorize", "client_id", clientId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as Issuing.Card
: returns a different object
|
||
public virtual Task<OAuthToken> CreateAsync(OAuthTokenCreateOptions options, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
return this.PostAsync($"{Urls.BaseConnectUrl}/oauth/token", requestOptions, cancellationToken, options); | ||
} | ||
|
||
public virtual OAuthDeauthorize Deauthorize(string clientId, string stripeUserId, RequestOptions requestOptions = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not a OAuthDeauthorizeOptions
or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, but OAuth is definitely an odd case. I wouldn't sweat it if it doesn't abide completely by the library's conventions.
@@ -95,7 +95,7 @@ public virtual async Task<Source> DetachAsync(string customerId, string sourceId | |||
|
|||
public virtual async Task<StripeList<Source>> ListAsync(string customerId, SourceListOptions listOptions = null, RequestOptions requestOptions = null, CancellationToken cancellationToken = default(CancellationToken)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know why we don't simply use the GetEntityList
and DeleteEntity
on this service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we couldn't use DeleteEntity
before because it returned a StripeDeleted
object, but detaching a source always returned a source.
Not sure about GetEntityList
. We can likely use it as well.
d669ed7
to
4346480
Compare
@ob-stripe Okay I did another round of fixes. There are 2 Services left that use |
Yeah, that sounds correct. I updated Doing the same for |
87027dc
to
d450f4c
Compare
This PR moves all existing services over to
BasicService
.cc @stripe/api-libraries