chargebee / chargebee-flutter

MIT License
5 stars 8 forks source link

Code quality improvements #38

Open ciriousjoker opened 1 year ago

ciriousjoker commented 1 year ago

Here are minor improvements that don't warrant their own Github issue, but that would make this package align more with the rest of the Dart ecosystem.

Please don't waste your time on these, the other issues are way more important.

Hide constructor

Chargebee() shouldn't be accessible, since everything is static anyway. You can hide the constructor via

class Chargebee {
  Chargebee._(); 
  ...

Override toString() to make objects easily loggable:

final result = await Chargebee.purchaseProduct(...);
print(result);
logToCrashlytics(result.toString());

Use named parameters for the methods:

await Chargebee.configure("...", "...", "...", "..."); // <-- which of these is the android sdk key?
await configure(
  site: "...",
  apiKey: "...",
  androidSdkKey: "...", // <-- this can be removed without potentially passing null in a random place in the arglist
  iosSdkKey: "...",
);

PurchaseResult.status should be an enum:

Yes, you can google and search for valid values in the website documentation, but its faster to have your code editor autocomplete everything or at least spit out the inline documentation (which is also missing: #37).

cb-amutha commented 1 year ago

@ciriousjoker thanks for your PR for our SDK improvements and it would help us and means a lot. will go through that PR and update them accordingly.