pindo_client 1.0.2 copy "pindo_client: ^1.0.2" to clipboard
pindo_client: ^1.0.2 copied to clipboard

discontinuedreplaced by: pindo
outdated

A wrapper to use all the functions of the Pindo API written in Dart.

Pindo Client #

Pindo Client codecov style: very good analysis License: MIT

This is a non-official wrapper for the Pindo API written in Dart.

Click here to learn more about Pindo.

Getting Started #


Add the dependency

dependendies:
  pindo_client: ^1.0.2

Usage #


You need a PindoClient() object to use all the functionalities offered by the API. Pindo Client uses Dio under the hood to handle http requests. If you are using Dio in your app and already have a Dio object initialized, reusing it is recommended but not required while initializing a new PindoClient().

final pindo = PindoClient();

Registration #

To create a new Pindo account, use the function register that takes a username, an email and a password as parameters (all of them are as strings and required).

import 'package:pindo_client/pindo_client.dart';
Future<void> main() async{
    final pindo = PindoClient();
    await pindo.register(
      username:'pindo',
      email:'pindo@test.com',
      password: 'awesome-password'
    ).then((_)=>print('Logged in')).onError((e,s)=>print('$e'));
}

Token #

To get the user's token, use the function getToken that takes a username and a password (all as string and required); and returns the token(string).

import 'package:pindo_client/pindo_client.dart';
Future<void> main() async{
  final pindo = PindoClient();
  await pindo.getToken(
    username:'pindo',
    password:'awesome-password'
  ).then((token)=>print(token)).onError((e,s)=>print('$e'));
}

Refresh Token #

To refresh the user's token, use the function refreshToken that takes a username and a password(all as string and required); and returns the refreshed token(string).

import 'package:pindo_client/pindo_client.dart';
Future<void> main() async{
  final pindo = PindoClient();
  await pindo.refreshToken(
    username:'pindo',
    password:'awesome-password'
  ).then((token)=>print(token)).onError((e,s)=>print('$e'));
}

Balance #

To get the user's balance, use the function balance that takes the user's token and returns their balance(double).

import 'package:pindo_client/pindo_client.dart';
Future<void> main() async{
  final pindo = PindoClient();
  await pindo.balance(
    token:'awesomest-token-in-the-entire-world',
  ).then((balance)=>print('$balance')).onError((e,s)=>print('$e'));
}

SMS #

To send an SMS, use the function sendSMS that takes the parameters: token(sender's token), to(the receiver's phone number), from(the sender's name), and text(the sms body) all of them as strings. This function returns the user's remaining balance after they have sent the SMS.

Note: Only works with Rwandan 🇷🇼 phone numbers

import 'package:pindo_client/pindo_client.dart';
Future<void> main() async{
  final pindo = PindoClient();
  await pindo.sendSMS(
    token:'<my-token>',
    to: '<my-phone-number>',
    from: 'Pindo',
    text: 'Hello Pindo',
  ).then((balance)=>print('$balance')).onError((e,s)=>print('$e'));
}

Organization #

To update a pindo organization, use the function organization which takes four parameters: a token(String), the organization name(String), a webhook url(String) and the number of retries(int). This function returns the organization's URL.

Future<void> main() async{
  final pindo = PindoClient();
  await pindo.organization(
    token: '<my-token>',
    name: '<org-name>',
    webHookURL: 'https://example.com/hook',
    retriesCount: 7,
    ).then((url)=>print(url)).onError((e,s)=>print('$e'));
}

Forgot Password #

To send the user an email to reset their password, use the function forgotPassword which takes one parameter: the user's email addrres.

  Future<void> main()async{
    final pindo = PindoClient();
    await pindo.forgotPassword(email: 'tester@test.com').then(
    (_)=>print('Email sent')).onError((e,s)=>print('$e'));
  }

Contribution #

Please make sure your code is tested before pushing

About Pindo #

Visit the website here; or check the Pindo on Github.

Author #

Boris Kayi

1
likes
120
pub points
0%
popularity

Publisher

unverified uploader

A wrapper to use all the functions of the Pindo API written in Dart.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

dio, meta

More

Packages that depend on pindo_client