joinLoyalty method

Future<String> joinLoyalty(
  1. String phone,
  2. String? email,
  3. String? firstName,
  4. String? lastName,
  5. String? shopId,
)

Joins the loyalty program (loyalty/members/join) and returns the response envelope as a JSON string { "status": ..., "payload": { ... } }. The shop is identified by the SDK's configured shop_id; phone is required. Dart layer parses the result into LoyaltyJoinResponse.

Implementation

Future<String> joinLoyalty(String phone, String? email, String? firstName, String? lastName, String? shopId) async {
  final String pigeonVar_channelName = 'dev.flutter.pigeon.personalization_flutter_sdk.PersonalizationHostApi.joinLoyalty$pigeonVar_messageChannelSuffix';
  final BasicMessageChannel<Object?> pigeonVar_channel = BasicMessageChannel<Object?>(
    pigeonVar_channelName,
    pigeonChannelCodec,
    binaryMessenger: pigeonVar_binaryMessenger,
  );
  final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[phone, email, firstName, lastName, shopId]);
  final List<Object?>? pigeonVar_replyList =
      await pigeonVar_sendFuture as List<Object?>?;
  if (pigeonVar_replyList == null) {
    throw _createConnectionError(pigeonVar_channelName);
  } else if (pigeonVar_replyList.length > 1) {
    throw PlatformException(
      code: pigeonVar_replyList[0]! as String,
      message: pigeonVar_replyList[1] as String?,
      details: pigeonVar_replyList[2],
    );
  } else if (pigeonVar_replyList[0] == null) {
    throw PlatformException(
      code: 'null-error',
      message: 'Host platform returned null value for non-null return value.',
    );
  } else {
    return (pigeonVar_replyList[0] as String?)!;
  }
}