build method
Build the final immutable InitializeCustomerRequest instance.
Implementation
InitializeCustomerRequest build() {
if (_customerId == null || _customerId!.isEmpty) {
throw ArgumentError('Customer ID cannot be empty');
}
// Validate push provider and device token relationship
if (_pushProvider != null && (_deviceToken == null || _deviceToken!.isEmpty)) {
throw ArgumentError('Device token is required when push provider is set');
}
if (_pushProvider == null && _deviceToken != null && _deviceToken!.isNotEmpty) {
throw ArgumentError('Push provider is required when device token is set');
}
_customerAttributes ??= CustomerAttributesBuilder().build();
return InitializeCustomerRequest._(
customerId: _customerId!,
deviceToken: _deviceToken,
customerAttributes: _customerAttributes,
referralCode: _referralCode,
email: _email,
mobile: _mobile,
isGuest: _isGuest ?? false,
pushProvider: _pushProvider?.value,
);
}