postConnectorByConnectorAndWorkflow method

Future<Response<Run>> postConnectorByConnectorAndWorkflow({
  1. required String xKeyclicApp,
  2. required String connector,
  3. required String workflow,
  4. required RunData runData,
  5. String? acceptLanguage,
  6. DateTime? xDateTime,
  7. String? xKeyclicAppPlatform,
  8. String? xKeyclicAppVersion,
  9. CancelToken? cancelToken,
  10. Map<String, dynamic>? headers,
  11. Map<String, dynamic>? extra,
  12. ValidateStatus? validateStatus,
  13. ProgressCallback? onSendProgress,
  14. ProgressCallback? onReceiveProgress,
})

Create one Connector resource.

Parameters:

  • xKeyclicApp
  • connector - The identifier of the resource.
  • workflow
  • runData
  • acceptLanguage
  • xDateTime
  • xKeyclicAppPlatform
  • xKeyclicAppVersion
  • 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 Run as data Throws DioError if API call or serialization fails Keyclic API documentation. Also see Create one Connector resource. Documentation

Implementation

Future<Response<Run>> postConnectorByConnectorAndWorkflow({
  required String xKeyclicApp,
  required String connector,
  required String workflow,
  required RunData runData,
  String? acceptLanguage,
  DateTime? xDateTime,
  String? xKeyclicAppPlatform,
  String? xKeyclicAppVersion,
  CancelToken? cancelToken,
  Map<String, dynamic>? headers,
  Map<String, dynamic>? extra,
  ValidateStatus? validateStatus,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
}) async {
  final String path = r'/connectors/{connector}/workflows/{workflow}/runs'
      .replaceAll('{' r'connector' '}', connector.toString())
      .replaceAll('{' r'workflow' '}', workflow.toString());
  final options = Options(
    method: r'POST',
    headers: <String, dynamic>{
      // to string ??
      if (acceptLanguage != null) r'accept-language': acceptLanguage,
      if (xDateTime != null) r'x-date-time': xDateTime,
      r'x-keyclic-app': xKeyclicApp,
      if (xKeyclicAppPlatform != null)
        r'x-keyclic-app-platform': xKeyclicAppPlatform,
      if (xKeyclicAppVersion != null)
        r'x-keyclic-app-version': xKeyclicAppVersion,
      ...?headers,
    },
    extra: <String, dynamic>{
      'secure': <Map<String, String>>[
        {
          'type': 'apiKey',
          'name': 'bearer',
          'keyName': 'Authorization',
          'where': 'header',
        },
      ],
      ...?extra,
    },
    contentType: 'application/json;charset=UTF-8',
    validateStatus: validateStatus,
  );

  dynamic bodyData;

  try {
    bodyData = runData.toJson();
    // bodyData = jsonEncode(runData);
    // bodyData = jsonDecode(jsonEncode(runData));
  } catch (error, stackTrace) {
    throw DioError(
      requestOptions: options.compose(
        _apiClient.dio.options,
        path,
      ),
      type: DioErrorType.other,
      error: error,
    )..stackTrace = stackTrace;
  }

  final response = await _apiClient.dio.request<Object>(
    path,
    data: bodyData,
    options: options,
    cancelToken: cancelToken,
    onSendProgress: onSendProgress,
    onReceiveProgress: onReceiveProgress,
  );

  Run responseData;

  try {
    responseData =
        await _apiClient.deserializeAsync<Run>(response.data!, 'Run');
  } catch (error, stackTrace) {
    throw DioError(
      requestOptions: response.requestOptions,
      response: response,
      type: DioErrorType.other,
      error: error,
    )..stackTrace = stackTrace;
  }

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