SDK for Dart and Flutter.
Add the dependency from the GitHub repository and pin it to the latest release tag:
dependencies:
WinWinKit:
git:
url: https://github.com/WinWinKit/winwinkit-dart.git
ref: 0.3.0 Then run flutter pub get (or dart pub get for pure Dart projects).
import 'package:WinWinKit/api.dart';
final sdk = WinWinKit();
final usersApi = sdk.getUsersApi(); WinWinKit builds on dio and exposes the underlying client as sdk.dio. You can provide your own Dio instance, override the API base URL (for staging environments), or add interceptors such as request logging.
All methods return a Future<Response<T>>. The deserialized model lives under response.data.
Each snippet instantiates a new client for clarity—reuse a single WinWinKit instance in your app to share Dio configuration.
import 'package:WinWinKit/api.dart';
import 'package:built_value/json_object.dart';
import 'package:dio/dio.dart';
Future<void> syncUser() async {
final sdk = WinWinKit();
final usersApi = sdk.getUsersApi();
final request = UserCreateRequest((b) => b
..appUserId = 'your-app-user-id'
..isPremium = false
..metadata = JsonObject({'plan': 'starter'}));
try {
final response = await usersApi.createOrUpdateUser(
xApiKey: 'your-api-key',
userCreateRequest: request,
);
final createdUser = response.data?.data?.user;
print('Synced user: ${createdUser?.appUserId}');
} on DioException catch (error) {
print('Failed to sync user: ${error.response?.data}');
}
} final sdk = WinWinKit();
final usersApi = sdk.getUsersApi();
final userResponse = await usersApi.getUser(
appUserId: 'your-app-user-id',
xApiKey: 'your-api-key',
);
final user = userResponse.data?.data?.user;
print('Fetched user: ${user?.appUserId}'); final sdk = WinWinKit();
final claimActionsApi = sdk.getClaimActionsApi();
final claimResponse = await claimActionsApi.claimCode(
appUserId: 'your-app-user-id',
xApiKey: 'your-api-key',
userClaimCodeRequest: UserClaimCodeRequest((b) => b..code = 'XYZ123'),
);
final updatedUser = claimResponse.data?.data?.user;
print('Updated user after claim: ${updatedUser?.appUserId}'); claimResponse.data?.data?.rewardsGranted contains the rewards granted to the user, grouped by reward type.
final sdk = WinWinKit();
final rewardsApi = sdk.getRewardsActionsApi();
await rewardsApi.withdrawCredits(
appUserId: 'your-app-user-id',
xApiKey: 'your-api-key',
userWithdrawCreditsRequest: UserWithdrawCreditsRequest((b) => b
..key = 'credit_reward_key'
..amount = 100),
); final sdk = WinWinKit();
final appStoreApi = sdk.getAppStoreApi();
final offerCode = await appStoreApi.getOfferCode(
offerCodeId: 'your-offer-code-id',
xApiKey: 'your-api-key',
);
final offer = offerCode.data?.data?.offerCode;
print('Offer code name: ${offer?.name}'); dio throws a DioException when the request fails or the response cannot be deserialized. Inspect error.response?.statusCode and error.response?.data for details returned by WinWinKit.
The SDKs provide interface for interacting with WinWinKit APIs, but not the UI.
Thus you need to build the user interface for the referral feature in your app.
We plan to provide UI with the SDK in the future. Please let us know if that is your requirement to get started.
dio 5.7.x (pulled in automatically)