class GithubEvent { final String id; final String type; final Actor actor; final Repo repo; final Payload payload; final bool public; final DateTime createdAt; GithubEvent({ required this.id, required this.type, required this.actor, required this.repo, required this.payload, required this.public, required this.createdAt, }); factory GithubEvent.fromJson(Map json) { return GithubEvent( id: json['id'].toString(), type: json['type'], actor: Actor.fromJson(json['actor']), repo: Repo.fromJson(json['repo']), payload: Payload.fromJson(json['payload']), public: json['public'], createdAt: DateTime.parse(json['created_at']), ); } } class Actor { final int id; final String login; final String displayLogin; final String avatarUrl; Actor({ required this.id, required this.login, required this.displayLogin, required this.avatarUrl, }); factory Actor.fromJson(Map json) { return Actor( id: json['id'], login: json['login'], displayLogin: json['display_login'], avatarUrl: json['avatar_url'], ); } } class Repo { final int id; final String name; final String url; Repo({required this.id, required this.name, required this.url}); factory Repo.fromJson(Map json) { return Repo(id: json['id'], name: json['name'], url: json['url']); } } class Payload { final String? action; final int? pushId; final List? commits; Payload({this.action, this.pushId, this.commits}); factory Payload.fromJson(Map json) { return Payload( action: json['action'], pushId: json['push_id'], commits: json['commits'] != null ? List.from( json['commits'].map((x) => Commit.fromJson(x)), ) : null, ); } } class Commit { final String sha; final Author author; final String message; final bool distinct; final String url; Commit({ required this.sha, required this.author, required this.message, required this.distinct, required this.url, }); factory Commit.fromJson(Map json) { return Commit( sha: json['sha'], author: Author.fromJson(json['author']), message: json['message'], distinct: json['distinct'], url: json['url'], ); } } class Author { final String email; final String name; Author({required this.email, required this.name}); factory Author.fromJson(Map json) { return Author(email: json['email'], name: json['name']); } }