This repository has been archived by the owner on Jan 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#196 add connector info endpoint, handle unknown exchange name
- Loading branch information
Valentin Stavetski
committed
May 14, 2018
1 parent
4238c51
commit 591bf91
Showing
3 changed files
with
75 additions
and
37 deletions.
There are no files selected for viewing
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
47 changes: 47 additions & 0 deletions
47
rest-api/src/main/kotlin/fund/cyber/markets/api/rest/controller/ConnectorInfoController.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package fund.cyber.markets.api.rest.controller | ||
|
||
import fund.cyber.markets.common.model.TokensPair | ||
import fund.cyber.markets.common.rest.service.ConnectorService | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import org.springframework.http.ResponseEntity | ||
import org.springframework.http.ResponseEntity.notFound | ||
import org.springframework.http.ResponseEntity.ok | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.PathVariable | ||
import org.springframework.web.bind.annotation.RestController | ||
import reactor.core.publisher.Mono | ||
import reactor.core.publisher.toMono | ||
|
||
|
||
@RestController | ||
class ConnectorInfoController { | ||
|
||
@Autowired | ||
private lateinit var connectorService: ConnectorService | ||
|
||
@GetMapping("/exchanges") | ||
fun getExchanges(): Mono<ResponseEntity<Set<String>>> { | ||
|
||
val exchanges = connectorService.getExchanges() | ||
|
||
return if (exchanges != null) { | ||
ok().body(exchanges).toMono() | ||
} else { | ||
notFound().build<Set<String>>().toMono() | ||
} | ||
} | ||
|
||
@GetMapping("/exchange/{exchangeName}/pairs") | ||
fun getTrades( | ||
@PathVariable exchangeName: String | ||
): Mono<ResponseEntity<Set<TokensPair>>> { | ||
val pairs = connectorService.getTokensPairsByExchange(exchangeName) | ||
|
||
return if (pairs != null && pairs.isNotEmpty()) { | ||
ok().body(pairs).toMono() | ||
} else { | ||
notFound().build<Set<TokensPair>>().toMono() | ||
} | ||
} | ||
|
||
} |
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