splitwise_api 0.0.2 copy "splitwise_api: ^0.0.2" to clipboard
splitwise_api: ^0.0.2 copied to clipboard

outdated

A Wrapper over SplitWise API

SplitWise API for Dart Say Thanks! License GitHub stars #

A wrapper based on SplitWise

  • Feel free to open a PR or Issue
  • Uses OAuth 1

-[ ] Included Data Classes in the Package

Steps #

  • Get the consumerKey and consumerSecret from Splitwise Register App
  • Check the example.dart located in example/example.dart

Project Structure #

|-- .gitignore
|-- .metadata
|-- CHANGELOG.md
|-- LICENSE
|-- README.md
|-- example
|   '-- example.dart
|-- lib
|   '-- splitwise_api.dart
'-- pubspec.yaml

Usage

  • Import the package
dependencies:
  splitwise_api: ^0.0.1
  • Import in the file
import 'package:splitwise_api/splitwise_api.dart';
  • Setup SharedPreferences or any other system to save the token and tokenSecret to keep user logged in.
    • For Example :-
import 'package:shared_preferences/shared_preferences.dart';

class SplitWiseHelper {
  saveTokens(String text) async {
    final prefs = await SharedPreferences.getInstance();
    prefs.setString('tokens', text);
  }

  getTokens() async {
    final prefs = await SharedPreferences.getInstance();
    prefs.getString('tokens');
  }
}
  • Now Use the Wrapper and save the tokens.
    • ForExample :-
void main() async {
  SplitWiseService splitWiseService = SplitWiseService.initialize(_consumerKey, _consumerSecret);
  SplitWiseHelper splitWiseHelper = SplitWiseHelper();
  if (splitWiseHelper.getTokens() == null) {
    var authURL = splitWiseService.validateClient();
    print(authURL);
    var tokens = await splitWiseService.validateClient(verifier: 'theTokenYouGetAfterAuthorization');
    //This Will print the token and also return them save them to Shared Prefs
    splitWiseHelper.saveTokens(tokens);
    splitWiseService.validateClient(token: 'tokenYouGet', tokenSecret: 'tokenSecretYouGet');
  } else {
    splitWiseService.validateClient(token: 'FromSaved', tokenSecret: 'FromSaved');
    //Example
    splitWiseService.getCurrentUser();
  }
}

Hit like if it helped

1
likes
0
pub points
23%
popularity

Publisher

unverified uploader

A Wrapper over SplitWise API

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

oauth1

More

Packages that depend on splitwise_api