HttpRule.fromJson constructor

HttpRule.fromJson(
  1. Object? j
)

Implementation

factory HttpRule.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return HttpRule(
    selector: switch (json['selector']) {
      null => '',
      Object $1 => decodeString($1),
    },
    get: switch (json['get']) {
      null => null,
      Object $1 => decodeString($1),
    },
    put: switch (json['put']) {
      null => null,
      Object $1 => decodeString($1),
    },
    post: switch (json['post']) {
      null => null,
      Object $1 => decodeString($1),
    },
    delete: switch (json['delete']) {
      null => null,
      Object $1 => decodeString($1),
    },
    patch: switch (json['patch']) {
      null => null,
      Object $1 => decodeString($1),
    },
    custom: switch (json['custom']) {
      null => null,
      Object $1 => CustomHttpPattern.fromJson($1),
    },
    body: switch (json['body']) {
      null => '',
      Object $1 => decodeString($1),
    },
    responseBody: switch (json['responseBody']) {
      null => '',
      Object $1 => decodeString($1),
    },
    additionalBindings: switch (json['additionalBindings']) {
      null => [],
      List<Object?> $1 => [for (final i in $1) HttpRule.fromJson(i)],
      _ => throw const FormatException('"additionalBindings" is not a list'),
    },
  );
}