ReleasePackerCommandURL.fromJson constructor

ReleasePackerCommandURL.fromJson(
  1. Object json
)

Implementation

factory ReleasePackerCommandURL.fromJson(Object json) {
  if (json is String) {
    return ReleasePackerCommandURL(json);
  } else if (json is Map) {
    var map = json.asJsonMap;

    var url = map.get<String>('url');
    if (url == null || url.isEmpty) {
      throw ArgumentError("Invalid JSON! Invalid `url`: $url");
    }

    var parameters = map.get<Map>('parameters');
    var authorization = map.get('authorization');
    var body = map.get('body');

    var credential = toCredential(authorization);

    return ReleasePackerCommandURL(url,
        parameters: parameters?.asJsonMap,
        authorization: credential,
        body: body);
  } else {
    throw ArgumentError("Unknown type: $json");
  }
}