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.
- Add a json file to your app with the following:
{
"clientApiKey": "<YOUR_CLIENT_TOKEN_HERE>",
"clientSecretKey": "<YOUR_CLIENT_SECRET_KEY_HERE>",
"stage": "<YOUR_CLIENT_DOMAIN_HERE>",
}
- Read the json
var jsonString = await rootBundle.loadString("lib/assets/config/your_json_name.json");
- Initialize the SDK with the json config
final jsonConfig = jsonDecode(jsonString);
DcouponSDK.initializeSdk(
options: DcouponSDKOptions(
stage: jsonConfig['stage'],
clientApiKey: jsonConfig['clientApiKey'],
clientSecretKey: jsonConfig['clientSecretKey'],
));
- Call any SDK method
Example
Future<void> login() async {
// do login
DcouponSDK.instance
.logIn(
externalId,
referralCode: referralCode, //optional
)
.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.