dcoupon_sdk_flutter_package

A Flutter package for dcoupon SDK. dcoupon SDK allows our clients to log in their users into the dcoupon service, so users can benefit from accessing dcoupon service from 3rd party apps, without needing to use an additional login for dcoupon.

Usage

To use this plugin, add dcoupon_sdk_flutter_package as a dependency in your pubspec.yaml file.

MUST DO: Set up dcoupon SDK

To start using dcoupon SDK methods, you need to provide contents of a json file to the SDK.

  1. Add a json file to your app with the following:
{
  "com.dcoupon.sdk.ClientToken": "<YOUR_CLIENT_TOKEN_HERE>",
  "com.dcoupon.sdk.ClientSecretKey": "<YOUR_CLIENT_SECRET_KEY_HERE>",
  "com.dcoupon.sdk.ClientCountry": "<YOUR_CLIENT_COUNTRY_2_LETTER_CODE_HERE>",
  "com.dcoupon.sdk.ClientDomain": "<YOUR_CLIENT_DOMAIN_HERE>",
  "com.dcoupon.sdk.ClientPublishers": [
    {
      "token":"<YOUR_DEFAULT_CLIENT_PUBLISHER_API_TOKEN_HERE>",
      "name" : "<YOUR_DEFAULT_CLIENT_PUBLISHER_NAME_HERE>"
    },
    {
      "token":"<YOUR_OTHER_CLIENT_PUBLISHER_API_TOKEN_HERE>",
      "name" : "<YOUR_OTHER_CLIENT_PUBLISHER_NAME_HERE>"
    }
  ]
}
  1. Read the json
var jsonContents = await rootBundle.loadString("lib/assets/config/your_json_name.json");
  1. Configure the SDK with the json contents
final dcoupon = Dcoupon(context: context);
//---OR---
final dcoupon = Dcoupon()
dcoupon.setContext(context) //Can assign context later

await dcoupon.loadConfig(jsonContents);

Example

Future<void> login() async {
    // do login
    dcoupon
        .logIn(
      email,
      externalId,
      alias: alias,
      gender: gender,
      birthdate: birthdate,
    )
        .then((response) async {
      //User authenticated in dcoupon, you can call other methods
      DcouponListener response = await dcoupon.getCoupons(
                offset: int.parse(start),
                limit: int.parse(limit),
                sortBy: sortBy,
                companyTokens: companyTokens,
                retailerTokens: retailerTokens,
            )

    }).catchError((ex) {
      print("example.app.login.catchError: " + ex.toString());
    });
  }

API reference

You can check the API reference in this page or go to dcoupon SDK API reference

Libraries

dcoupon_sdk_flutter_package
A flutter package for dcoupon SDK.