Last active
October 5, 2016 01:12
-
-
Save ronanrodrigo/894c3923e58cc292e46ddd9fc5afa6ab to your computer and use it in GitHub Desktop.
VIPER files
This file contains hidden or 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
| class CreateCustomerInputPresenterApp: CreateCustomerInputPresenter { | |
| var newCustomerForm: NewCustomerForm | |
| var createCustomerOutputPresenter: CreateCustomerOutputPresenterApp | |
| init(newCustomerForm: NewCustomerForm) { | |
| self.newCustomerForm = newCustomerForm | |
| createCustomerOutputPresenter = CreateCustomerOutputPresenterApp() | |
| } | |
| func createCustomer() { | |
| // Criação de uma instância do interactor, injetando dependências e chamando método principal do interactor. | |
| // Como nesse caso não quis me preocupar com camada de persistência usei um repository em memória. | |
| // customerRepositoryStore é uma variável que foi inicializada no AppDelegate, para ter um escopo | |
| // global | |
| CreateCustomerInteractor( | |
| customerRepository: customerRepositoryStore, | |
| createCustomerOutputPresenter: createCustomerOutputPresenter | |
| ).create( | |
| customer: generateCustomerEntity() | |
| ) | |
| } | |
| // Principal método do presenter de input. Aqui é onde será feita a transformação dos | |
| // dados digitados no formulário para uma entity. | |
| func generateCustomerEntity() -> Customer { | |
| return CustomerEntity( | |
| name: newCustomerForm.enteredName, | |
| phone: newCustomerForm.enteredPhone, | |
| email: newCustomerForm.enteredEmail, | |
| address: newCustomerForm.enteredAddress | |
| ) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment