pabulo_sdk 1.0.11 copy "pabulo_sdk: ^1.0.11" to clipboard
pabulo_sdk: ^1.0.11 copied to clipboard

Pábulo: The future of Loyalty, Merchants & Wallet Platforms, Today

Pabulo Platform Dart Library #

Pábulo: The future of Loyalty, Merchants & Wallet Platforms, Today.

Provides APIs for seamlessly connect to the Pabulo Platform and build rich Flutter UIs in no time.

Motivation #


✅ To provide ability to quickly build front-ends in the shortest possible time.
✅ Simplifying complex JSON data models into standard Request & Response objects.
✅ Providing efficiency to reduce network traffic by validating data before doing a server round trip.

Get Started #


Future<void> main() async {
  await AppConfig.initialize();

  /// Initialize th Globals for the base framework.
  /// This is a singleton so enable it in the main
  /// for early initialization.
  PabuloGlobals(
    AppConfig().appConfig.baseUrl,
    AppConfig().appConfig.defaults.getRequestTimeOut(),
    AppConfig().appConfig.defaults.language,
  );
  // You code after this.
}

Initialize the PabuloGlobals() with the three parameters:

  1. baseUrl : this is the path to the backend where the core platform is running , i.e. https://api.domain.com or https://api.domain.com:8080
  2. requestTimeOut : Optional The time as [Durations] to wait for backend to respond. If ignored the default is 30 seconds.
  3. language : Optional This is the language 'en-US' or 'fr-FR' to be used for communicating to the backand. If ignored the default is 'en-US'.

🫡 That is all !!! You are now wired up to start using the SDK.

Usage #


Once you have wired the SDK in the main() the next step is to use the repositories[^1] for the business flow that you are working on.

Use case 1: you are building a Login Screen for users to login.

class LoginBloc extends Bloc<LoginEvent, LoginState> {
  // Wire the SDK Repository for Administration Functions.
  final RepoAdmin _repoAdmin = RepoAdmin();

  // On Login Pressed call the api
  Future<void> onLoginPressed() async {
    try {
      RspLogin? rspLogin = await _repoAdmin.letMeIn(
        ReqLogin(consumerEmail: email, consumerPassword: password),);
    } catch (error) {
      // ... handle errors
    }
    // ... reset of your code.
  }
}

Use case 2: you are building a list of items to show with a input field.

/// By extending the DTO objects from the SDK you can now add 
/// input fields on top of the backend response.
class LoyaltySpendData extends LoyaltySpendDto {
  late TextEditingController minimumSpendAmountController;
  late TextEditingController minimumSpendPointsController;
  late TextEditingController incrementSpendAmountController;
  late TextEditingController incrementSpendPointsController;

  LoyaltySpendData({
    super.currency,
    super.incrementSpendAmount,
    super.incrementSpendPoints,
    super.minimumSpendAmount,
    super.minimumSpendPoints,
    super.symbol,
  }) {
    minimumSpendAmountController = TextEditingController(
      text: minimumSpendAmount?.toString() ?? "",
    );
    minimumSpendPointsController = TextEditingController(
      text: minimumSpendPoints?.toString() ?? "",
    );
    incrementSpendAmountController = TextEditingController(
      text: incrementSpendAmount?.toString() ?? "",
    );
    incrementSpendPointsController = TextEditingController(
      text: incrementSpendPoints?.toString() ?? "",
    );
  }
}

[^1] All repositories are Singleton's, that way they are safe to wire any number of times and anywhere in your code.

Conventions #


  1. Understanding naming conventions within the SDK will help you get up and running in no time:

    1. Request Objects: Objects that are used as part of the POST, PUT, PATCH operations, all the class names begin with a prefix Req and these classes are under the path src/models/request.
    2. Response Objects: Objects that are sent back from the server as a response in the http operation, all the class names begin with a prefix Rsp and these classes are under the path src/models/response.
    3. Data Object: Data Transfer Objects (DTO) are objects that hold the actual data, they are part of the Request and Response objects, these classes are suffixed with Dto and implement valid() and copyWith() functionality, and these classes are under the path src/models/factory.
    4. Repositories: these are API functions that directly communicate with backend without you needing to understand the security, uri end-point parameters etc., these classes are prefixed with Repo and are under the path src/repositories.

© Adhvent Consulting Ltd.

0
likes
0
points
339
downloads

Publisher

verified publisheradhvent.biz

Weekly Downloads

Pábulo: The future of Loyalty, Merchants & Wallet Platforms, Today

Homepage

License

unknown (license)

Dependencies

copy_with_extension, equatable, flutter, http, intl, json_annotation, jwt_decoder, path, path_provider, sealed_currencies, universal_io

More

Packages that depend on pabulo_sdk