Working api call to backend
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import '../global/utils.dart';
|
||||
|
||||
part 'budget.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class Budget {
|
||||
const Budget({
|
||||
this.id,
|
||||
required this.name,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
});
|
||||
|
||||
final int? id;
|
||||
final String name;
|
||||
|
||||
@JsonKey(fromJson: dateFromJson, toJson: dateToJson)
|
||||
final DateTime createdAt;
|
||||
@JsonKey(fromJson: dateFromJson, toJson: dateToJson)
|
||||
final DateTime updatedAt;
|
||||
|
||||
factory Budget.fromJson(Map<String, dynamic> json) => _$BudgetFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$BudgetToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'budget.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Budget _$BudgetFromJson(Map<String, dynamic> json) => Budget(
|
||||
id: json['id'] as int?,
|
||||
name: json['name'] as String,
|
||||
createdAt: dateFromJson(json['created_at'] as int),
|
||||
updatedAt: dateFromJson(json['updated_at'] as int),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$BudgetToJson(Budget instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'created_at': dateToJson(instance.createdAt),
|
||||
'updated_at': dateToJson(instance.updatedAt),
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import '../global/utils.dart';
|
||||
|
||||
part 'budget_category_model.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class BudgetCategory {
|
||||
const BudgetCategory({
|
||||
this.id,
|
||||
required this.budgetId,
|
||||
required this.name,
|
||||
required this.color,
|
||||
required this.createdAt,
|
||||
required this.amount,
|
||||
});
|
||||
|
||||
final int budgetId;
|
||||
final int? id;
|
||||
final String name;
|
||||
final double amount;
|
||||
|
||||
@JsonKey(fromJson: colorFromJson, toJson: colorToJson)
|
||||
final Color color;
|
||||
|
||||
@JsonKey(fromJson: dateFromJson, toJson: dateToJson)
|
||||
final DateTime createdAt;
|
||||
|
||||
factory BudgetCategory.fromJson(Map<String, dynamic> json) =>
|
||||
_$BudgetCategoryFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$BudgetCategoryToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'budget_category_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
BudgetCategory _$BudgetCategoryFromJson(Map<String, dynamic> json) =>
|
||||
BudgetCategory(
|
||||
id: json['id'] as int?,
|
||||
budgetId: json['budget_id'] as int,
|
||||
name: json['name'] as String,
|
||||
color: colorFromJson(json['color'] as String),
|
||||
createdAt: dateFromJson(json['created_at'] as int),
|
||||
amount: (json['amount'] as num).toDouble(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$BudgetCategoryToJson(BudgetCategory instance) =>
|
||||
<String, dynamic>{
|
||||
'budget_id': instance.budgetId,
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'amount': instance.amount,
|
||||
'color': colorToJson(instance.color),
|
||||
'created_at': dateToJson(instance.createdAt),
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import '../global/utils.dart';
|
||||
|
||||
part 'family_model.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class FamilyModel {
|
||||
const FamilyModel({
|
||||
required this.id,
|
||||
required this.budgetId,
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
});
|
||||
|
||||
final int id, budgetId;
|
||||
|
||||
@JsonKey(fromJson: dateFromJson, toJson: dateToJson)
|
||||
final DateTime createdAt;
|
||||
@JsonKey(fromJson: dateFromJson, toJson: dateToJson)
|
||||
final DateTime updatedAt;
|
||||
|
||||
factory FamilyModel.fromJson(Map<String, dynamic> json) =>
|
||||
_$FamilyModelFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$FamilyModelToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'family_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
FamilyModel _$FamilyModelFromJson(Map<String, dynamic> json) => FamilyModel(
|
||||
id: json['id'] as int,
|
||||
budgetId: json['budget_id'] as int,
|
||||
createdAt: dateFromJson(json['created_at'] as int),
|
||||
updatedAt: dateFromJson(json['updated_at'] as int),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$FamilyModelToJson(FamilyModel instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'budget_id': instance.budgetId,
|
||||
'created_at': dateToJson(instance.createdAt),
|
||||
'updated_at': dateToJson(instance.updatedAt),
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import '../global/utils.dart';
|
||||
|
||||
part 'transaction_model.g.dart';
|
||||
|
||||
enum TransactionType {
|
||||
income,
|
||||
expense,
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class Transaction {
|
||||
const Transaction({
|
||||
this.id,
|
||||
required this.amount,
|
||||
required this.transactionType,
|
||||
required this.budgetId,
|
||||
required this.budgetCategoryId,
|
||||
required this.addedByUserId,
|
||||
required this.date,
|
||||
this.createdAt,
|
||||
});
|
||||
|
||||
final int? id;
|
||||
final int budgetId, budgetCategoryId, addedByUserId;
|
||||
final double amount;
|
||||
final TransactionType transactionType;
|
||||
|
||||
@JsonKey(fromJson: dateFromJson, toJson: dateToJson)
|
||||
final DateTime date;
|
||||
|
||||
@JsonKey(fromJson: dateFromJson, toJson: dateToJson)
|
||||
final DateTime? createdAt;
|
||||
|
||||
factory Transaction.fromJson(Map<String, dynamic> json) =>
|
||||
_$TransactionFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$TransactionToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'transaction_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Transaction _$TransactionFromJson(Map<String, dynamic> json) => Transaction(
|
||||
id: json['id'] as int?,
|
||||
amount: (json['amount'] as num).toDouble(),
|
||||
transactionType:
|
||||
$enumDecode(_$TransactionTypeEnumMap, json['transaction_type']),
|
||||
budgetId: json['budget_id'] as int,
|
||||
budgetCategoryId: json['budget_category_id'] as int,
|
||||
addedByUserId: json['added_by_user_id'] as int,
|
||||
date: dateFromJson(json['date'] as int),
|
||||
createdAt: dateFromJson(json['created_at'] as int),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$TransactionToJson(Transaction instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'budget_id': instance.budgetId,
|
||||
'budget_category_id': instance.budgetCategoryId,
|
||||
'added_by_user_id': instance.addedByUserId,
|
||||
'amount': instance.amount,
|
||||
'transaction_type': _$TransactionTypeEnumMap[instance.transactionType]!,
|
||||
'date': dateToJson(instance.date),
|
||||
'created_at': dateToJson(instance.createdAt),
|
||||
};
|
||||
|
||||
const _$TransactionTypeEnumMap = {
|
||||
TransactionType.income: 'income',
|
||||
TransactionType.expense: 'expense',
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
import '../global/utils.dart';
|
||||
|
||||
part 'user.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class User {
|
||||
const User({
|
||||
this.id,
|
||||
required this.name,
|
||||
required this.familyId,
|
||||
required this.budgetId,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.lastActivityAt,
|
||||
});
|
||||
|
||||
final int? id;
|
||||
final int familyId, budgetId;
|
||||
final String name;
|
||||
|
||||
@JsonKey(fromJson: dateFromJson, toJson: dateToJson)
|
||||
final DateTime? createdAt;
|
||||
@JsonKey(fromJson: dateFromJson, toJson: dateToJson)
|
||||
final DateTime? updatedAt;
|
||||
@JsonKey(fromJson: dateFromJson, toJson: dateToJson)
|
||||
final DateTime? lastActivityAt;
|
||||
|
||||
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$UserToJson(this);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'user.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
User _$UserFromJson(Map<String, dynamic> json) => User(
|
||||
id: json['id'] as int?,
|
||||
name: json['name'] as String,
|
||||
familyId: json['family_id'] as int,
|
||||
budgetId: json['budget_id'] as int,
|
||||
createdAt: dateFromJson(json['created_at'] as int),
|
||||
updatedAt: dateFromJson(json['updated_at'] as int),
|
||||
lastActivityAt: dateFromJson(json['last_activity_at'] as int),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$UserToJson(User instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'family_id': instance.familyId,
|
||||
'budget_id': instance.budgetId,
|
||||
'name': instance.name,
|
||||
'created_at': dateToJson(instance.createdAt),
|
||||
'updated_at': dateToJson(instance.updatedAt),
|
||||
'last_activity_at': dateToJson(instance.lastActivityAt),
|
||||
};
|
||||
Reference in New Issue
Block a user