parseAPIRequestMethod function

APIRequestMethod? parseAPIRequestMethod(
  1. String? method
)

Returns the APIRequestMethod for method.

Implementation

APIRequestMethod? parseAPIRequestMethod(String? method) {
  if (method == null) return null;
  method = method.trim();

  switch (method) {
    case 'get':
    case 'GET':
      return APIRequestMethod.GET;
    case 'post':
    case 'POST':
      return APIRequestMethod.POST;
    case 'put':
    case 'PUT':
      return APIRequestMethod.PUT;
    case 'delete':
    case 'DELETE':
      return APIRequestMethod.DELETE;
    case 'patch':
    case 'PATCH':
      return APIRequestMethod.PATCH;
    case 'optionS':
    case 'OPTIONS':
      return APIRequestMethod.OPTIONS;
    case 'head':
    case 'HEAD':
      return APIRequestMethod.HEAD;
    default:
      return null;
  }
}