https://github.com/47degrees/sample-tagless-final
https://github.com/47degrees/sample-tagless-final
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/47degrees/sample-tagless-final
- Owner: 47degrees
- Created: 2018-12-03T10:36:06.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-24T08:19:16.000Z (almost 3 years ago)
- Last Synced: 2025-02-03T14:42:46.071Z (11 months ago)
- Language: Scala
- Size: 25.4 KB
- Stars: 3
- Watchers: 43
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
### EncryptionService
* This service should use a Java library with an static method.
* The static method returns the encrypted array but can also throw some runtime exception.
* We need to implement an algebra that call to this method but logging the exception and raising our exception into the `F` context:
`case object EncryptionError extends RuntimeException with NoStackTrace`
* This is the signature of the Java method:
`com.sample.encryption.Encryptor.encryptString(s: String): Array[Byte]`
### HTTPService
* The company already has a HTTPClient for interacting with their API. We need to add a log call before and after the call.
* We need to implement the algebra through a builder receiving the HTTPClient.
* The client looks like following:
```scala
class SampleClient[F[_]: Async] {
def loadInfoRequest(id: UUID, prefs: Preferences): F[UserInformation] = ???
}
```
### ValidationService
We need to add an implementation for this algebra. It needs to validate the following things:
* The age should be >= 18.
* The gender need to be `M` (Male) or `F` (Female)
* The heightAndWeight comes in the form: 175x80 (cm and kg). We need to split the value and put in two int fields.
The errors need to be accumulated in a NonEmptyList but we don’t give details about the original values, we need to log them as errors.
* Logging
We will use `org.slf4j` for logging but we should treat the logger instantiation and the logging message as a side effect.