import 'package:json_annotation/json_annotation.dart';

part 'tag_model.g.dart';

@JsonSerializable(fieldRename: FieldRename.snake)
class TagModel {
  String id;
  String name;

  TagModel({required this.id, required this.name});

  factory TagModel.fromJson(Map<String, dynamic> json) {
    return _$TagModelFromJson(json);
  }

  Map<String, dynamic> toJson() => _$TagModelToJson(this);

  @override
  String toString() {
    return 'TagModel{id: $id, name: $name}';
  }

  @override
  bool operator ==(Object other) {
    if (identical(this, other)) return true;

    return other is TagModel && other.id == id && other.name == name;
  }

  @override
  int get hashCode {
    return id.hashCode ^ name.hashCode;
  }
}
