DictionaryApi.java (610B)
1 package com.wimdupont.client; 2 3 import com.wimdupont.config.ApplicationProperties; 4 import com.wimdupont.model.dto.DictionaryDto; 5 import com.wimdupont.model.dto.WordDto; 6 7 import java.util.Arrays; 8 import java.util.Optional; 9 10 public class DictionaryApi { 11 12 private final ApplicationProperties applicationProperties = ApplicationProperties.getInstance(); 13 14 public Optional<WordDto> getDictionary(String word) { 15 return Client.get(applicationProperties.getDictionaryClientUrl() + word, DictionaryDto[].class) 16 .map(Arrays::asList) 17 .map(f -> new WordDto(word, f)); 18 } 19 }