-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: init to work with abstractions and complexities for ensure and …
…improve flexibility
- Loading branch information
1 parent
4abde1e
commit b4ef9bd
Showing
17 changed files
with
110 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export 'repositories/repositories.dart'; | ||
export 'results/results.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
lib/app/features/contact/data/results/contact_failed_result.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
enum ContactFailedResult { | ||
tooManyRequests, | ||
unauthorized, | ||
unknown, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export 'contact_failed_result.dart'; |
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
lib/app/features/contact/domain/models/contact_answer.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'package:site/app/features/contact/domain/models/contact_model.dart'; | ||
|
||
class ContactAnswer extends ContactModel { | ||
factory ContactAnswer.fromJson(Map<String, dynamic> json) { | ||
return ContactAnswer( | ||
name: json['sender_name'], | ||
email: json['source_email'], | ||
message: json['template_body'], | ||
subject: json['template_subject'], | ||
response: json['response'], | ||
status: json['status'], | ||
); | ||
} | ||
|
||
ContactAnswer({ | ||
required super.name, | ||
required super.email, | ||
required super.message, | ||
required super.subject, | ||
required this.response, | ||
required this.status, | ||
}); | ||
|
||
final String response; | ||
final String status; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
abstract class ContactModel { | ||
ContactModel({ | ||
required this.name, | ||
required this.email, | ||
required this.message, | ||
required this.subject, | ||
}); | ||
|
||
final String name, email, message, subject; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:site/app/features/contact/contact.dart'; | ||
|
||
class ContactUser extends ContactModel { | ||
ContactUser({ | ||
required super.name, | ||
required super.email, | ||
required super.message, | ||
required super.subject, | ||
}); | ||
|
||
static Map<String, dynamic> toJson(ContactModel contact) { | ||
return { | ||
'sender_name': contact.name, | ||
'source_email': contact.email, | ||
'template_subject': contact.subject, | ||
'template_body': contact.message, | ||
}; | ||
} | ||
|
||
static String toJsonString(ContactModel contact) => | ||
jsonEncode(toJson(contact)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export 'contact.dart'; | ||
export 'contact_answer.dart'; | ||
export 'contact_user.dart'; | ||
export 'contact_model.dart'; |
7 changes: 5 additions & 2 deletions
7
lib/app/features/contact/domain/repositories/contact_repository.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import 'package:site/app/features/contact/domain/models/contact.dart'; | ||
import 'package:site/app/core/result/result.dart'; | ||
import 'package:site/app/features/contact/contact.dart'; | ||
|
||
abstract class ContactRepository { | ||
Future sendMail({required Contact contact}); | ||
Future<Result<ContactFailedResult, ContactAnswer>> sendMail({ | ||
required ContactModel contact, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,10 @@ import 'package:flutter/material.dart'; | |
|
||
import 'package:site/app/core/injections/injections.dart'; | ||
import 'package:site/app/core/l10n/l10n.dart'; | ||
import 'package:site/app/features/contact/domain/models/contact.dart'; | ||
import 'package:site/app/features/contact/presentation/controller/contact_controller.dart'; | ||
import 'package:site/app/features/contact/presentation/widgets/widgets.dart'; | ||
import 'package:site/app/features/contact/contact.dart'; | ||
import 'package:site/app/utils/contact_validators.dart'; | ||
import 'package:site/app/widgets/buttons/buttons.dart'; | ||
import 'package:site/app/widgets/dividers/dividers.dart'; | ||
import 'package:site/app/features/contact/data/repositories/contact_repository_impl.dart'; | ||
|
||
class CustomForm extends StatelessWidget { | ||
CustomForm({ | ||
|
@@ -83,7 +80,7 @@ class CustomForm extends StatelessWidget { | |
onPressed: onPressed, | ||
onLongPress: () { | ||
_contactController?.sendMail( | ||
contact: Contact( | ||
contact: ContactUser( | ||
name: 'felipe sales', | ||
email: '[email protected]', | ||
message: 'teste de mensagem', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import 'package:site/app/features/contact/domain/models/contact.dart'; | ||
import 'package:site/app/features/contact/contact.dart'; | ||
|
||
class AppFixtures { | ||
final tContact = Contact( | ||
final tContact = ContactUser( | ||
name: 'felipecastrosales', | ||
email: '[email protected]', | ||
message: 'Hello, World!', | ||
|