createUser method
Future<Response<CreateUserResponse> >
createUser({
- CreateUserRequest? createUserRequest,
- CancelToken? cancelToken,
- Map<
String, dynamic> ? headers, - Map<
String, dynamic> ? extra, - ValidateStatus? validateStatus,
- ProgressCallback? onSendProgress,
- ProgressCallback? onReceiveProgress,
Create User Creates a user record and optionally zero or more identities for the user. An example identity could be the email address of the user.
Parameters:
createUserRequest
- The details of the user to create.cancelToken
- ACancelToken
that can be used to cancel the operationheaders
- Can be used to add additional headers to the requestextras
- Can be used to add flags to the requestvalidateStatus
- AValidateStatus
callback that can be used to determine request success based on the HTTP status of the responseonSendProgress
- AProgressCallback
that can be used to get the send progressonReceiveProgress
- AProgressCallback
that can be used to get the receive progress
Returns a Future containing a Response
with a CreateUserResponse as data
Throws DioException
if API call or serialization fails
Implementation
Future<Response<CreateUserResponse>> createUser({
CreateUserRequest? createUserRequest,
CancelToken? cancelToken,
Map<String, dynamic>? headers,
Map<String, dynamic>? extra,
ValidateStatus? validateStatus,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
const path = r'/api/v1/user';
final options = Options(
method: r'POST',
headers: <String, dynamic>{
...?headers,
},
extra: <String, dynamic>{
'secure': <Map<String, String>>[
{
'type': 'http',
'scheme': 'bearer',
'name': 'kindeBearerAuth',
},
],
...?extra,
},
contentType: 'application/json',
validateStatus: validateStatus,
);
dynamic bodyData;
try {
const type = FullType(CreateUserRequest);
bodyData = createUserRequest == null ? null : _serializers.serialize(createUserRequest, specifiedType: type);
} catch(error, stackTrace) {
throw DioException(
requestOptions: options.compose(
_dio.options,
path,
),
type: DioExceptionType.unknown,
error: error,
stackTrace: stackTrace,
);
}
final response = await _dio.request<Object>(
path,
data: bodyData,
options: options,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
CreateUserResponse? responseData;
try {
final rawResponse = response.data;
responseData = rawResponse == null ? null : _serializers.deserialize(
rawResponse,
specifiedType: const FullType(CreateUserResponse),
) as CreateUserResponse;
} catch (error, stackTrace) {
throw DioException(
requestOptions: response.requestOptions,
response: response,
type: DioExceptionType.unknown,
error: error,
stackTrace: stackTrace,
);
}
return Response<CreateUserResponse>(
data: responseData,
headers: response.headers,
isRedirect: response.isRedirect,
requestOptions: response.requestOptions,
redirects: response.redirects,
statusCode: response.statusCode,
statusMessage: response.statusMessage,
extra: response.extra,
);
}