Issue.fromJson constructor

Issue.fromJson(
  1. Map<String, dynamic> json
)

Builds an issue from a JSON-style map (used by the local plan adapter).

Implementation

factory Issue.fromJson(Map<String, dynamic> json) {
  final rawLabels = json['labels'];
  final rawBlockers = json['blocked_by'];
  return Issue(
    id: json['id'] as String,
    identifier: json['identifier'] as String,
    title: json['title'] as String,
    description: json['description'] as String?,
    priority: json['priority'] is int ? json['priority'] as int : null,
    state: json['state'] as String,
    branchName: json['branch_name'] as String?,
    url: json['url'] as String?,
    labels: rawLabels is List
        ? rawLabels
              .whereType<String>()
              .map((s) => s.toLowerCase())
              .toList(growable: false)
        : const <String>[],
    blockedBy: rawBlockers is List
        ? rawBlockers
              .whereType<Map<String, dynamic>>()
              .map(IssueBlocker.fromJson)
              .toList(growable: false)
        : const <IssueBlocker>[],
    createdAt: _parseDate(json['created_at']),
    updatedAt: _parseDate(json['updated_at']),
  );
}