getUserProfileV2 method

Future<Response<UserProfileV2>> getUserProfileV2({
  1. CancelToken? cancelToken,
  2. Map<String, dynamic>? headers,
  3. Map<String, dynamic>? extra,
  4. ValidateStatus? validateStatus,
  5. ProgressCallback? onSendProgress,
  6. ProgressCallback? onReceiveProgress,
})

Returns the details of the currently logged in user Contains the id, names, profile picture URL and email of the currently logged in user.

Parameters:

  • cancelToken - A CancelToken that can be used to cancel the operation
  • headers - Can be used to add additional headers to the request
  • extras - Can be used to add flags to the request
  • validateStatus - A ValidateStatus callback that can be used to determine request success based on the HTTP status of the response
  • onSendProgress - A ProgressCallback that can be used to get the send progress
  • onReceiveProgress - A ProgressCallback that can be used to get the receive progress

Returns a Future containing a Response with a UserProfileV2 as data Throws DioException if API call or serialization fails

Implementation

Future<Response<UserProfileV2>> getUserProfileV2({
  CancelToken? cancelToken,
  Map<String, dynamic>? headers,
  Map<String, dynamic>? extra,
  ValidateStatus? validateStatus,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
}) async {
  const path = r'/oauth2/v2/user_profile';
  final options = Options(
    method: r'GET',
    headers: <String, dynamic>{
      ...?headers,
    },
    extra: <String, dynamic>{
      'secure': <Map<String, String>>[
        {
          'type': 'http',
          'scheme': 'bearer',
          'name': 'kindeBearerAuth',
        },
      ],
      ...?extra,
    },
    validateStatus: validateStatus,
  );

  final response = await _dio.request<Object>(
    path,
    options: options,
    cancelToken: cancelToken,
    onSendProgress: onSendProgress,
    onReceiveProgress: onReceiveProgress,
  );

  UserProfileV2? responseData;

  try {
    final rawResponse = response.data;
    responseData = rawResponse == null ? null : _serializers.deserialize(
      rawResponse,
      specifiedType: const FullType(UserProfileV2),
    ) as UserProfileV2;

  } catch (error, stackTrace) {
    throw DioException(
      requestOptions: response.requestOptions,
      response: response,
      type: DioExceptionType.unknown,
      error: error,
      stackTrace: stackTrace,
    );
  }

  return Response<UserProfileV2>(
    data: responseData,
    headers: response.headers,
    isRedirect: response.isRedirect,
    requestOptions: response.requestOptions,
    redirects: response.redirects,
    statusCode: response.statusCode,
    statusMessage: response.statusMessage,
    extra: response.extra,
  );
}