Skip to content

Code quality improvements #38

@ciriousjoker

Description

@ciriousjoker

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).

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions