Skip to content

Instantly share code, notes, and snippets.

@furquanuddin94
Last active March 4, 2022 12:52
Show Gist options
  • Save furquanuddin94/c13c3be3b392c188bdd39461936c9ba5 to your computer and use it in GitHub Desktop.
Save furquanuddin94/c13c3be3b392c188bdd39461936c9ba5 to your computer and use it in GitHub Desktop.
package com.someRandomVendor.search
private[search] class SomeRandomVendorSearchService(
client: SomeRandomVendorClient,
requestMapper: Mapper[SearchRequest, SomeRandomVendorSearchRequest],
responseMapper: Mapper[SomeRandomVendorSearchResponse, SearchResponse]) extends SearchService {
override def search(request: SearchRequest): Future[SearchResponse] = {
for {
//validate request
_ <- requestValidator.validate(request)
//map to vendor request
vendorRequest <- requestMapper.map(request)
//do the api call to vendor
vendorResponse <- client.search(vendorRequest)
//map vendor response back to your model
response <- responseMapper.map(vendorResponse, someRandomVendorResponse)
} yield response
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment