Last active
March 4, 2022 12:52
-
-
Save furquanuddin94/c13c3be3b392c188bdd39461936c9ba5 to your computer and use it in GitHub Desktop.
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
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