I have created two similar methods:
override def getUsers(organization: String, params: String): F[Either[CodecException, List[Users]]] = for {
resp <- getUsersFromClient(organization, params)
result <- Sync[F].delay(resp)
} yield result
override def getAnimals(url: String, params: String): F[Either[CodecException, List[Animal]]] = for {
resp <- getAnimalsFromClient(url, params)
result <- Sync[F].delay(resp)
} yield result
And I think I should refactor them in some way to have only one method or something by implicits
, but I do not have any idea how it should be done in a right way to keep functional style. Could you help me with that?
EDIT:
def getUsersFromClient(param1: String, params: String): F[HttpResponse] = Hammock.getWithOpts(...)
def getAnimals(param1: String, params: String): F[HttpResponse] = Hammock.getWithOpts(...)
This method also are similar and return F[HttpResponse]