Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/data/core/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ const List<int> successStatus = [
206,
207,
208,
226
226,
];
Original file line number Diff line number Diff line change
@@ -1,45 +1,33 @@
class LaravelRestApiActionsBody {
final List<Action> fields;

LaravelRestApiActionsBody({
required this.fields,
});
LaravelRestApiActionsBody({required this.fields});

factory LaravelRestApiActionsBody.fromJson(Map<String, dynamic> json) {
return LaravelRestApiActionsBody(
fields: (json['fields'] as List<dynamic>)
.map((e) => Action.fromJson(e as Map<String, dynamic>))
.toList(),
fields:
(json['fields'] as List<dynamic>)
.map((e) => Action.fromJson(e as Map<String, dynamic>))
.toList(),
);
}

Map<String, dynamic> toJson() {
return {
'fields': fields.map((action) => action.toJson()).toList(),
};
return {'fields': fields.map((action) => action.toJson()).toList()};
}
}

class Action {
final String name;
final String value;

Action({
required this.name,
required this.value,
});
Action({required this.name, required this.value});

factory Action.fromJson(Map<String, dynamic> json) {
return Action(
name: json['name'] as String,
value: json['value'] as String,
);
return Action(name: json['name'] as String, value: json['value'] as String);
}

Map<String, dynamic> toJson() {
return {
'name': name,
'value': value,
};
return {'name': name, 'value': value};
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
class LaravelRestApiMutateBody {
List<Mutation> mutate;

LaravelRestApiMutateBody({
required this.mutate,
});
LaravelRestApiMutateBody({required this.mutate});

factory LaravelRestApiMutateBody.fromJson(Map<String, dynamic> json) {
return LaravelRestApiMutateBody(mutate: json["mutate"]);
Expand All @@ -19,11 +17,7 @@ class Mutation {
Map<String, dynamic>? attributes;
dynamic key;

Mutation({
required this.operation,
this.attributes,
this.key,
});
Mutation({required this.operation, this.attributes, this.key});

factory Mutation.fromJson(Map<String, dynamic> json) {
return Mutation(
Expand All @@ -42,11 +36,4 @@ class Mutation {
}
}

enum MutationOperation {
create,
update,
attach,
detach,
toggle,
sync,
}
enum MutationOperation { create, update, attach, detach, toggle, sync }
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,34 @@ class LaravelRestApiSearchBody {
factory LaravelRestApiSearchBody.fromJson(Map<String, dynamic> json) {
return LaravelRestApiSearchBody(
text: json['text'] != null ? TextSearch.fromJson(json['text']) : null,
scopes: (json['scopes'] as List<dynamic>?)
?.map((e) => Scope.fromJson(e))
.toList(),
filters: (json['filters'] as List<dynamic>?)
?.map((e) => Filter.fromJson(e))
.toList(),
sorts: (json['sorts'] as List<dynamic>?)
?.map((e) => Sort.fromJson(e))
.toList(),
selects: (json['selects'] as List<dynamic>?)
?.map((e) => Select.fromJson(e))
.toList(),
includes: (json['includes'] as List<dynamic>?)
?.map((e) => Include.fromJson(e))
.toList(),
aggregates: (json['aggregates'] as List<dynamic>?)
?.map((e) => Aggregate.fromJson(e))
.toList(),
instructions: (json['instructions'] as List<dynamic>?)
?.map((e) => Instruction.fromJson(e))
.toList(),
scopes:
(json['scopes'] as List<dynamic>?)
?.map((e) => Scope.fromJson(e))
.toList(),
filters:
(json['filters'] as List<dynamic>?)
?.map((e) => Filter.fromJson(e))
.toList(),
sorts:
(json['sorts'] as List<dynamic>?)
?.map((e) => Sort.fromJson(e))
.toList(),
selects:
(json['selects'] as List<dynamic>?)
?.map((e) => Select.fromJson(e))
.toList(),
includes:
(json['includes'] as List<dynamic>?)
?.map((e) => Include.fromJson(e))
.toList(),
aggregates:
(json['aggregates'] as List<dynamic>?)
?.map((e) => Aggregate.fromJson(e))
.toList(),
instructions:
(json['instructions'] as List<dynamic>?)
?.map((e) => Instruction.fromJson(e))
.toList(),
gates:
(json['gates'] as List<dynamic>?)?.map((e) => e as String).toList(),
page: json['page'] as int?,
Expand Down Expand Up @@ -86,9 +93,7 @@ class TextSearch {
}

Map<String, dynamic> toJson() {
return {
if (value != null) 'value': value,
};
return {if (value != null) 'value': value};
}
}

Expand All @@ -106,10 +111,7 @@ class Scope {
}

Map<String, dynamic> toJson() {
return {
'name': name,
if (parameters != null) 'parameters': parameters,
};
return {'name': name, if (parameters != null) 'parameters': parameters};
}
}

Expand All @@ -128,9 +130,10 @@ class Filter {
operator: json['operator'] as String?,
value: json['value'],
type: json['type'] as String?,
nested: (json['nested'] as List<dynamic>?)
?.map((e) => Filter.fromJson(e))
.toList(),
nested:
(json['nested'] as List<dynamic>?)
?.map((e) => Filter.fromJson(e))
.toList(),
);
}

Expand Down Expand Up @@ -159,10 +162,7 @@ class Sort {
}

Map<String, dynamic> toJson() {
return {
'field': field,
'direction': direction,
};
return {'field': field, 'direction': direction};
}
}

Expand All @@ -172,15 +172,11 @@ class Select {
Select({required this.field});

factory Select.fromJson(Map<String, dynamic> json) {
return Select(
field: json['field'] as String,
);
return Select(field: json['field'] as String);
}

Map<String, dynamic> toJson() {
return {
'field': field,
};
return {'field': field};
}
}

Expand All @@ -194,9 +190,10 @@ class Include {
factory Include.fromJson(Map<String, dynamic> json) {
return Include(
relation: json['relation'] as String,
filters: (json['filters'] as List<dynamic>?)
?.map((e) => Filter.fromJson(e))
.toList(),
filters:
(json['filters'] as List<dynamic>?)
?.map((e) => Filter.fromJson(e))
.toList(),
limit: json['limit'] as int?,
);
}
Expand Down Expand Up @@ -228,9 +225,10 @@ class Aggregate {
relation: json['relation'] as String,
type: json['type'] as String,
field: json['field'] as String,
filters: (json['filters'] as List<dynamic>?)
?.map((e) => Filter.fromJson(e))
.toList(),
filters:
(json['filters'] as List<dynamic>?)
?.map((e) => Filter.fromJson(e))
.toList(),
);
}

Expand All @@ -253,17 +251,15 @@ class Instruction {
factory Instruction.fromJson(Map<String, dynamic> json) {
return Instruction(
name: json['name'] as String,
fields: (json['fields'] as List<dynamic>)
.map((e) => Field.fromJson(e))
.toList(),
fields:
(json['fields'] as List<dynamic>)
.map((e) => Field.fromJson(e))
.toList(),
);
}

Map<String, dynamic> toJson() {
return {
'name': name,
'fields': fields.map((e) => e.toJson()).toList(),
};
return {'name': name, 'fields': fields.map((e) => e.toJson()).toList()};
}
}

Expand All @@ -274,16 +270,10 @@ class Field {
Field({required this.name, required this.value});

factory Field.fromJson(Map<String, dynamic> json) {
return Field(
name: json['name'] as String,
value: json['value'],
);
return Field(name: json['name'] as String, value: json['value']);
}

Map<String, dynamic> toJson() {
return {
'name': name,
'value': value,
};
return {'name': name, 'value': value};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ class LaravelRestApiMutateResponse {
final List<dynamic> created;
final List<dynamic> updated;

LaravelRestApiMutateResponse({
required this.created,
required this.updated,
});
LaravelRestApiMutateResponse({required this.created, required this.updated});

factory LaravelRestApiMutateResponse.fromJson(Map<String, dynamic> json) {
return LaravelRestApiMutateResponse(
Expand All @@ -15,9 +12,6 @@ class LaravelRestApiMutateResponse {
}

Map<String, dynamic> toJson() {
return {
'created': created,
'updated': updated,
};
return {'created': created, 'updated': updated};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ class PaginatedResponse<T> {
factory PaginatedResponse.fromJson(Map<String, dynamic> json) {
return PaginatedResponse(
currentPage: json['current_page'],
data: (json['data'] as List<dynamic>)
.map((item) => UserData.fromJson(item))
.toList(),
data:
(json['data'] as List<dynamic>)
.map((item) => UserData.fromJson(item))
.toList(),
from: json['from'],
lastPage: json['last_page'],
perPage: json['per_page'],
Expand Down Expand Up @@ -64,11 +65,7 @@ class UserData {
}

Map<String, dynamic> toJson() {
return {
'id': id,
'name': name,
'gates': gates.toJson(),
};
return {'id': id, 'name': name, 'gates': gates.toJson()};
}
}

Expand Down Expand Up @@ -114,15 +111,11 @@ class MetaData {
MetaData({required this.gates});

factory MetaData.fromJson(Map<String, dynamic> json) {
return MetaData(
gates: MetaGates.fromJson(json['gates']),
);
return MetaData(gates: MetaGates.fromJson(json['gates']));
}

Map<String, dynamic> toJson() {
return {
'gates': gates.toJson(),
};
return {'gates': gates.toJson()};
}
}

Expand All @@ -132,14 +125,10 @@ class MetaGates {
MetaGates({required this.authorizedToCreate});

factory MetaGates.fromJson(Map<String, dynamic> json) {
return MetaGates(
authorizedToCreate: json['authorized_to_create'],
);
return MetaGates(authorizedToCreate: json['authorized_to_create']);
}

Map<String, dynamic> toJson() {
return {
'authorized_to_create': authorizedToCreate,
};
return {'authorized_to_create': authorizedToCreate};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ mixin ActionsFactory<T> {
data: response.body?['data']['impacted'] ?? 0,
);
} catch (exception) {
return RestApiResponse<int>(
message: response.message,
statusCode: 500,
);
return RestApiResponse<int>(message: response.message, statusCode: 500);
}
}
}
Loading